mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-03 05:34:23 -04:00
Fix scanning with partial absolute groups on tmdb
This commit is contained in:
parent
21841604a3
commit
0d5957c3f8
@ -559,6 +559,7 @@ class TheMovieDatabase(Provider):
|
|||||||
absolute-ordered group and return it
|
absolute-ordered group and return it
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
show = await self.identify_show(show_id)
|
||||||
try:
|
try:
|
||||||
groups = await self.get(f"tv/{show_id}/episode_groups")
|
groups = await self.get(f"tv/{show_id}/episode_groups")
|
||||||
ep_count = max((x["episode_count"] for x in groups["results"]), default=0)
|
ep_count = max((x["episode_count"] for x in groups["results"]), default=0)
|
||||||
@ -577,7 +578,22 @@ class TheMovieDatabase(Provider):
|
|||||||
if group_id is None:
|
if group_id is None:
|
||||||
return None
|
return None
|
||||||
group = await self.get(f"tv/episode_group/{group_id}")
|
group = await self.get(f"tv/episode_group/{group_id}")
|
||||||
return [ep for grp in group["groups"] for ep in grp["episodes"]]
|
absgrp = [ep for grp in group["groups"] for ep in grp["episodes"]]
|
||||||
|
logger.warn(
|
||||||
|
f"Incomplete absolute group for show {show_id}. Filling missing values by assuming season/episode order is ascending"
|
||||||
|
)
|
||||||
|
complete_abs = absgrp + [
|
||||||
|
{"season_number": s.season_number, "episode_number": e}
|
||||||
|
for s in show.seasons
|
||||||
|
# ignore specials not specified in the absgrp
|
||||||
|
if s.season_number > 0
|
||||||
|
for e in range(1, s.episodes_count)
|
||||||
|
if not any(
|
||||||
|
x["season_number"] == s.season_number and x["episode_number"] == e
|
||||||
|
for x in absgrp
|
||||||
|
)
|
||||||
|
]
|
||||||
|
return complete_abs
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
"Could not retrieve absolute ordering information", exc_info=e
|
"Could not retrieve absolute ordering information", exc_info=e
|
||||||
@ -642,17 +658,17 @@ class TheMovieDatabase(Provider):
|
|||||||
if absolute is not None:
|
if absolute is not None:
|
||||||
return absolute
|
return absolute
|
||||||
# assume we use tmdb weird absolute by default (for example, One Piece S21E800, the first
|
# assume we use tmdb weird absolute by default (for example, One Piece S21E800, the first
|
||||||
# episode of S21 si not reset to 0 but keep increasing so it can be 800
|
# episode of S21 is not reset to 0 but keep increasing so it can be 800
|
||||||
start = next(
|
start = next(
|
||||||
(x["episode_number"] for x in absgrp if x["season_number"] == season), None
|
(x["episode_number"] for x in absgrp if x["season_number"] == season), None
|
||||||
)
|
)
|
||||||
if start is None or start <= episode_nbr:
|
if start is not None and start <= episode_nbr:
|
||||||
raise ProviderError(
|
# add back the continuous number (imagine the user has one piece S21e31
|
||||||
f"Could not guess absolute number of episode {show_id} s{season} e{episode_nbr}"
|
# but tmdb registered it as S21E831 since S21's first ep is 800
|
||||||
)
|
return await self.get_absolute_number(show_id, season, episode_nbr + start)
|
||||||
# add back the continuous number (imagine the user has one piece S21e31
|
raise ProviderError(
|
||||||
# but tmdb registered it as S21E831 since S21's first ep is 800
|
f"Could not guess absolute number of episode {show_id} s{season} e{episode_nbr}"
|
||||||
return await self.get_absolute_number(show_id, season, episode_nbr + start)
|
)
|
||||||
|
|
||||||
async def identify_collection(self, provider_id: str) -> Collection:
|
async def identify_collection(self, provider_id: str) -> Collection:
|
||||||
languages = self.get_languages()
|
languages = self.get_languages()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user