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:
+28
-13
@@ -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)
|
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 = []
|
results = []
|
||||||
|
|
||||||
ez_aliases = aliases.get("ez", [])
|
ez_aliases = aliases.get("ez", [])
|
||||||
if ez_aliases:
|
if ez_aliases:
|
||||||
ez_aliases_normalized = [normalize_title(a) for a in 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:
|
for torrent in torrents:
|
||||||
torrent_title = torrent["title"]
|
torrent_title = torrent["title"]
|
||||||
torrent_title_lower = torrent_title.lower()
|
torrent_title_lower = torrent_title.lower()
|
||||||
@@ -53,18 +68,18 @@ def filter_worker(torrents, title, year, year_end, aliases, remove_adult_content
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
if year and parsed.year:
|
if year and parsed.year:
|
||||||
if year_end is not None:
|
if not (min_year <= parsed.year <= max_year):
|
||||||
if not (year <= parsed.year <= year_end):
|
if year_end:
|
||||||
_log_exclusion(
|
expected = f"{year}-{year_end}"
|
||||||
f"📅 Rejected (Year Mismatch) | {torrent_title} | Year: {parsed.year} | Expected: {year}-{year_end}"
|
elif media_type == "series":
|
||||||
)
|
expected = f">{year}"
|
||||||
continue
|
else:
|
||||||
else:
|
expected = f"~{year}"
|
||||||
if year < (parsed.year - 1) or year > (parsed.year + 1):
|
|
||||||
_log_exclusion(
|
_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
|
continue
|
||||||
|
|
||||||
torrent["parsed"] = parsed
|
torrent["parsed"] = parsed
|
||||||
results.append(torrent)
|
results.append(torrent)
|
||||||
|
|||||||
@@ -225,6 +225,7 @@ class TorrentManager:
|
|||||||
self.title,
|
self.title,
|
||||||
self.year,
|
self.year,
|
||||||
self.year_end,
|
self.year_end,
|
||||||
|
self.media_type,
|
||||||
self.aliases,
|
self.aliases,
|
||||||
self.remove_adult_content,
|
self.remove_adult_content,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user