mirror of
https://github.com/g0ldyy/comet.git
synced 2026-01-12 01:16:12 +01:00
refactor: enhance filtering logic with media type and year range handling
- Updated the filter_worker function to include media_type as a parameter. - Introduced min_year and max_year calculations to improve year filtering logic. - Adjusted year mismatch logging to reflect new expected formats based on media type.
This commit is contained in:
@@ -17,13 +17,28 @@ def quick_alias_match(text_normalized: str, ez_aliases_normalized: list[str]):
|
||||
return any(alias in text_normalized for alias in ez_aliases_normalized)
|
||||
|
||||
|
||||
def filter_worker(torrents, title, year, year_end, aliases, remove_adult_content):
|
||||
def filter_worker(
|
||||
torrents, title, year, year_end, media_type, aliases, remove_adult_content
|
||||
):
|
||||
results = []
|
||||
|
||||
ez_aliases = aliases.get("ez", [])
|
||||
if ez_aliases:
|
||||
ez_aliases_normalized = [normalize_title(a) for a in ez_aliases]
|
||||
|
||||
min_year = 0
|
||||
max_year = float("inf")
|
||||
|
||||
if year:
|
||||
if year_end:
|
||||
min_year = year
|
||||
max_year = year_end
|
||||
elif media_type == "series":
|
||||
min_year = year - 1
|
||||
else:
|
||||
min_year = year - 1
|
||||
max_year = year + 1
|
||||
|
||||
for torrent in torrents:
|
||||
torrent_title = torrent["title"]
|
||||
torrent_title_lower = torrent_title.lower()
|
||||
@@ -53,16 +68,16 @@ def filter_worker(torrents, title, year, year_end, aliases, remove_adult_content
|
||||
continue
|
||||
|
||||
if year and parsed.year:
|
||||
if year_end is not None:
|
||||
if not (year <= parsed.year <= year_end):
|
||||
_log_exclusion(
|
||||
f"📅 Rejected (Year Mismatch) | {torrent_title} | Year: {parsed.year} | Expected: {year}-{year_end}"
|
||||
)
|
||||
continue
|
||||
if not (min_year <= parsed.year <= max_year):
|
||||
if year_end:
|
||||
expected = f"{year}-{year_end}"
|
||||
elif media_type == "series":
|
||||
expected = f">{year}"
|
||||
else:
|
||||
if year < (parsed.year - 1) or year > (parsed.year + 1):
|
||||
expected = f"~{year}"
|
||||
|
||||
_log_exclusion(
|
||||
f"📅 Rejected (Year Mismatch) | {torrent_title} | Year: {parsed.year} | Expected: ~{year}"
|
||||
f"📅 Rejected (Year Mismatch) | {torrent_title} | Year: {parsed.year} | Expected: {expected}"
|
||||
)
|
||||
continue
|
||||
|
||||
|
||||
@@ -225,6 +225,7 @@ class TorrentManager:
|
||||
self.title,
|
||||
self.year,
|
||||
self.year_end,
|
||||
self.media_type,
|
||||
self.aliases,
|
||||
self.remove_adult_content,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user