Skip to content

Commit

Permalink
fix: torrent name parsing fail in multi_version_filter
Browse files Browse the repository at this point in the history
  • Loading branch information
KotaHv committed Jul 30, 2024
1 parent 9b0063b commit 7e1666c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion backend/src/module/utils/multi_version_filter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from collections import defaultdict

from loguru import logger

from module.models.torrent import Torrent, TorrentInfo
from module.parser.analyser import torrent_name_parser

Expand All @@ -11,7 +13,14 @@ def filter_multi_version_torrents(torrents: list[Torrent]):

for torrent in torrents:
info = torrent_name_parser(torrent.name)
key = f"{info.title}+{info.episode}"
if info is None:
logger.warning(
f"Failed to parse torrent name for torrent '{torrent}'. "
f"Fallback to using torrent.name: '{torrent.name}'."
)
key = torrent.name
else:
key = f"{info.title}+{info.episode}"
grouped_torrents[key].append((torrent, info))

for torrents_group in grouped_torrents.values():
Expand Down

0 comments on commit 7e1666c

Please sign in to comment.