diff --git a/app/sdk/cloudsaver.py b/app/sdk/cloudsaver.py
index 2929c02..2eee3aa 100644
--- a/app/sdk/cloudsaver.py
+++ b/app/sdk/cloudsaver.py
@@ -1,6 +1,6 @@
-from datetime import datetime, timedelta
import re
import requests
+from sdk.common import iso_to_cst
class CloudSaver:
@@ -128,8 +128,7 @@ class CloudSaver:
# 统一发布时间格式
pubdate = item.get("pubDate", "")
if pubdate:
- utc_tm = datetime.fromisoformat(pubdate)
- pubdate = (utc_tm + timedelta(hours=8)).strftime("%Y-%m-%d %H:%M:%S")
+ pubdate = iso_to_cst(pubdate)
# 链接去重
if link.get("link") not in link_array:
link_array.append(link.get("link"))
@@ -140,8 +139,7 @@ class CloudSaver:
"content": content,
"datetime": pubdate,
"tags": item.get("tags", []),
- "channel": item.get("channel", ""),
- "channel_id": item.get("channelId", ""),
+ "channel": item.get("channelId", ""),
"source": "CloudSaver"
}
)
diff --git a/app/sdk/common.py b/app/sdk/common.py
new file mode 100644
index 0000000..068890c
--- /dev/null
+++ b/app/sdk/common.py
@@ -0,0 +1,15 @@
+from datetime import datetime, timezone, timedelta
+
+
+def iso_to_cst(iso_time_str: str) -> str:
+ """将 ISO 格式的时间字符串转换为 CST(China Standard Time) 时间并格式化为 %Y-%m-%d %H:%M:%S 格式
+
+ Args:
+ iso_time_str (str): ISO 格式时间字符串
+
+ Returns:
+ str: CST(China Standard Time) 时间字符串
+ """
+ dt = datetime.fromisoformat(iso_time_str)
+ dt_cst = dt.astimezone(timezone(timedelta(hours=8)))
+ 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 5b0447f..5c30893 100644
--- a/app/sdk/pansou.py
+++ b/app/sdk/pansou.py
@@ -1,8 +1,9 @@
import re
-from datetime import datetime, timedelta
import requests
+from sdk.common import iso_to_cst
+
class PanSou:
"""
@@ -55,13 +56,12 @@ class PanSou:
)
format_results = []
link_array = []
- for channel in search_results:
- url = channel.get("url", "")
- note = channel.get("note", "")
- tm = channel.get("datetime", "")
+ for item in search_results:
+ url = item.get("url", "")
+ note = item.get("note", "")
+ tm = item.get("datetime", "")
if tm:
- utc_tm = datetime.strptime(tm, "%Y-%m-%dT%H:%M:%SZ")
- tm = (utc_tm + timedelta(hours=8)).strftime("%Y-%m-%d %H:%M:%S")
+ tm = iso_to_cst(tm)
match = re.search(pattern, note)
if match:
@@ -74,10 +74,11 @@ class PanSou:
if url != "" and url not in link_array:
link_array.append(url)
format_results.append({
+ "shareurl": url,
"taskname": title,
"content": content,
- "shareurl": url,
"datetime": tm,
+ "channel": item.get("source", ""),
"source": "PanSou"
})
diff --git a/app/templates/index.html b/app/templates/index.html
index a4db29c..a735fcd 100644
--- a/app/templates/index.html
+++ b/app/templates/index.html
@@ -303,6 +303,7 @@
{{ suggestion.shareurl }}
{{ suggestion.source || "网络公开" }}
+ {{ suggestion.channel }}
{{ suggestion.datetime }}