From bcc6df9d4da387fff2143cab429a170acfcbe2b5 Mon Sep 17 00:00:00 2001 From: HibiKier <45528451+HibiKier@users.noreply.github.com> Date: Thu, 20 May 2021 21:04:57 +0800 Subject: [PATCH] Update data_source.py --- plugins/send_setu/data_source.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/send_setu/data_source.py b/plugins/send_setu/data_source.py index 6db1281c..7e69a067 100644 --- a/plugins/send_setu/data_source.py +++ b/plugins/send_setu/data_source.py @@ -63,9 +63,8 @@ async def get_setu_urls(keyword: str, num: int = 1, r18: int = 0): text_list.append(f'title:{title}\nauthor:{author}\nPID:{pid}') img_url = str(img_url).replace('img-master', 'img-original').replace('_master1200', '') txt_data += img_url + ',' - if DOWNLOAD_SETU: - with open(TXT_PATH + file_name, 'w') as f: - f.write(txt_data) + with open(TXT_PATH + file_name, 'w') as f: + f.write(txt_data) return urls, text_list, 200 else: return "没找到符合条件的色图...", '', 401 @@ -100,6 +99,8 @@ async def search_online_setu(url: str): def get_setu(index: str): length = len(os.listdir(IMAGE_PATH + path)) + if length == 0: + return None, None if not index: index = random.randint(0, length - 1) if is_number(index):