This commit is contained in:
jxxghp 2023-06-21 08:41:13 +08:00
parent 243aa28871
commit a538dccc5a
3 changed files with 34 additions and 2 deletions

View File

@ -94,7 +94,7 @@ class MessageChain(ChainBase):
if no_exists:
# 发送消息
messages = [
f"{sea} 季缺失 {len(no_exist.episodes) or no_exist.total_episodes}"
f"{sea} 季缺失 {StringUtils.str_series(no_exist.episodes) if no_exist.episodes else no_exist.total_episodes}"
for sea, no_exist in no_exists.get(mediainfo.tmdb_id).items()]
self.post_message(title=f"{mediainfo.title_year}\n" + "\n".join(messages))
# 搜索种子,过滤掉不需要的剧集,以便选择

View File

@ -113,7 +113,7 @@ class FilterModule(_ModuleBase):
torrent_episodes = meta.episode_list
if not set(torrent_seasons).issubset(set(seasons)):
# 种子季不在过滤季中
logger.info(f"种子 {torrent.title} 不是需要的季")
logger.info(f"种子 {torrent.site_name} - {torrent.title} 不是需要的季")
return False
if not torrent_episodes:
# 整季按匹配处理

View File

@ -552,3 +552,35 @@ class StringUtils:
# 端口号不是整数,返回 None 表示无效
return None, None
return domain, port
@staticmethod
def str_series(array: List[int]) -> str:
"""
将季集列表转化为字符串简写
"""
# 确保数组按照升序排列
array.sort()
result = []
start = array[0]
end = array[0]
for i in range(1, len(array)):
if array[i] == end + 1:
end = array[i]
else:
if start == end:
result.append(str(start))
else:
result.append(f"{start}-{end}")
start = array[i]
end = array[i]
# 处理最后一个序列
if start == end:
result.append(str(start))
else:
result.append(f"{start}-{end}")
return ",".join(result)