fix douban plugin

This commit is contained in:
jxxghp 2023-07-26 15:06:22 +08:00
parent 9793c6e0a2
commit b240c0c266

View File

@ -398,32 +398,14 @@ class DoubanSync(_PluginBase):
exist_flag, no_exists = self.downloadchain.get_no_exists_info(meta=meta, mediainfo=mediainfo) exist_flag, no_exists = self.downloadchain.get_no_exists_info(meta=meta, mediainfo=mediainfo)
if exist_flag: if exist_flag:
logger.info(f'{mediainfo.title_year} 媒体库中已存在') logger.info(f'{mediainfo.title_year} 媒体库中已存在')
continue action = "exist"
logger.info(f'{mediainfo.title_year} 媒体库中不存在,开始搜索 ...')
# 搜索
contexts = self.searchchain.process(mediainfo=mediainfo,
no_exists=no_exists)
if not contexts:
logger.warn(f'{mediainfo.title_year} 未搜索到资源')
# 添加订阅
self.subscribechain.add(title=mediainfo.title,
year=mediainfo.year,
mtype=mediainfo.type,
tmdbid=mediainfo.tmdb_id,
season=meta.begin_season,
exist_ok=True,
username="豆瓣想看")
action = "subscribe"
else: else:
# 自动下载 logger.info(f'{mediainfo.title_year} 媒体库中不存在,开始搜索 ...')
downloads, lefts = self.downloadchain.batch_download(contexts=contexts, no_exists=no_exists) # 搜索
if downloads and not lefts: contexts = self.searchchain.process(mediainfo=mediainfo,
# 全部下载完成 no_exists=no_exists)
logger.info(f'{mediainfo.title_year} 下载完成') if not contexts:
action = "download" logger.warn(f'{mediainfo.title_year} 未搜索到资源')
else:
# 未完成下载
logger.info(f'{mediainfo.title_year} 未下载未完整,添加订阅 ...')
# 添加订阅 # 添加订阅
self.subscribechain.add(title=mediainfo.title, self.subscribechain.add(title=mediainfo.title,
year=mediainfo.year, year=mediainfo.year,
@ -433,18 +415,38 @@ class DoubanSync(_PluginBase):
exist_ok=True, exist_ok=True,
username="豆瓣想看") username="豆瓣想看")
action = "subscribe" action = "subscribe"
else:
# 自动下载
downloads, lefts = self.downloadchain.batch_download(contexts=contexts, no_exists=no_exists)
if downloads and not lefts:
# 全部下载完成
logger.info(f'{mediainfo.title_year} 下载完成')
action = "download"
else:
# 未完成下载
logger.info(f'{mediainfo.title_year} 未下载未完整,添加订阅 ...')
# 添加订阅
self.subscribechain.add(title=mediainfo.title,
year=mediainfo.year,
mtype=mediainfo.type,
tmdbid=mediainfo.tmdb_id,
season=meta.begin_season,
exist_ok=True,
username="豆瓣想看")
action = "subscribe"
# 存储历史记录 # 存储历史记录
history.append({ if douban_id not in [h.get("doubanid") for h in history]:
"action": action, history.append({
"title": doubaninfo.get("title") or mediainfo.title, "action": action,
"type": mediainfo.type.value, "title": doubaninfo.get("title") or mediainfo.title,
"year": mediainfo.year, "type": mediainfo.type.value,
"poster": mediainfo.poster_path, "year": mediainfo.year,
"overview": mediainfo.overview, "poster": mediainfo.poster_path,
"tmdbid": mediainfo.tmdb_id, "overview": mediainfo.overview,
"doubanid": douban_id, "tmdbid": mediainfo.tmdb_id,
"time": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") "doubanid": douban_id,
}) "time": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
})
except Exception as err: except Exception as err:
logger.error(f'同步用户 {user_id} 豆瓣想看数据出错:{err}') logger.error(f'同步用户 {user_id} 豆瓣想看数据出错:{err}')
logger.info(f"用户 {user_id} 豆瓣想看同步完成") logger.info(f"用户 {user_id} 豆瓣想看同步完成")