async def __get_illusts(self, keyword: str) -> T.Sequence[dict]: """ 获取搜索的画像(从缓存或服务器) """ if not keyword: # 若未指定关键词,则从今日排行榜中选取 illusts = await get_illusts(search_func=papi.illust_ranking, search_page_limit=1) else: # 缓存文件路径 dirpath = os.path.join(os.path.curdir, self.search_cache_dir) filename = re.sub("\.[<>/\\\|:\"*?]", "_", keyword) + ".json" # 转义非法字符 cache_file = os.path.join(dirpath, filename) illusts = await get_illusts_with_cache( cache_file=cache_file, cache_outdated_time=self.search_cache_outdated_time, search_func=papi.search_illust, word=keyword, illust_filter=make_illust_filter( block_tags=self.block_tags, bookmark_lower_bound=self.bookmark_lower_bound, view_lower_bound=self.view_lower_bound), search_item_limit=self.search_item_limit, search_page_limit=self.search_page_limit) return illusts
async def __get_illusts(self, user_id: int) -> T.Sequence[dict]: """ 获取指定画师的画像(从缓存或服务器) :param user_id: 画师的用户id :return: 画像列表 """ # 缓存文件路径 dirname = os.path.join(os.path.curdir, self.search_cache_dir) filename = str(user_id) + ".json" cache_file = os.path.join(dirname, filename) illusts = await get_illusts_with_cache( cache_file=cache_file, cache_outdated_time=self.search_cache_outdated_time, search_func=papi.user_illusts, user_id=user_id, illust_filter=make_illust_filter( block_tags=self.block_tags, bookmark_lower_bound=self.bookmark_lower_bound, view_lower_bound=self.view_lower_bound), search_item_limit=self.search_item_limit, search_page_limit=self.search_page_limit) return illusts
async def __get_bookmarks(self) -> T.Sequence[dict]: """ 获取书签的画像(从缓存或服务器) """ cache_file = os.path.abspath(self.search_cache_filename) # 缓存文件路径 if self.user_id is not None: user_id = self.user_id else: user_id = papi.user_id illusts = await get_illusts_with_cache( cache_file=cache_file, cache_outdated_time=self.search_cache_outdated_time, search_func=papi.user_bookmarks_illust, user_id=user_id, illust_filter=make_illust_filter( block_tags=self.block_tags, bookmark_lower_bound=self.bookmark_lower_bound, view_lower_bound=self.view_lower_bound), search_item_limit=self.search_item_limit, search_page_limit=self.search_page_limit) return illusts