예제 #1
0
def get_pins_db(post_no=None,board=None):
    database = storage.Storage()
    pins = database.get_pins(post_no,board)

    pins_list=[]

    if post_no == None and board == None:

        for pin in pins:
            short_com = pin['SHORT_COM'][2:-1].replace("'","'")
            filename = database.get_thumb_dir() + "/" + re.findall(r'\d+s.jpg',pin['THUMB_URL'])[0]
            thread_dead =False
            archived = thread_archived(pin['POSTNO'])
            now = epoch_to_readable(pin['TIME_CREATED'])

            post_count = get_new_posts_count(pin['BOARD'],pin['POSTNO'],pin['REPLIES_COUNT'])
            if post_count is None:
                thread_dead = True

            pins_list.append({'no':pin['POSTNO'],'pinBoardId':pin['BOARD'],'com':short_com,'postCount':post_count,
                              'thumbUrl':filename,'threadArchived':archived,'threadDead':thread_dead,'now':now})
            #pins_list.append({'postNo':pin['POSTNO'],'pinFromBoard':pin['BOARD'],'shortCom':short_com,'postCount':post_count,'pinnedThumbSource':filename,'threadArchived':archived,'threadDead':thread_dead})
            #POSTNO,BOARD,SHORT_COM,THUMB_URL,TIME_ADDED,TIME_READ,TIME_CREATED

        print(pins_list)
        #return pins_list
        if sys.platform != 'win32':
            pyotherside.send('pinned_all', pins_list)

    elif post_no and board == None:

        for pin in pins:
            pins_list.append({'postNo':pin['POSTNO'],'board':pin['BOARD']})

        print(pins_list)
        if sys.platform != 'win32':
            pyotherside.send('pinned_postno', pins_list)

    elif board and post_no == None:
        #pin_dict = {}
        for pin in pins:
            pins_list.append(pin['POSTNO'])

        #print(pins_list)

        #pins_list = dict (zip(my_dict.values(),my_dict.keys()))
        if sys.platform != 'win32':
            pyotherside.send('pinned_board', pins_list)
예제 #2
0
def get_pins_db(post_no=None, board=None):
    database = storage.Storage()
    pins = database.get_pins(post_no, board)

    pins_list = []

    if post_no is None and board is None:
        for pin in pins:
            short_com = pin['SHORT_COM']
            short_com = html.unescape(short_com)

            if len(re.findall(r'\d+s.jpg', pin['THUMB_URL'])) != 0:
                filename = database.get_thumb_dir() + "/" + re.findall(
                    r'\d+s.jpg', pin['THUMB_URL'])[0]
            else:
                filename = None

            thread_dead = False
            archived = False
            post_count = 0

            now = epoch_to_readable(pin['TIME_CREATED'])

            print("GETTIng INFO BOUT {}".format(pin['POSTNO']))

            pins_list.append({
                'no': pin['POSTNO'],
                'post_board': pin['BOARD'],
                'thisBoard': pin['BOARD'],
                'com': short_com,
                'postCount': post_count,
                'thumbUrl': filename,
                'threadArchived': archived,
                'threadDead': thread_dead,
                'now': now,
                'has_file': 1,
                'pin': 1,
                'name': '',
                'closed': 0,
                'images': 0,
                'sticky': 0,
                'replies': 0
            })
            #POSTNO,BOARD,SHORT_COM,THUMB_URL,TIME_ADDED,TIME_READ,TIME_CREATED

        pyotherside.send('pinned_all', pins_list)

        pins_list = []

        for pin in pins:
            post_count = get_new_posts_count(pin['BOARD'], pin['POSTNO'],
                                             pin['REPLIES_COUNT'])
            if post_count is None:
                thread_dead = True
                archived = False
            else:
                archived = thread_archived(pin['POSTNO'])

            pins_list.append({
                'no': pin['POSTNO'],
                'postCount': post_count,
                'threadArchived': archived,
                'threadDead': thread_dead
            })

        pyotherside.send('pinned_all_update', pins_list)

    elif post_no and board is None:

        for pin in pins:
            pins_list.append({'postNo': pin['POSTNO'], 'board': pin['BOARD']})

        print(pins_list)
        if sys.platform != 'win32':
            pyotherside.send('pinned_postno', pins_list)

    elif board and post_no is None:
        for pin in pins:
            pins_list.append(pin['POSTNO'])

        if sys.platform != 'win32':
            pyotherside.send('pinned_board', pins_list)
예제 #3
0
def get_pins_db(post_no=None,board=None):
    database = storage.Storage()
    pins = database.get_pins(post_no,board)

    pins_list=[]

    if post_no is None and board is None:

        for pin in pins:
            short_com = pin['SHORT_COM'][2:-1].replace("'","'")
            if len(re.findall(r'\d+s.jpg',pin['THUMB_URL'])) != 0:
                filename = database.get_thumb_dir() + "/" + re.findall(r'\d+s.jpg',pin['THUMB_URL'])[0]
            else:
                filename = None
            thread_dead = False
            archived = False
            post_count = 0

            now = epoch_to_readable(pin['TIME_CREATED'])
            #last_read = epoch_to_readable(pin['TIME_CREATED'])

            print("GETTIng INFO BOUT {}".format(pin['POSTNO']))

            pins_list.append({'no':pin['POSTNO'],'post_board':pin['BOARD'],'thisBoard':pin['BOARD'],'com':short_com,'postCount':post_count,
                              'thumbUrl':filename,'threadArchived':archived,'threadDead':thread_dead,
                              'now':now,'has_file':1,'pin':1,'name':'','closed':0,'images':0,'sticky':0,'replies':0})
            #POSTNO,BOARD,SHORT_COM,THUMB_URL,TIME_ADDED,TIME_READ,TIME_CREATED

        pyotherside.send('pinned_all', pins_list)

        pins_list = []

        for pin in pins:
            post_count = get_new_posts_count(pin['BOARD'],pin['POSTNO'],pin['REPLIES_COUNT'])
            if post_count is None:
                thread_dead = True
                archived = False
            else:
                archived = thread_archived(pin['POSTNO'])

            pins_list.append({'no':pin['POSTNO'],'postCount':post_count,
                              'threadArchived':archived,'threadDead':thread_dead})

        pyotherside.send('pinned_all_update', pins_list)

    elif post_no and board is None:

        for pin in pins:
            pins_list.append({'postNo':pin['POSTNO'],'board':pin['BOARD']})

        print(pins_list)
        if sys.platform != 'win32':
            pyotherside.send('pinned_postno', pins_list)

    elif board and post_no is None:
        #pin_dict = {}
        for pin in pins:
            pins_list.append(pin['POSTNO'])

        #print(pins_list)

        #pins_list = dict (zip(my_dict.values(),my_dict.keys()))
        if sys.platform != 'win32':
            pyotherside.send('pinned_board', pins_list)