Release v1.0.13: fix TheTVDB match crash and improve stability.
Emit plain tuples across thread boundaries, prevent overlapping match workers, scope episode comparisons by season, and cap API pagination. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
+21
-2
@@ -45,6 +45,13 @@ class EpisodeTarget:
|
||||
return f"S{s}E{e1}"
|
||||
|
||||
|
||||
def target_to_tuple(target: EpisodeTarget) -> tuple[int, ...]:
|
||||
"""Plain tuple safe to pass through Qt signals."""
|
||||
if target.episode_end is not None and target.episode_end > target.episode:
|
||||
return (target.season, target.episode, target.episode_end)
|
||||
return (target.season, target.episode)
|
||||
|
||||
|
||||
def split_combined_title(name: str) -> list[str]:
|
||||
"""Split a combined-order episode title like 'Ep A/Ep B' into parts."""
|
||||
return [p.strip() for p in name.replace(" / ", "/").split("/") if p.strip()]
|
||||
@@ -395,7 +402,19 @@ def match_filenames_to_episodes(
|
||||
|
||||
pairs: list[tuple[float, str, EpisodeTarget, str, str]] = []
|
||||
for fname, fnorm, raw_title, parsed in file_entries:
|
||||
for season, ep_num, enorm, ep_name in ep_entries:
|
||||
file_season = parsed.get("season")
|
||||
if season_filter == 0 and file_season is not None:
|
||||
season_eps = [e for e in ep_entries if e[0] == file_season]
|
||||
season_combined = [
|
||||
(cep, target, variants)
|
||||
for cep, target, variants in combined_entries
|
||||
if target.season == file_season
|
||||
]
|
||||
else:
|
||||
season_eps = ep_entries
|
||||
season_combined = combined_entries
|
||||
|
||||
for season, ep_num, enorm, ep_name in season_eps:
|
||||
if not fnorm:
|
||||
continue
|
||||
score = _apply_season_hint(
|
||||
@@ -412,7 +431,7 @@ def match_filenames_to_episodes(
|
||||
ep_name,
|
||||
)
|
||||
)
|
||||
for _cep, target, variants in combined_entries:
|
||||
for _cep, target, variants in season_combined:
|
||||
if not fnorm:
|
||||
continue
|
||||
if not _combined_allowed_for_file(parsed, target, _cep.name):
|
||||
|
||||
@@ -206,8 +206,9 @@ class TvdbClient:
|
||||
"""Fetch episodes; optional translated titles via language code (e.g. eng)."""
|
||||
episodes: list[TvdbEpisode] = []
|
||||
page = 0
|
||||
max_pages = 50
|
||||
use_api_season = season is not None and not language
|
||||
while True:
|
||||
while page < max_pages:
|
||||
params: dict[str, Any] = {"page": page}
|
||||
if use_api_season:
|
||||
params["season"] = season
|
||||
|
||||
Reference in New Issue
Block a user