Skip to content
This repository was archived by the owner on Jun 14, 2026. It is now read-only.
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 62 additions & 1 deletion src/trackers/ULCX.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', "")
Expand All @@ -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
Comment on lines +154 to +160

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.

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

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.


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}
Loading