Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
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)