def get_posts(board_id, postno): board = basc_py4chan.Board(board_id) thread = board.get_thread(postno) post_list = [] post_replies = {} if thread != None: all_posts = thread.all_posts for post in all_posts: post_values = {} post_values['no'] = post.post_id if post.post_id == postno: post_values['replies'] = len(thread.posts) - 1 post_values['sticky'] = int(thread.sticky) else: post_values['replies'] = 0 post_values['sticky'] = 0 post_values['closed'] = int(thread.closed) post_values['name'] = post.name post_values['time'] = post.timestamp post_values['semantic_url'] = post.semantic_url post_values['images'] = int(post.has_file) post_values['has_file'] = int(post.has_file) if post.has_file: post_values['ext'] = post.file_extension post_values['thumbUrl'] = post.thumbnail_url post_values['imgUrl'] = post.file_url post_values['filename'] = post.filename post_values['file_deleted'] = int(post.file_deleted) if post.comment: replies = utils.collect_replies(post.comment) if replies: for reply in replies: if reply not in post_replies: post_replies[reply] = [] post_replies[reply].append(post.post_id) if post.subject and post.comment: post_values['com'] = '<b>{}</b><br>'.format( post.subject) + post.comment elif not post.subject and post.comment: post_values['com'] = post.comment elif post.subject and not post.comment: post_values['com'] = '<b>{}</b>'.format(post.subject) post_list.append(post_values) post_list = utils.parse_posts(post_list, post_replies) pyotherside.send('posts', post_list) else: pyotherside.send('posts_status', post_list)
def get_posts(board_id,postno): board = basc_py4chan.Board(board_id) thread = board.get_thread(postno) post_list = [] post_replies = {} if thread != None: all_posts = thread.all_posts for post in all_posts: post_values = {} post_values['no'] = post.post_id if post.post_id == postno : post_values['replies'] = len(thread.posts) post_values['sticky'] = int(thread.sticky) else: post_values['replies'] = 0 post_values['sticky'] = 0 post_values['closed'] = int(thread.closed) post_values['name'] = post.name post_values['time'] = post.timestamp post_values['ext'] = post.file_extension post_values['file_deleted'] = int(post.file_deleted) post_values['images'] = int(post.has_file) post_values['semantic_url'] = post.semantic_url post_values['thumbUrl'] = post.thumbnail_url post_values['imgUrl'] = post.file_url post_values['filename'] = post.filename post_values['has_file'] = int(post.has_file) if post.comment: replies = utils.collect_replies(post.comment) if replies: for reply in replies: if reply not in post_replies: post_replies[reply]=[] post_replies[reply].append(post.post_id) if post.subject and post.comment: post_values['com'] = '<b>{}</b><br>'.format(post.subject) + post.comment elif not post.subject and post.comment: post_values['com'] = post.comment elif post.subject and not post.comment: post_values['com'] = '<b>{}</b>'.format(post.subject) post_list.append(post_values) post_list = utils.parse_posts(post_list,post_replies) pyotherside.send('posts', post_list) else: pyotherside.send('posts_status', post_list)
def get_threads(board,page): threads = json.loads(req("https://a.4cdn.org/{board}/{page}.json".format(board=board, page=page))) thread_list = [] for thread in threads['threads']: thread_list.append(thread['posts'][0]) ## PYTHONIC PARSING. HTML TAGS dont work well yet, until fix use js method directly from qml thread_list = utils.parse_posts(thread_list,board) pyotherside.send('threads', thread_list)
def get_threads(board_id): #threads = json.loads(req("https://a.4cdn.org/{board}/{page}.json".format(board=board, page=page))) board = basc_py4chan.Board(board_id) threads = [] threads.extend(board.get_all_threads()) thread_list = [] for thread in threads: topic = thread.topic thread_values = {} thread_values['no'] = topic.post_number thread_values['board'] = board_id thread_values['post_board'] = board_id thread_values['replies'] = int(thread.num_replies) thread_values['sticky'] = int(thread.sticky) thread_values['closed'] = int(thread.closed) thread_values['name'] = topic.name thread_values['time'] = topic.timestamp thread_values['semantic_url'] = topic.semantic_url if thread.omitted_images: thread_values['images'] = thread.omitted_images else: thread_values['images'] = int(topic.has_file) thread_values['has_file'] = int(topic.has_file) if topic.has_file: thread_values['ext'] = topic.file_extension thread_values['file_deleted'] = int(topic.file_deleted) thread_values['thumbUrl'] = topic.thumbnail_url thread_values['thumbnail_url'] = topic.thumbnail_url thread_values['imgUrl'] = topic.file_url thread_values['file_url'] = topic.file_url thread_values['filename'] = topic.filename if topic.subject and topic.comment: thread_values['com'] = '<b>{}</b><br>'.format( topic.subject) + topic.comment elif not topic.subject and topic.comment: thread_values['com'] = topic.comment elif topic.subject and not topic.comment: thread_values['com'] = '<b>{}</b>'.format(topic.subject) thread_list.append(thread_values) thread_list = utils.parse_posts(thread_list) pyotherside.send('threads', thread_list)
def get_threads(board_id,page_no): #threads = json.loads(req("https://a.4cdn.org/{board}/{page}.json".format(board=board, page=page))) board = basc_py4chan.Board(board_id) threads = board.get_threads(page_no) thread_list = [] for thread in threads: print(thread.omitted_images) topic = thread.topic thread_values = {} thread_values['no'] = topic.post_number thread_values['board'] = board_id thread_values['post_board'] = board_id thread_values['replies'] = len(thread.posts)-1 thread_values['sticky'] = int(thread.sticky) thread_values['closed'] = int(thread.closed) thread_values['name'] = topic.name thread_values['time'] = topic.timestamp thread_values['ext'] = topic.file_extension thread_values['file_deleted'] = int(topic.file_deleted) if thread.omitted_images: thread_values['images'] = thread.omitted_images else: thread_values['images'] = int(topic.has_file) thread_values['semantic_url'] = topic.semantic_url thread_values['thumbUrl'] = topic.thumbnail_url thread_values['thumbnail_url'] = topic.thumbnail_url thread_values['imgUrl'] = topic.file_url thread_values['file_url'] = topic.file_url thread_values['filename'] = topic.filename thread_values['has_file'] = int(topic.has_file) if topic.subject and topic.comment: thread_values['com'] = '<b>{}</b><br>'.format(topic.subject) + topic.comment elif not topic.subject and topic.comment: thread_values['com'] = topic.comment elif topic.subject and not topic.comment: thread_values['com'] = '<b>{}</b>'.format(topic.subject) thread_list.append(thread_values) thread_list = utils.parse_posts(thread_list) pyotherside.send('threads', thread_list)
def get_posts(board,postno): posts = json.loads(req("https://a.4cdn.org/{board}/thread/{postno}.json" .format(board=board, postno=postno))) post_list = [] post_replies = {} for post in posts['posts']: post_list.append(post) if 'com' in post: replies = utils.collect_replies(post['com']) if replies: for reply in replies: if reply not in post_replies: post_replies[reply]=[] post_replies[reply].append(post['no']) post_list = utils.parse_posts(post_list,board,post_replies) pyotherside.send('posts', post_list)