forked from Pfuenzle/AnisearchKomga
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathupdateReadProgress.py
38 lines (30 loc) · 1.13 KB
/
updateReadProgress.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from config.config import *
from tools.env import *
from tools.log import logger
def update_read_progress():
'''
更新阅读进度
'''
env = InitEnv()
bgm = env.bgm
all_series = env.all_series
for series in all_series:
series_name = series['name']
books_read_count = series['booksReadCount']
try:
for link in series['metadata']['links']:
if link['label'].lower() == "bangumi":
subject_id = link['url'].split("/")[-1]
break
except ValueError as e:
logger.exception(e)
logger.error("Update read progress for "+series_name+" failed:")
continue
# TODO 添加是否同步判断逻辑,比如:是否`在读`
if bgm.update_reading_progress(subject_id, books_read_count):
logger.info("Successfully update: "+series_name +
" series read progress: "+str(books_read_count))
else:
logger.error("Failed to update: "+series_name +
" series read progress: "+str(books_read_count))
update_read_progress()