mirror of
https://github.com/Cp0204/quark-auto-save.git
synced 2026-01-14 16:30:43 +08:00
Compare commits
5 Commits
db087a6f28
...
e274f8d2d0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e274f8d2d0 | ||
|
|
6f9b009194 | ||
|
|
de37c26423 | ||
|
|
e975b2822b | ||
|
|
78581b15a7 |
@ -1,3 +1,4 @@
|
||||
from datetime import datetime, timedelta
|
||||
import re
|
||||
import requests
|
||||
|
||||
@ -124,6 +125,11 @@ class CloudSaver:
|
||||
content = content.replace('<mark class="highlight">', "")
|
||||
content = content.replace("</mark>", "")
|
||||
content = content.strip()
|
||||
# 统一发布时间格式
|
||||
pubdate = item.get("pubDate", "")
|
||||
if pubdate:
|
||||
utc_tm = datetime.fromisoformat(pubdate)
|
||||
pubdate = (utc_tm + timedelta(hours=8)).strftime("%Y-%m-%d %H:%M:%S")
|
||||
# 链接去重
|
||||
if link.get("link") not in link_array:
|
||||
link_array.append(link.get("link"))
|
||||
@ -132,6 +138,7 @@ class CloudSaver:
|
||||
"shareurl": link.get("link"),
|
||||
"taskname": title,
|
||||
"content": content,
|
||||
"datetime": pubdate,
|
||||
"tags": item.get("tags", []),
|
||||
"channel": item.get("channel", ""),
|
||||
"channel_id": item.get("channelId", ""),
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import re
|
||||
import datetime
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import requests
|
||||
|
||||
@ -60,7 +60,8 @@ class PanSou:
|
||||
note = channel.get("note", "")
|
||||
tm = channel.get("datetime", "")
|
||||
if tm:
|
||||
tm = datetime.datetime.strptime(tm, "%Y-%m-%dT%H:%M:%SZ").strftime("%Y-%m-%d %H:%M:%S")
|
||||
utc_tm = datetime.strptime(tm, "%Y-%m-%dT%H:%M:%SZ")
|
||||
tm = (utc_tm + timedelta(hours=8)).strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
match = re.search(pattern, note)
|
||||
if match:
|
||||
|
||||
@ -955,6 +955,7 @@
|
||||
}
|
||||
},
|
||||
searchSuggestions(index, taskname, deep = 1) {
|
||||
taskname = taskname.replace(/\((19|20)\d{2}\)/g, '').trim();
|
||||
if (taskname.length < 2) {
|
||||
console.log(`任务名[${taskname}]过短${taskname.length} 不进行搜索`);
|
||||
return;
|
||||
|
||||
@ -164,7 +164,7 @@ class MagicRename:
|
||||
"{YEAR}": [r"(?<!\d)(18|19|20)\d{2}(?!\d)"],
|
||||
"{S}": [r"(?<=[Ss])\d{1,2}(?=[EeXx])", r"(?<=[Ss])\d{1,2}"],
|
||||
"{SXX}": [r"[Ss]\d{1,2}(?=[EeXx])", r"[Ss]\d{1,2}"],
|
||||
"{E}": [
|
||||
"{E+}": [
|
||||
r"(?<=[Ss]\d\d[Ee])\d{1,3}",
|
||||
r"(?<=[Ee])\d{1,3}",
|
||||
r"(?<=[Ee][Pp])\d{1,3}",
|
||||
@ -224,7 +224,7 @@ class MagicRename:
|
||||
return file_name
|
||||
# 预处理替换变量
|
||||
for key, p_list in self.magic_variable.items():
|
||||
if key in replace:
|
||||
if match_key := re.search(key, replace):
|
||||
# 正则类替换变量
|
||||
if p_list and isinstance(p_list, list):
|
||||
for p in p_list:
|
||||
@ -240,7 +240,10 @@ class MagicRename:
|
||||
value = (
|
||||
str(datetime.now().year)[: (8 - len(value))] + value
|
||||
)
|
||||
replace = replace.replace(key, value)
|
||||
# 集数零填充处理
|
||||
elif key == "{E+}":
|
||||
value = value.lstrip("0").zfill(match_key.group().count("E"))
|
||||
replace = re.sub(key, value, replace)
|
||||
break
|
||||
# 非正则类替换变量
|
||||
if key == "{TASKNAME}":
|
||||
@ -251,7 +254,7 @@ class MagicRename:
|
||||
continue
|
||||
else:
|
||||
# 清理未匹配的 magic_variable key
|
||||
replace = replace.replace(key, "")
|
||||
replace = re.sub(key, "", replace)
|
||||
if pattern and replace:
|
||||
file_name = re.sub(pattern, replace, file_name)
|
||||
else:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user