Conversation
|
Thanks for taking the time to contribute to this project. Upload Assistant is currently in a complete rewrite, and no new development is being conducted on this python source at this time. If you have come this far, please feel free to leave open, any pull requests regarding new sites being added to the source, as these can serve as the baseline for later conversion. If your pull request relates to a critical bug, this will be addressed in this code base, and a new release published as needed. If your pull request only addresses a quite minor bug, it is not likely to be addressed in this code base. Details for the new code base will follow at a later date. |
📝 WalkthroughWalkthroughThis PR centralizes adult media detection logic across trackers. Instead of each tracker independently detecting adult content via regex pattern matching on keywords and genres, the system now extracts adult flags from TMDB, computes a unified Changes
Sequence DiagramsequenceDiagram
participant User
participant Prep
participant TMDB as TMDB API
participant Tracker
participant COMMON
User->>Prep: Start upload
Prep->>TMDB: Fetch media data
TMDB-->>Prep: Return adult flag
Prep->>Prep: check_adult_media()
Note over Prep: Evaluate TMDB flag<br/>+ keyword matching
Prep->>Tracker: meta["adult_media"] = bool
Tracker->>COMMON: check_and_confirm_adult_media_upload(meta)
alt Adult media detected
COMMON->>User: Prompt confirmation<br/>(if not unattended)
User-->>COMMON: Confirm/Deny
COMMON-->>Tracker: Return bool
else Not adult media
COMMON-->>Tracker: Return True
end
alt Confirmation allowed
Tracker->>Tracker: Proceed with upload
else Confirmation denied
Tracker->>Tracker: Skip/Abort upload
end
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly Related PRs
Suggested Reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip You can validate your CodeRabbit configuration file in your editor.If your editor has YAML language server, you can enable auto-completion and validation by adding |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/trackers/COMMON.py (1)
1318-1336: Centralized adult content check looks correct.The logic correctly handles:
- Interactive mode: prompts user for confirmation
- Unattended with
unattended_confirm: prompts user- Unattended without confirm: silently blocks upload
Minor suggestion for slightly cleaner control flow:
♻️ Optional: Simplify conditional with inverted check
if meta.get("adult_media", False): if not meta["unattended"] or (meta["unattended"] and meta.get("unattended_confirm", False)): console.print(f"[bold red]Pornography is not allowed at {tracker}.[/bold red]") - if cli_ui.ask_yes_no("Do you want to upload anyway?", default=False): - pass - else: + if not cli_ui.ask_yes_no("Do you want to upload anyway?", default=False): return False else: return False return True🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/trackers/COMMON.py` around lines 1318 - 1336, The control flow in check_and_confirm_adult_media_upload is correct but can be simplified: if meta["adult_media"] is truthy, first return False immediately when meta.get("unattended", False) is True and meta.get("unattended_confirm", False) is False; otherwise print the console message and call cli_ui.ask_yes_no("Do you want to upload anyway?", default=False) and return True only if that call returns True (else return False); keep all checks referencing meta keys "adult_media", "unattended", and "unattended_confirm" and use the existing console.print and cli_ui.ask_yes_no calls in the function.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/prep.py`:
- Around line 1274-1278: The combined genres/keywords string is built with a
space so entries at the start of meta["combined_genres"] can evade the
comma-aware regex; change how genres is constructed (e.g., join keywords and
combined_genres with a comma and/or use filter to avoid empty parts) so genres
is a true comma-separated list before the regex runs (refer to the variable
genres and the use of meta.get('keywords', ''), meta.get('combined_genres', ''),
and adult_keywords in this block).
In `@src/tmdb.py`:
- Line 1323: The new tmdb_adult_media field (and TMDb keywords) won't be
backfilled because set_tmdb_metadata() short-circuits when
title/year/genres/overview exist; update set_tmdb_metadata() so it still fetches
TMDb data when tmdb_adult_media or tmdb_keywords are missing (or null) even if
title/year/genres/overview are present, then write those fields into the same
metadata paths (tmdb_adult_media and tmdb_keywords) so Prep.check_adult_media()
can see accurate values; reference set_tmdb_metadata(), tmdb_adult_media, and
tmdb_keywords when making the conditional and write-back changes.
In `@src/trackers/RTF.py`:
- Around line 202-205: The shared helper
COMMON.check_and_confirm_adult_media_upload currently allows a user override;
change its behavior so that when meta indicates adult_media it does not prompt
and always returns False (hard-reject) instead of calling cli_ui.ask_yes_no and
returning True on confirmation; keep callers like RTF (the call in RTF where
COMMON(config=self.config).check_and_confirm_adult_media_upload(meta,
self.tracker) is used) unchanged so they continue to set meta['skipping']="RTF"
and return [] when the helper returns False.
---
Nitpick comments:
In `@src/trackers/COMMON.py`:
- Around line 1318-1336: The control flow in
check_and_confirm_adult_media_upload is correct but can be simplified: if
meta["adult_media"] is truthy, first return False immediately when
meta.get("unattended", False) is True and meta.get("unattended_confirm", False)
is False; otherwise print the console message and call cli_ui.ask_yes_no("Do you
want to upload anyway?", default=False) and return True only if that call
returns True (else return False); keep all checks referencing meta keys
"adult_media", "unattended", and "unattended_confirm" and use the existing
console.print and cli_ui.ask_yes_no calls in the function.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e84e2b24-5765-4b08-a29f-bc7422401cfe
📒 Files selected for processing (13)
src/prep.pysrc/tmdb.pysrc/trackers/ANT.pysrc/trackers/AR.pysrc/trackers/BHD.pysrc/trackers/COMMON.pysrc/trackers/IHD.pysrc/trackers/LUME.pysrc/trackers/OE.pysrc/trackers/RF.pysrc/trackers/RTF.pysrc/trackers/TL.pysrc/trackers/ULCX.py
| genres = f"{meta.get('keywords', '')} {meta.get('combined_genres', '')}" | ||
| if meta.get("tmdb_adult_media", False): | ||
| return True | ||
| else: | ||
| return bool(any(re.search(rf"(^|,\s*){re.escape(keyword)}(\s*,|$)", genres, re.IGNORECASE) for keyword in adult_keywords)) |
There was a problem hiding this comment.
Use a comma-aware separator before running the adult regex.
The pattern only matches at start-of-string or after a comma. f"{keywords} {combined_genres}" inserts a plain space, so an adult value at the start of combined_genres—for example Erotic, Drama—won't match and the shared adult gate can be bypassed.
Suggested fix
def check_adult_media(self, meta) -> bool:
adult_keywords = ["xxx", "erotic", "porn", "adult", "orgy"]
- genres = f"{meta.get('keywords', '')} {meta.get('combined_genres', '')}"
if meta.get("tmdb_adult_media", False):
return True
- else:
- return bool(any(re.search(rf"(^|,\s*){re.escape(keyword)}(\s*,|$)", genres, re.IGNORECASE) for keyword in adult_keywords))
+ searchable = ", ".join(
+ part for part in (meta.get('keywords', ''), meta.get('combined_genres', '')) if part
+ )
+ return any(
+ re.search(rf"(^|,\s*){re.escape(keyword)}(\s*,|$)", searchable, re.IGNORECASE)
+ for keyword in adult_keywords
+ )🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/prep.py` around lines 1274 - 1278, The combined genres/keywords string is
built with a space so entries at the start of meta["combined_genres"] can evade
the comma-aware regex; change how genres is constructed (e.g., join keywords and
combined_genres with a comma and/or use filter to avoid empty parts) so genres
is a true comma-separated list before the regex runs (refer to the variable
genres and the use of meta.get('keywords', ''), meta.get('combined_genres', ''),
and adult_keywords in this block).
| 'networks': networks, | ||
| 'imdb_mismatch': imdb_mismatch, | ||
| 'mismatched_imdb_id': mismatched_imdb_id | ||
| "tmdb_adult_media": adult_media, |
There was a problem hiding this comment.
Backfill the new TMDb adult fields on already-populated metadata paths.
Adding tmdb_adult_media here isn't sufficient while set_tmdb_metadata() still skips the TMDb fetch as soon as title/year/genres/overview exist. Those paths never populate tmdb_adult_media or TMDb keywords, so Prep.check_adult_media() can classify adult titles as safe.
Suggested fix
# src/tmdb.py
- essential_fields = ['title', 'year', 'genres', 'overview']
+ essential_fields = ['title', 'year', 'genres', 'overview', 'keywords', 'tmdb_adult_media']🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/tmdb.py` at line 1323, The new tmdb_adult_media field (and TMDb keywords)
won't be backfilled because set_tmdb_metadata() short-circuits when
title/year/genres/overview exist; update set_tmdb_metadata() so it still fetches
TMDb data when tmdb_adult_media or tmdb_keywords are missing (or null) even if
title/year/genres/overview are present, then write those fields into the same
metadata paths (tmdb_adult_media and tmdb_keywords) so Prep.check_adult_media()
can see accurate values; reference set_tmdb_metadata(), tmdb_adult_media, and
tmdb_keywords when making the conditional and write-back changes.
| common = COMMON(config=self.config) | ||
| if not common.check_and_confirm_adult_media_upload(meta, self.tracker): | ||
| meta['skipping'] = "RTF" | ||
| return [] |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
common_file="$(fd 'COMMON.py$' src | head -n 1)"
[ -n "$common_file" ] || { echo "COMMON.py not found" >&2; exit 1; }
echo "=== check_and_confirm_adult_media_upload ==="
python - "$common_file" <<'PY'
import sys
from pathlib import Path
path = Path(sys.argv[1])
lines = path.read_text(encoding="utf-8").splitlines()
start = None
indent = None
for i, line in enumerate(lines):
stripped = line.lstrip()
if stripped.startswith("def check_and_confirm_adult_media_upload("):
start = i
indent = len(line) - len(stripped)
break
if start is None:
raise SystemExit("method not found")
for j, line in enumerate(lines[start:], start=start):
stripped = line.lstrip()
current_indent = len(line) - len(stripped)
if j > start and stripped.startswith(("def ", "class ")) and current_indent <= indent:
break
print(line)
PY
echo
echo "=== call sites ==="
rg -n -C2 'check_and_confirm_adult_media_upload\s*\(' srcRepository: Audionut/Upload-Assistant
Length of output: 3601
Remove user override capability from adult-content check in shared helper.
The shared helper check_and_confirm_adult_media_upload() allows uploads to proceed when the user confirms "yes" to the override prompt. This changes RTF (and other trackers like LUME, OE) from a hard-reject to a user-overridable block.
Looking at COMMON.py, when adult_media is flagged and the user is not in unattended mode, the method prints a warning and calls ask_yes_no(). If the user selects yes, it executes pass and then returns True, allowing the upload:
if cli_ui.ask_yes_no("Do you want to upload anyway?", default=False):
pass # Falls through to return True
else:
return FalseEither the helper should return False unconditionally when adult content is detected (restoring the hard-reject behavior), or it should only be used for trackers that legitimately allow user override.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/trackers/RTF.py` around lines 202 - 205, The shared helper
COMMON.check_and_confirm_adult_media_upload currently allows a user override;
change its behavior so that when meta indicates adult_media it does not prompt
and always returns False (hard-reject) instead of calling cli_ui.ask_yes_no and
returning True on confirmation; keep callers like RTF (the call in RTF where
COMMON(config=self.config).check_and_confirm_adult_media_upload(meta,
self.tracker) is used) unchanged so they continue to set meta['skipping']="RTF"
and return [] when the helper returns False.
#1279
Summary by CodeRabbit
New Features
Refactor