mirror of
https://github.com/g0ldyy/comet.git
synced 2026-01-12 01:16:12 +01:00
Merge pull request #450 from g0ldyy/feat/rtn-filter-logs
feat: add `RTN_FILTER_DEBUG` setting to enable verbose logging for torrent filtering rejections
This commit is contained in:
@@ -244,6 +244,7 @@ TORRENT_DISABLED_STREAM_URL=https://comet.looks.legal # Optional URL included in
|
||||
# Content Filtering #
|
||||
# ============================== #
|
||||
REMOVE_ADULT_CONTENT=False
|
||||
RTN_FILTER_DEBUG=False # Set to True to log why torrents are excluded by RTN (debug only, verbose!)
|
||||
DIGITAL_RELEASE_FILTER=False # Filter unreleased content
|
||||
TMDB_READ_ACCESS_TOKEN= # Optional: Provide your own TMDB Read Access Token to avoid using the shared default key
|
||||
|
||||
|
||||
@@ -403,6 +403,7 @@ def log_startup_info(settings):
|
||||
)
|
||||
|
||||
logger.log("COMET", f"Remove Adult Content: {bool(settings.REMOVE_ADULT_CONTENT)}")
|
||||
logger.log("COMET", f"RTN Filter Debug: {bool(settings.RTN_FILTER_DEBUG)}")
|
||||
logger.log(
|
||||
"COMET", f"Digital Release Filter: {bool(settings.DIGITAL_RELEASE_FILTER)}"
|
||||
)
|
||||
|
||||
@@ -133,6 +133,7 @@ class AppSettings(BaseSettings):
|
||||
PROXY_ETHOS: Optional[str] = "always"
|
||||
RATELIMIT_MAX_RETRIES: Optional[int] = 3
|
||||
RATELIMIT_RETRY_BASE_DELAY: Optional[float] = 1.0
|
||||
RTN_FILTER_DEBUG: Optional[bool] = False
|
||||
|
||||
@field_validator("INDEXER_MANAGER_TYPE")
|
||||
def set_indexer_manager_type(cls, v, values):
|
||||
|
||||
@@ -22,7 +22,7 @@ class CometScraper(BaseScraper):
|
||||
|
||||
try:
|
||||
title = title_full.split("\n")[0].split("📄 ")[1]
|
||||
except:
|
||||
except Exception:
|
||||
continue
|
||||
seeders = (
|
||||
int(title_full.split("👤 ")[1].split(" ")[0])
|
||||
|
||||
@@ -1,30 +1,53 @@
|
||||
from RTN import parse, title_match
|
||||
|
||||
from comet.core.logger import logger
|
||||
from comet.core.models import settings
|
||||
|
||||
if settings.RTN_FILTER_DEBUG:
|
||||
|
||||
def _log_exclusion(msg):
|
||||
logger.log("FILTER", msg)
|
||||
else:
|
||||
|
||||
def _log_exclusion(msg):
|
||||
pass
|
||||
|
||||
|
||||
def filter_worker(torrents, title, year, year_end, aliases, remove_adult_content):
|
||||
# todo: log reason for each filtered torrent
|
||||
results = []
|
||||
|
||||
for torrent in torrents:
|
||||
torrent_title = torrent["title"]
|
||||
if "sample" in torrent_title.lower() or torrent_title == "":
|
||||
_log_exclusion(f"🚫 Rejected (Sample/Empty) | {torrent_title}")
|
||||
continue
|
||||
|
||||
parsed = parse(torrent_title)
|
||||
|
||||
if remove_adult_content and parsed.adult:
|
||||
_log_exclusion(f"🔞 Rejected (Adult) | {torrent_title}")
|
||||
continue
|
||||
|
||||
if not parsed.parsed_title or not title_match(
|
||||
title, parsed.parsed_title, aliases=aliases
|
||||
):
|
||||
_log_exclusion(
|
||||
f"❌ Rejected (Title Mismatch) | {torrent_title} | Parsed: {parsed.parsed_title} | Expected: {title}"
|
||||
)
|
||||
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
|
||||
else:
|
||||
if year < (parsed.year - 1) or year > (parsed.year + 1):
|
||||
_log_exclusion(
|
||||
f"📅 Rejected (Year Mismatch) | {torrent_title} | Year: {parsed.year} | Expected: ~{year}"
|
||||
)
|
||||
continue
|
||||
|
||||
torrent["parsed"] = parsed
|
||||
|
||||
Reference in New Issue
Block a user