Skip to content

Commit

Permalink
fix: 解析种子后不下载
Browse files Browse the repository at this point in the history
  • Loading branch information
linyuan0213 committed Jul 13, 2024
1 parent 0754cb5 commit 379c8f2
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions app/downloader/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,9 +864,10 @@ def __get_season_episodes(tmdbid, season):
# 只有一季的可能是命名错误,需要打开种子鉴别,只有实际集数大于等于总集数才下载
torrent_episodes, torrent_path = self.get_torrent_episodes(
url=item.enclosure,
page_url=item.page_url)
if not torrent_episodes \
or len(torrent_episodes) >= __get_season_episodes(need_tmdbid, item_season[0]):
page_url=item.page_url,
tmdb_id=item.tmdb_id)
if torrent_episodes \
and len(torrent_episodes) <= __get_season_episodes(need_tmdbid, item_season[0]):
_, download_id = __download(download_item=item, torrent_file=torrent_path)
else:
log.info(
Expand Down Expand Up @@ -951,7 +952,8 @@ def __get_season_episodes(tmdbid, season):
# 检查种子看是否有需要的集
torrent_episodes, torrent_path = self.get_torrent_episodes(
url=item.enclosure,
page_url=item.page_url)
page_url=item.page_url,
tmdb_id=item.tmdb_id)
selected_episodes = set(torrent_episodes).intersection(set(need_episodes))
if not selected_episodes:
log.info("【Downloader】%s 没有需要的集,跳过..." % item.org_string)
Expand Down Expand Up @@ -1295,7 +1297,7 @@ def __get_client_type(type_name):
if dict_type.name == type_name or dict_type.value == type_name:
return dict_type

def get_torrent_episodes(self, url, page_url=None):
def get_torrent_episodes(self, url, page_url=None, tmdb_id=None):
"""
解析种子文件,获取集数
:return: 集数列表、种子路径
Expand All @@ -1319,7 +1321,7 @@ def get_torrent_episodes(self, url, page_url=None):
for file in files:
if os.path.splitext(file)[-1] not in RMT_MEDIAEXT:
continue
meta = MetaInfo(file)
meta = MetaInfo(file, tmdb_id=tmdb_id)
if not meta.begin_episode:
continue
episodes = list(set(episodes).union(set(meta.get_episode_list())))
Expand Down

0 comments on commit 379c8f2

Please sign in to comment.