fix(ULCX): enhance get_name method to include episode titles for TV shows#1311
fix(ULCX): enhance get_name method to include episode titles for TV shows#1311
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. |
📝 WalkthroughWalkthroughget_name in Changes
Sequence Diagram(s)sequenceDiagram
participant U as ULCX.get_name
participant M as Meta (input)
participant TVDB as TVDB data
participant TVMAZE as TVMAZE data
participant TMDB as TMDB data
participant IMDB as IMDB data
U->>M: read meta, season_int, episode_int, tv_pack
alt category == "TV" and (season_int==0 or episode_int==0) and not tv_pack
U->>TVDB: query episodes for season/episode
TVDB-->>U: episode title (maybe)
alt no title from TVDB
U->>TVMAZE: read episode_name
TVMAZE-->>U: episode title (maybe)
end
alt still no title
U->>TMDB: read name
TMDB-->>U: episode title (maybe)
end
alt still no title
U->>IMDB: search episodes by season/episode
IMDB-->>U: episode title (maybe)
end
U->>U: normalize title ("tba"/"tbd" -> empty)
alt non-empty title
U->>U: insert title after first episode token in ulcx_name
end
end
U-->>M: return final ulcx_name
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/trackers/ULCX.py`:
- Around line 146-154: The special-episode detection currently checks
episode_str == "0" which skips specials like S00E01; change the condition to
check season_str == "0" instead so the block that looks up
meta["imdb_info"]["episodes"] and appends the episode title to ulcx_name runs
for season 0 specials (referencing variables season_str, episode_str, meta,
ulcx_name and the loop over ep_entry).
|
Specials on TVDb: use the IMDB should only be a fallback if there is no TVDB ID. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/trackers/ULCX.py`:
- Around line 154-160: The current logic treats episode_int == 0 as "first
episode of the season" and may wrongly pick episode 1's title; change the
handling so when episode_int == 0 you search episodes for an entry where
ep_entry.get("seasonNumber") == season_int AND ep_entry.get("episodeNumber") ==
0 (or a "special" flag if TVDB uses one) and use that ep_entry.get("name") for
ep_title if present; if no episodeNumber==0 special exists, do not fall back to
episodeNumber==1 (leave ep_title empty or keep existing behavior), updating the
block that iterates over episodes (variables: episode_int, season_int, episodes,
ep_entry, ep_title) accordingly.
- Around line 182-193: The IMDB fallback block (starting at the check for "if
not ep_title") should only run when there is no TVDB data present; update the
condition to require both that ep_title is falsy and that meta does not contain
TVDB info (e.g., use not meta.get("tvdb_id") or not
meta.get("tvdb_episode_data")). Specifically modify the existing "if not
ep_title:" guard to something like "if not ep_title and not
meta.get('tvdb_episode_data'):" so the loop over meta.get('imdb_info',
{}).get('episodes', []) (using season_int and episode_int to match entries) only
executes when TVDB episode data is absent.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
| 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 |
There was a problem hiding this comment.
TVDB lookup for SxxE00 can assign the wrong episode title.
At Line 154, treating episode_int == 0 as “first episode of season” can incorrectly append episode 1’s title for SxxE00 specials.
Suggested fix
- 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
+ # Use exact season/episode match only.
+ # If SxxE00 has no TVDB episode entry, fall through to other sources.
+ 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🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/trackers/ULCX.py` around lines 154 - 160, The current logic treats
episode_int == 0 as "first episode of the season" and may wrongly pick episode
1's title; change the handling so when episode_int == 0 you search episodes for
an entry where ep_entry.get("seasonNumber") == season_int AND
ep_entry.get("episodeNumber") == 0 (or a "special" flag if TVDB uses one) and
use that ep_entry.get("name") for ep_title if present; if no episodeNumber==0
special exists, do not fall back to episodeNumber==1 (leave ep_title empty or
keep existing behavior), updating the block that iterates over episodes
(variables: episode_int, season_int, episodes, ep_entry, ep_title) accordingly.
| 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 |
There was a problem hiding this comment.
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: meta['tvdb_episode_data'] is only set when meta['tvdb_id'] is present.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| 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 | |
| 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", []) | |
| 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 |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/trackers/ULCX.py` around lines 182 - 193, The IMDB fallback block
(starting at the check for "if not ep_title") should only run when there is no
TVDB data present; update the condition to require both that ep_title is falsy
and that meta does not contain TVDB info (e.g., use not meta.get("tvdb_id") or
not meta.get("tvdb_episode_data")). Specifically modify the existing "if not
ep_title:" guard to something like "if not ep_title and not
meta.get('tvdb_episode_data'):" so the loop over meta.get('imdb_info',
{}).get('episodes', []) (using season_int and episode_int to match entries) only
executes when TVDB episode data is absent.
Fixes #1214.
Summary by CodeRabbit