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
fix(ULCX): enhance get_name method to include episode titles for TV shows #1311
Draft
wastaken7
wants to merge
3
commits into
master
Choose a base branch
from
ulcx-specials
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.
Draft
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -122,7 +122,7 @@ def wrap_in_spoiler(match: re.Match[str]) -> str: | |||||||||||||||||||||||||||||||||||||||||||||||||
| return {'description': desc} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| async def get_name(self, meta: Meta) -> dict[str, str]: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ulcx_name = meta['name'] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ulcx_name: str = meta["name"] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| imdb_name = meta.get('imdb_info', {}).get('title', "") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| imdb_year = str(meta.get('imdb_info', {}).get('year', "")) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| imdb_aka = meta.get('imdb_info', {}).get('aka', "") | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -139,4 +139,65 @@ async def get_name(self, meta: Meta) -> dict[str, str]: | |||||||||||||||||||||||||||||||||||||||||||||||||
| if meta.get('category') != "TV" and imdb_year and imdb_year.strip() and year and year.strip() and imdb_year != year: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ulcx_name = ulcx_name.replace(f"{year}", imdb_year, 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| # Add the episode title for TV shows, if it is a special | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if meta.get("category") == "TV": | ||||||||||||||||||||||||||||||||||||||||||||||||||
| season_int = meta.get("season_int", 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| episode_int = meta.get("episode_int", 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if (season_int == 0 or episode_int == 0) and not meta.get("tv_pack", 0): | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ep_title = "" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| # 1. TVDB | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if not ep_title: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| tvdb_episode_data = meta.get("tvdb_episode_data") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if tvdb_episode_data and isinstance(tvdb_episode_data, dict): | ||||||||||||||||||||||||||||||||||||||||||||||||||
| episodes = tvdb_episode_data.get("episodes", []) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if episodes: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if episode_int == 0: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| # For SxxE00, find first episode of the season | ||||||||||||||||||||||||||||||||||||||||||||||||||
| for ep_entry in episodes: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if ep_entry.get("seasonNumber") == season_int: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ep_title = ep_entry.get("name", "").strip() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if ep_title: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| break | ||||||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| # For S00E## or regular episodes | ||||||||||||||||||||||||||||||||||||||||||||||||||
| for ep_entry in episodes: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if ep_entry.get("seasonNumber") == season_int and ep_entry.get("number") == episode_int: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ep_title = ep_entry.get("name", "").strip() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if ep_title: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| break | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| # 2. TVMaze | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if not ep_title: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| tvmaze_episode_data = meta.get("tvmaze_episode_data") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if tvmaze_episode_data and isinstance(tvmaze_episode_data, dict): | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ep_title = tvmaze_episode_data.get("episode_name", "").strip() | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| # 3. TMDB | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if not ep_title: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| tmdb_episode_data = meta.get("tmdb_episode_data") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if tmdb_episode_data and isinstance(tmdb_episode_data, dict): | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ep_title = tmdb_episode_data.get("name", "").strip() | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| # 4. IMDB (fallback) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if not ep_title: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| imdb_info: dict[str, Any] = meta.get("imdb_info", {}) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if imdb_info: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| episodes = imdb_info.get("episodes", []) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if episodes and isinstance(episodes, list): | ||||||||||||||||||||||||||||||||||||||||||||||||||
| season_str = str(season_int) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| episode_str = str(episode_int) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| for ep_entry in episodes: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if str(ep_entry.get("season", "")) == season_str and str(ep_entry.get("episode_number", "")) == episode_str: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ep_title = str(ep_entry.get("title", "")).strip() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if ep_title: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| break | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+182
to
+193
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. Gate IMDB fallback so it runs only when no TVDB ID exists. At Line 182, IMDB fallback currently runs even when TVDB metadata exists, which can override intended source precedence. Suggested fix- # 4. IMDB (fallback)
- if not ep_title:
+ # 4. IMDB fallback only when TVDB ID is unavailable
+ if not ep_title and not meta.get("tvdb_id"):
imdb_info: dict[str, Any] = meta.get("imdb_info", {})
if imdb_info:
episodes = imdb_info.get("episodes", [])Based on learnings: 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| if ep_title and ep_title.lower() in ("tba", "tbd"): | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ep_title = "" | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| if ep_title: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| episode_token = str(meta.get("episode", "")).strip() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if episode_token: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ulcx_name = ulcx_name.replace(episode_token, f"{episode_token} {ep_title}", 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| return {'name': ulcx_name} | ||||||||||||||||||||||||||||||||||||||||||||||||||
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.
TVDB lookup for
SxxE00can assign the wrong episode title.At Line 154, treating
episode_int == 0as “first episode of season” can incorrectly append episode 1’s title forSxxE00specials.Suggested fix
🤖 Prompt for AI Agents