diff --git a/app/run.py b/app/run.py index 2c4a3d3..2518a21 100644 --- a/app/run.py +++ b/app/run.py @@ -235,14 +235,17 @@ def get_task_suggestions(): return jsonify({"success": False, "message": "未登录"}) query = request.args.get("q", "").lower() deep = request.args.get("d", "").lower() + net_data = config_data.get("source", {}).get("net", {}) cs_data = config_data.get("source", {}).get("cloudsaver", {}) ps_data = config_data.get("source", {}).get("pansou", {}) def net_search(): - base_url = base64.b64decode("aHR0cHM6Ly9zLjkxNzc4OC54eXo=").decode() - url = f"{base_url}/task_suggestions?q={query}&d={deep}" - response = requests.get(url) - return response.json() + if net_data.get("enable").lower() != "false": + base_url = base64.b64decode("aHR0cHM6Ly9zLjkxNzc4OC54eXo=").decode() + url = f"{base_url}/task_suggestions?q={query}&d={deep}" + response = requests.get(url) + return response.json() + return [] def cs_search(): if ( @@ -268,7 +271,7 @@ def get_task_suggestions(): def ps_search(): if (ps_data.get("server")): ps = PanSou(ps_data.get("server")) - return ps.search(query) + return ps.search(query, deep == "1") return [] try: diff --git a/app/sdk/common.py b/app/sdk/common.py index 068890c..46d0150 100644 --- a/app/sdk/common.py +++ b/app/sdk/common.py @@ -11,5 +11,6 @@ def iso_to_cst(iso_time_str: str) -> str: str: CST(China Standard Time) 时间字符串 """ dt = datetime.fromisoformat(iso_time_str) - dt_cst = dt.astimezone(timezone(timedelta(hours=8))) + tz = timezone(timedelta(hours=8)) + dt_cst = dt if dt.astimezone(tz) > datetime.now(tz) else dt.astimezone(tz) return dt_cst.strftime("%Y-%m-%d %H:%M:%S") if dt_cst.year >= 1970 else "" diff --git a/app/sdk/pansou.py b/app/sdk/pansou.py index 5c30893..12d865d 100644 --- a/app/sdk/pansou.py +++ b/app/sdk/pansou.py @@ -14,7 +14,7 @@ class PanSou: self.server = server self.session = requests.Session() - def search(self, keyword: str) -> list: + def search(self, keyword: str, refresh: bool = False) -> list: """搜索资源 Args: @@ -25,7 +25,7 @@ class PanSou: """ try: url = f"{self.server.rstrip('/')}/api/search" - params = {"kw": keyword, "cloud_types": ["quark"], "res": "merge", "refresh": True} + params = {"kw": keyword, "cloud_types": ["quark"], "res": "merge", "refresh": refresh} response = self.session.get(url, params=params) result = response.json() if result.get("code") == 0: diff --git a/app/templates/index.html b/app/templates/index.html index a735fcd..9a5b7ee 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -196,6 +196,18 @@ +