def open(self): data = request.to_api('http://api.4chan.org/boards.json') for board_data in data['boards']: self.__boards[board_data['board']] = { 'title' : board_data.get('title', 'unknown'), 'pages' : board_data.get('pages', -1) }
def update(self, clear=False): if clear: self.__posts = {} posts = request.to_api(self.__translator.thread(self.__thread_id)) posts = posts["posts"] for post in posts: self.__posts.update({post["no"]: post})
def update(self, clear=False): if clear: self.__posts = {} posts = request.to_api(self.__translator.thread(self.__thread_id)) posts = posts['posts'] for post in posts: self.__posts.update({post['no']: post})
def update(self, clear = False): if clear: self.__posts = {} for page in range(self.__translator.max_pages): try: threads = request.to_api(self.__translator.thread(page))['threads'] except request.InvalidRequest: break for thread in threads: for post in thread['posts']: self.__posts.update({post['no'] : post})
def update(self, clear=False): if clear: self.__posts = {} for page in range(self.__translator.max_pages): try: threads = request.to_api( self.__translator.thread(page))['threads'] except request.InvalidRequest: break for thread in threads: for post in thread['posts']: self.__posts.update({post['no']: post})