Skip to content

Commit

Permalink
🐛 搜索时去除剧季信息
Browse files Browse the repository at this point in the history
  • Loading branch information
KimigaiiWuyi authored Jun 27, 2024
1 parent 6be4e34 commit 2a111d7
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Bangumi_Auto_Rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ def chinese_to_arabic(cn: str) -> int:
return val


def remove_season(s: str):
s = re.sub(r'(S\d+)', '', s)
return s.strip()


def remove_tag(s: str):
for pattern in bracket_patterns:
s = re.sub(pattern, '', s)
Expand Down Expand Up @@ -210,7 +215,10 @@ def get_tv_info(query: str):
for i in range(3):
try:
search = tmdb.Search()
search.tv(query=remove_tag(query).strip('!'), language='zh-CN')
search.tv(
query=remove_season(remove_tag(query).strip('!')),
language='zh-CN',
)
target_list = search.__dict__['results']
if target_list:
target = target_list[0]
Expand All @@ -229,7 +237,10 @@ def get_moive_info(query: str):
for i in range(3):
try:
search = tmdb.Search()
search.movie(query=remove_tag(query).strip('!'), language='zh-CN')
search.movie(
query=remove_season(remove_tag(query).strip('!')),
language='zh-CN',
)
target_list = search.__dict__['results']
if target_list:
target = target_list[0]
Expand Down

0 comments on commit 2a111d7

Please sign in to comment.