Skip to content

Commit 3de3fb8

Browse files
committed
manual script
1 parent aa532a9 commit 3de3fb8

3 files changed

Lines changed: 106 additions & 3 deletions

File tree

yyetsweb/commands/add_dl.py

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#!/usr/bin/env python3
2+
# coding: utf-8
3+
4+
# YYeTsBot - add_dl.py
5+
6+
7+
import random
8+
import time
9+
from common import Mongo
10+
11+
12+
def prompt_default(text, default):
13+
value = input(f"{text} [{default}]: ").strip()
14+
return value if value else default
15+
16+
17+
def main():
18+
mongo = Mongo()
19+
client = mongo.client["zimuzu"]
20+
col = client["yyets"]
21+
22+
resource_id = int(input("请输入 resource id: ").strip())
23+
24+
doc = col.find_one({"data.info.id": resource_id})
25+
if not doc:
26+
raise RuntimeError(f"resource id {resource_id} not found")
27+
28+
season_num = prompt_default("请输入季", "0")
29+
video_format = prompt_default("请输入视频格式", "1080P").upper()
30+
episode = prompt_default("请输入集数", "0")
31+
32+
size = input("请输入大小,比如 3GB / 7MB: ").strip()
33+
name = input("请输入名字: ").strip()
34+
35+
address = ""
36+
while not address:
37+
address = input("请输入网盘地址 address: ").strip()
38+
39+
passwd = input("请输入网盘密码 passwd,默认空: ").strip()
40+
41+
new_item = {
42+
"itemid": str(random.randint(10_0000, 20_0000)),
43+
"episode": str(episode),
44+
"name": name,
45+
"size": size,
46+
"yyets_trans": 0,
47+
"dateline": str(int(time.time())),
48+
"files": [
49+
{
50+
"way": "9",
51+
"way_cn": "网盘",
52+
"address": address,
53+
"passwd": passwd,
54+
}
55+
],
56+
}
57+
58+
target_season = None
59+
60+
for season in doc["data"]["list"]:
61+
if str(season.get("season_num")) == str(season_num):
62+
target_season = season
63+
break
64+
65+
# 不存在这个季就自动创建
66+
if target_season is None:
67+
target_season = {
68+
"season_num": str(season_num),
69+
"season_cn": "正片" if str(season_num) == "0" else f"第{season_num}季",
70+
"items": {},
71+
"formats": [],
72+
}
73+
doc["data"]["list"].append(target_season)
74+
75+
items = target_season.setdefault("items", {})
76+
formats = target_season.setdefault("formats", [])
77+
78+
# 不存在这个格式就创建
79+
if video_format not in items:
80+
items[video_format] = []
81+
82+
# append 新数据
83+
items[video_format].append(new_item)
84+
85+
# formats 顺便补一下
86+
if video_format not in formats:
87+
formats.append(video_format)
88+
89+
# 写回 mongodb
90+
result = col.replace_one(
91+
{"_id": doc["_id"]},
92+
doc,
93+
)
94+
95+
print("\n写入成功")
96+
print("matched:", result.matched_count)
97+
print("modified:", result.modified_count)
98+
print("新增 itemid:", new_item["itemid"])
99+
100+
101+
if __name__ == "__main__":
102+
while True:
103+
main()

yyetsweb/commands/douban_fix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
search_html = ""
3535
cname = yyets_data["data"]["info"]["cnname"]
3636

37-
final_data = douban.get_craw_data(cname, douban_id, resource_id, search_html, session)
37+
final_data = douban.get_craw_data(cname, douban_id, resource_id, search_html)
3838
douban.db["douban"].find_one_and_replace({"resourceId": resource_id}, final_data)
3939
print("fix complete")
4040
sys.exit(0)

yyetsweb/server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,11 @@ def run_server(port, host):
163163
timez = ZoneInfo("Asia/Shanghai")
164164
scheduler = BackgroundScheduler(timezone=timez)
165165
scheduler.add_job(Other().reset_top, trigger=CronTrigger.from_crontab("0 0 * * 1"))
166-
scheduler.add_job(sync_douban, trigger=CronTrigger.from_crontab("1 1 1 * *"))
166+
scheduler.add_job(sync_douban, trigger=CronTrigger.from_crontab("1 1 * * *"))
167167
# scheduler.add_job(entry_dump, trigger=CronTrigger.from_crontab("2 2 1 * *"))
168168
scheduler.add_job(Other().import_ban_user, "interval", seconds=300)
169169
scheduler.add_job(Other().fill_user_hash, "interval", seconds=60)
170-
scheduler.add_job(Cloudflare().clear_fw, trigger=CronTrigger.from_crontab("0 0 */3 * *"))
170+
# scheduler.add_job(Cloudflare().clear_fw, trigger=CronTrigger.from_crontab("0 0 */3 * *"))
171171
scheduler.add_job(YYSub().run, trigger=CronTrigger.from_crontab("0 1 * * *"))
172172
scheduler.add_job(comment_check, trigger=CronTrigger.from_crontab("0 1 * * *"))
173173
scheduler.start()

0 commit comments

Comments
 (0)