Skip to content

Commit

Permalink
Add support for tmdb continuous (absolute) ordering when using normal…
Browse files Browse the repository at this point in the history
… ordering (ex: One piece)
  • Loading branch information
zoriya committed Feb 26, 2024
1 parent c14c0a6 commit 33a5893
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion scanner/providers/implementations/themoviedatabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ async def get_absolute_number(self, show_id: str, season: int, episode_nbr: int)
)
+ episode_nbr
)
return next(
absolute = next(
(
# The + 1 is to go from 0based index to 1based absolute number
i + 1
Expand All @@ -664,6 +664,18 @@ async def get_absolute_number(self, show_id: str, season: int, episode_nbr: int)
),
None,
)
if absolute is not None:
return absolute
# 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
start = next(
(x["episode_number"] for x in absgrp if x["season_number"] == season), None
)
if start is None or start <= episode_nbr:
return None
# add back the continuous number (imagine the user has one piece S21e31
# 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)

async def identify_collection(self, provider_id: str) -> Collection:
languages = self.get_languages()
Expand Down

0 comments on commit 33a5893

Please sign in to comment.