Skip to content

Commit

Permalink
Merge pull request #623 from ZelKami/resume-point
Browse files Browse the repository at this point in the history
Fix runtime fallback for calculating episode progress
  • Loading branch information
razzeee authored Sep 7, 2023
2 parents 88abc37 + 67cfcd5 commit 8f93f7a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion resources/lib/syncEpisodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ def __addEpisodeProgressToKodi(self, traktShows, kodiShows, fromPercent, toPerce
# Trakt to avoid later using 0 in runtime * progress_pct.
if not episode['runtime']:
episode['runtime'] = self.sync.traktapi.getEpisodeSummary(
show['ids']['trakt'], season['number'], episode['number'], extended='full').runtime
show['ids']['trakt'], season['number'], episode['number'], extended='full').runtime * 60
episodes.append(
{'episodeid': episode['ids']['episodeid'], 'progress': episode['progress'], 'runtime': episode['runtime']})

Expand Down
6 changes: 6 additions & 0 deletions resources/lib/syncMovies.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,12 @@ def __addMovieProgressToKodi(self, traktMovies, kodiMovies, fromPercent, toPerce

self.sync.UpdateProgress(fromPercent, line1='', line2=kodiUtilities.getString(
32126) % len(kodiMoviesToUpdate))
# If library item doesn't have a runtime set get it from
# Trakt to avoid later using 0 in runtime * progress_pct.
for movie in kodiMoviesToUpdate:
if not movie['runtime']:
movie['runtime'] = self.sync.traktapi.getMovieSummary(
movie['ids']['trakt'], extended='full').runtime * 60
# need to calculate the progress in int from progress in percent from Trakt
# split movie list into chunks of 50
chunksize = 50
Expand Down
4 changes: 2 additions & 2 deletions resources/lib/traktapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,9 @@ def getEpisodePlaybackProgress(self):

return progressEpisodes

def getMovieSummary(self, movieId):
def getMovieSummary(self, movieId, extended=None):
with Trakt.configuration.http(retry=True):
return Trakt['movies'].get(movieId)
return Trakt['movies'].get(movieId, extended=extended)

def getShowSummary(self, showId):
with Trakt.configuration.http(retry=True):
Expand Down

0 comments on commit 8f93f7a

Please sign in to comment.