Skip to content

Commit

Permalink
fix 搜索匹配Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jxxghp committed Jul 12, 2023
1 parent 0900ab4 commit 41bc1a9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app/chain/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,17 @@ def process(self, mediainfo: MediaInfo,
logger.warn(f'{torrent.site_name} - {torrent.title} 年份不匹配')
continue
# 比对标题
if torrent_meta.name in [mediainfo.title, mediainfo.original_title]:
meta_name = StringUtils.clear_upper(torrent_meta.name)
if meta_name in [
StringUtils.clear_upper(mediainfo.title),
StringUtils.clear_upper(mediainfo.original_title)
]:
logger.info(f'{mediainfo.title} 匹配到资源:{torrent.site_name} - {torrent.title}')
_match_torrents.append(torrent)
continue
# 比对别名和译名
for name in mediainfo.names:
if StringUtils.clear(name).strip().upper() == \
StringUtils.clear(torrent_meta.name).strip().upper():
if StringUtils.clear_upper(name) == meta_name:
logger.info(f'{mediainfo.title} 匹配到资源:{torrent.site_name} - {torrent.title}')
_match_torrents.append(torrent)
break
Expand Down
9 changes: 9 additions & 0 deletions app/utils/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,15 @@ def clear(text: Union[list, str], replace_word: str = "",
else:
return [StringUtils.clear(x) for x in text]

@staticmethod
def clear_upper(text: str) -> str:
"""
去除特殊字符,同时大写
"""
if not text:
return ""
return StringUtils.clear(text).upper().strip()

@staticmethod
def str_filesize(size: Union[str, float, int], pre: int = 2) -> str:
"""
Expand Down

0 comments on commit 41bc1a9

Please sign in to comment.