This repository was archived by the owner on Jun 14, 2026. It is now read-only.
forked from L4GSP1KE/Upload-Assistant
-
Notifications
You must be signed in to change notification settings - Fork 139
refactor adult content detection #1301
Open
wastaken7
wants to merge
2
commits into
master
Choose a base branch
from
adult-content
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -997,6 +997,7 @@ async def tmdb_other_meta( | |
| tmdb_metadata = {} | ||
|
|
||
| # Initialize variables that might not be set in all code paths | ||
| adult_media = False | ||
| backdrop = "" | ||
| cast: list[str] = [] | ||
| certification = "" | ||
|
|
@@ -1131,6 +1132,8 @@ async def tmdb_other_meta( | |
| tmdb_type = media_data.get('type', 'Scripted') | ||
| networks = media_data.get('networks', []) | ||
|
|
||
| adult_media = media_data.get("adult", False) | ||
|
|
||
| production_companies = media_data.get('production_companies', []) | ||
| production_countries = media_data.get('production_countries', []) | ||
|
|
||
|
|
@@ -1317,41 +1320,42 @@ async def tmdb_other_meta( | |
|
|
||
| # Build the metadata dictionary | ||
| tmdb_metadata = { | ||
| 'title': title, | ||
| 'year': year, | ||
| 'release_date': release_date, | ||
| 'first_air_date': first_air_date, | ||
| 'last_air_date': last_air_date, | ||
| 'imdb_id': imdb_id, | ||
| 'tvdb_id': tvdb_id, | ||
| 'origin_country': origin_country, | ||
| 'original_language': original_language, | ||
| 'original_title': original_title, | ||
| 'keywords': keywords, | ||
| 'genres': genres, | ||
| 'genre_ids': genre_ids, | ||
| 'tmdb_creators': creators, | ||
| 'tmdb_directors': directors, | ||
| 'tmdb_cast': cast, | ||
| 'mal_id': mal_id, | ||
| 'anime': anime, | ||
| 'demographic': demographic, | ||
| 'retrieved_aka': retrieved_aka, | ||
| 'poster': poster, | ||
| 'tmdb_poster': poster_path, | ||
| 'logo': logo_path, | ||
| 'tmdb_logo': tmdb_logo, | ||
| 'backdrop': backdrop, | ||
| 'overview': overview, | ||
| 'tmdb_type': tmdb_type, | ||
| 'runtime': runtime, | ||
| 'youtube': youtube, | ||
| 'certification': certification, | ||
| 'production_companies': production_companies, | ||
| 'production_countries': production_countries, | ||
| 'networks': networks, | ||
| 'imdb_mismatch': imdb_mismatch, | ||
| 'mismatched_imdb_id': mismatched_imdb_id | ||
| "tmdb_adult_media": adult_media, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Backfill the new TMDb adult fields on already-populated metadata paths. Adding 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 |
||
| "title": title, | ||
| "year": year, | ||
| "release_date": release_date, | ||
| "first_air_date": first_air_date, | ||
| "last_air_date": last_air_date, | ||
| "imdb_id": imdb_id, | ||
| "tvdb_id": tvdb_id, | ||
| "origin_country": origin_country, | ||
| "original_language": original_language, | ||
| "original_title": original_title, | ||
| "keywords": keywords, | ||
| "genres": genres, | ||
| "genre_ids": genre_ids, | ||
| "tmdb_creators": creators, | ||
| "tmdb_directors": directors, | ||
| "tmdb_cast": cast, | ||
| "mal_id": mal_id, | ||
| "anime": anime, | ||
| "demographic": demographic, | ||
| "retrieved_aka": retrieved_aka, | ||
| "poster": poster, | ||
| "tmdb_poster": poster_path, | ||
| "logo": logo_path, | ||
| "tmdb_logo": tmdb_logo, | ||
| "backdrop": backdrop, | ||
| "overview": overview, | ||
| "tmdb_type": tmdb_type, | ||
| "runtime": runtime, | ||
| "youtube": youtube, | ||
| "certification": certification, | ||
| "production_companies": production_companies, | ||
| "production_countries": production_countries, | ||
| "networks": networks, | ||
| "imdb_mismatch": imdb_mismatch, | ||
| "mismatched_imdb_id": mismatched_imdb_id, | ||
| } | ||
|
|
||
| return tmdb_metadata | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 ofcombined_genres—for exampleErotic, 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