예제 #1
0
def thread_archived(postNo):
    is_archived = False
    archived = json.loads(req("https://a.4cdn.org/adv/archive.json"))
    if postNo in archived:
        is_archived = True

    return is_archived
예제 #2
0
def thread_archived(postNo):
    is_archived = False
    archived = json.loads(req("https://a.4cdn.org/adv/archive.json"))
    if postNo in archived:
        is_archived = True

    return is_archived
예제 #3
0
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)
예제 #4
0
def get_new_posts_count(board,postno,replies_count):
    posts = req("https://a.4cdn.org/{board}/thread/{postno}.json"
                             .format(board=board, postno=postno))

    total = None

    if isinstance(posts, str):
        posts = json.loads(posts)
        updated_replies_count = posts['posts'][0]['replies']
        total = updated_replies_count - replies_count

        return total
예제 #5
0
def get_posts_info(board,postno,time_read):
    posts = json.loads(req("https://a.4cdn.org/{board}/thread/{postno}.json"
                             .format(board=board, postno=postno)))

    post_list = []

    for post in posts['posts']:
        if time_read < post['time']:
            #print(post['time'])
            post['unread'] = int(time.time())
            post_list.append(post)


    return post_list
예제 #6
0
def refresh(table_exists=True):
    boards_data = json.loads(req("https://a.4cdn.org/boards.json"))
    database = storage.Storage()
    database.create_boards_table()

    #for board in boards_data:
    #    board['meta_description'] = html.unescape(board['meta_description'])


    database.insert_boards(boards_data,table_exists)

    #for board in decoded_re['boards']:
    #    database.insert_board(board['board'], board['title'], table_exists)

    get()
예제 #7
0
def get_posts_info(board, postno, time_read):

    posts = json.loads(
        req("https://a.4cdn.org/{board}/thread/{postno}.json".format(
            board=board, postno=postno)))

    post_list = []

    for post in posts['posts']:
        if time_read < post['time']:
            #print(post['time'])
            post['unread'] = int(time.time())
            post_list.append(post)

    return post_list
예제 #8
0
def get_threads_info(board,post_no=None):

    thread_info = json.loads(req("https://a.4cdn.org/{board}/threads.json".format(board=board)))

    def search_no(post_no,list):
        for thread in list:
            if thread['no'] == post_no:
                return thread['last_modified']

    if post_no:
        for info in thread_info:
            thread_alive = search_no(post_no,info['threads'])
            if thread_alive:
                thread = {'last_modified':thread_alive,'page':info['page']}
                return thread
예제 #9
0
def get_threads_info(board, post_no=None):

    thread_info = json.loads(
        req("https://a.4cdn.org/{board}/threads.json".format(board=board)))

    def search_no(post_no, list):
        for thread in list:
            if thread['no'] == post_no:
                return thread['last_modified']

    if post_no:
        for info in thread_info:
            thread_alive = search_no(post_no, info['threads'])
            if thread_alive:
                thread = {'last_modified': thread_alive, 'page': info['page']}
                return thread
예제 #10
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)