mirror of
https://github.com/Cp0204/quark-auto-save.git
synced 2026-01-14 08:20:42 +08:00
fix: 修复 net.enable=None 时 lower() 报错
This commit is contained in:
parent
97478c85f2
commit
aab5205507
18
app/run.py
18
app/run.py
@ -238,15 +238,15 @@ def get_task_suggestions():
|
||||
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():
|
||||
if net_data.get("enable").lower() != "false":
|
||||
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")
|
||||
@ -267,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, deep == "1")
|
||||
return []
|
||||
|
||||
|
||||
try:
|
||||
search_results = []
|
||||
with ThreadPoolExecutor(max_workers=3) as executor:
|
||||
@ -284,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)}"})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user