Skip to content

Commit 6bd86a7

Browse files
committed
fix:区分series和movie id
1 parent fc96cfe commit 6bd86a7

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

app/modules/thetvdb/__init__.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,13 @@ def _handle_tvdb_call(self, func, *args, **kwargs):
3030
return func(*args, **kwargs)
3131
except ValueError as e:
3232
# 检查错误信息中是否包含 token 失效相关描述
33-
if "failed to get" in str(e) or "Unauthorized" in str(e) or "NOT_MODIFIED" in str(e):
33+
if "Unauthorized" in str(e):
3434
logger.warning("TVDB Token 可能已失效,正在尝试重新登录...")
3535
self._initialize_tvdb_session()
3636
return func(*args, **kwargs)
37+
elif "NotFoundException" in str(e):
38+
logger.warning("TVDB 剧集不存在")
39+
return None
3740
else:
3841
raise
3942
except Exception as e:
@@ -96,13 +99,14 @@ def tvdb_info(self, tvdbid: int) -> Optional[dict]:
9699

97100
def search_tvdb(self, title: str) -> list:
98101
"""
99-
用标题搜索TVDB
102+
用标题搜索TVDB剧集
100103
:param title: 标题
101104
:return: TVDB信息
102105
"""
103106
try:
104-
logger.info(f"开始用标题搜索TVDB: {title} ...")
105-
return self._handle_tvdb_call(self.tvdb.search, title)
107+
logger.info(f"开始用标题搜索TVDB剧集: {title} ...")
108+
res = self._handle_tvdb_call(self.tvdb.search, title)
109+
return [item for item in res if item.get("type") == "series"]
106110
except Exception as err:
107-
logger.error(f"用标题搜索TVDB失败: {str(err)}")
111+
logger.error(f"用标题搜索TVDB剧集失败: {str(err)}")
108112
return []

0 commit comments

Comments
 (0)