diff --git a/app/run.py b/app/run.py index 2c4a3d3..397c0eb 100644 --- a/app/run.py +++ b/app/run.py @@ -235,15 +235,18 @@ 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", "true").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 ( cs_data.get("server") @@ -264,13 +267,13 @@ def get_task_suggestions(): search_results = cs.clean_search_results(search.get("data")) return search_results return [] - + def ps_search(): - if (ps_data.get("server")): + if ps_data.get("server"): ps = PanSou(ps_data.get("server")) - return ps.search(query) + return ps.search(query, deep == "1") return [] - + try: search_results = [] with ThreadPoolExecutor(max_workers=3) as executor: @@ -281,17 +284,17 @@ def get_task_suggestions(): for future in as_completed(features): result = future.result() search_results.extend(result) - + # 按时间排序并去重 results = [] link_array = [] - search_results.sort(key=lambda x: x.get("datetime", ""), reverse=True) + search_results.sort(key=lambda x: x.get("datetime", ""), reverse=True) for item in search_results: url = item.get("shareurl", "") if url != "" and url not in link_array: link_array.append(url) results.append(item) - + return jsonify({"success": True, "data": results}) except Exception as e: return jsonify({"success": True, "message": f"error: {str(e)}"}) 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 @@ +
+
+

网络公开

+
+
+
+ +
+ +
+
+

CloudSaver

@@ -325,7 +337,7 @@
- +
@@ -350,7 +362,7 @@
- +
@@ -371,7 +383,7 @@
- +
@@ -468,6 +480,22 @@