Skip to content

fix(ULCX): enhance get_name method to include episode titles for TV shows#1311

Draft
wastaken7 wants to merge 3 commits intomasterfrom
ulcx-specials
Draft

fix(ULCX): enhance get_name method to include episode titles for TV shows#1311
wastaken7 wants to merge 3 commits intomasterfrom
ulcx-specials

Conversation

@wastaken7
Copy link
Copy Markdown
Collaborator

@wastaken7 wastaken7 commented Mar 19, 2026

Fixes #1214.

Summary by CodeRabbit

  • New Features
    • TV episode entries now automatically include episode titles when available from multiple metadata sources, resulting in more descriptive episode names.
  • Bug Fixes
    • Ignored placeholder titles like "tba"/"tbd" to avoid adding meaningless episode labels; episode titles are only appended when non-empty and valid.

@github-actions
Copy link
Copy Markdown

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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 19, 2026

📝 Walkthrough

Walkthrough

get_name in ULCX now attempts to derive and append a missing or uncertain TV episode title (including specials like S00EXX) by consulting available episode metadata sources (tvdb, tvmaze, tmdb, imdb) and normalizing trivial placeholders (tba/tbd).

Changes

Cohort / File(s) Summary
ULCX episode title resolution
src/trackers/ULCX.py
Typed local ulcx_name as str; when meta["category"] == "TV" and season/episode may be missing/zero and not a tv_pack, try to obtain ep_title from tvdb_episode_data["episodes"], then tvmaze_episode_data["episode_name"], then tmdb_episode_data["name"], then imdb_info["episodes"]. Normalize "tba"/"tbd" to empty and, if found, append the title after the first episode token in the upload name.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A rabbit scampers through metadata hay,
Finding episode names along the way,
Specials no longer lost in the night,
Titles hop in, snug and right,
ULCX uploads gleam in new light! 🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: enhancing the get_name method to include episode titles for TV shows.
Linked Issues check ✅ Passed The implementation successfully addresses #1214 by retrieving episode titles from multiple sources and appending them to the upload title for special episodes.
Out of Scope Changes check ✅ Passed All changes are directly related to enhancing episode title retrieval for TV shows, which is the scope defined in #1214.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ulcx-specials

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: eee5a647-8c19-4432-8631-0c7acbbfd4eb

📥 Commits

Reviewing files that changed from the base of the PR and between 7df0d14 and 037aaae.

📒 Files selected for processing (1)
  • src/trackers/ULCX.py

Comment thread src/trackers/ULCX.py Outdated
@wastaken7 wastaken7 requested a review from Audionut March 19, 2026 17:25
@Audionut
Copy link
Copy Markdown
Owner

Specials on TVDb: use the S00E## format appended by the special name.
Specials not on TVDb: use the S##E00 format appended by the special name.

IMDB should only be a fallback if there is no TVDB ID.
TVMAZE is probably a better fallback for episode title.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 19547e0f-9e9f-4798-a01a-b51167ffdf7b

📥 Commits

Reviewing files that changed from the base of the PR and between 037aaae and 163637d.

📒 Files selected for processing (1)
  • src/trackers/ULCX.py

Comment thread src/trackers/ULCX.py
Comment on lines +154 to +160
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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.

Comment thread src/trackers/ULCX.py
Comment on lines +182 to +193
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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.

Suggested change
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.

@wastaken7 wastaken7 marked this pull request as draft March 26, 2026 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ULCX: Add episode title to upload if single special episode

2 participants