From d24c0819738768907b43c0465b6b6d51d6f63000 Mon Sep 17 00:00:00 2001 From: sean <819165594@qq.com> Date: Sat, 15 Oct 2022 20:00:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=89=B2=E5=9B=BE=E6=8F=92?= =?UTF-8?q?=E4=BB=B6p=E7=AB=99=E5=8F=8D=E5=90=91=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E5=A4=B1=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/send_setu_/send_setu/data_source.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/send_setu_/send_setu/data_source.py b/plugins/send_setu_/send_setu/data_source.py index bb833810b..66f3c0461 100755 --- a/plugins/send_setu_/send_setu/data_source.py +++ b/plugins/send_setu_/send_setu/data_source.py @@ -12,6 +12,7 @@ import asyncio import os import random +import re try: import ujson as json @@ -22,6 +23,7 @@ url = "https://api.lolicon.app/setu/v2" path = "_setu" r18_path = "_r18" +host_pattern = re.compile(r"https?://([^/]+)") # 获取url @@ -89,7 +91,9 @@ async def search_online_setu( """ ws_url = Config.get_config("pixiv", "PIXIV_NGINX_URL") if ws_url: - url_ = url_.replace("i.pximg.net", ws_url).replace("i.pixiv.cat", ws_url) + host_match = re.match(host_pattern, url_) + host = host_match.group(1) + url_ = url_.replace(host, ws_url) index = random.randint(1, 100000) if id_ is None else id_ path_ = IMAGE_PATH / path_ if path_ else TEMP_PATH file_name = f"{index}_temp_setu.jpg" if path_ == TEMP_PATH else f"{index}.jpg"