diff --git a/resources/lib/syncEpisodes.py b/resources/lib/syncEpisodes.py index 95be9ce5..70fbc848 100644 --- a/resources/lib/syncEpisodes.py +++ b/resources/lib/syncEpisodes.py @@ -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']}) diff --git a/resources/lib/syncMovies.py b/resources/lib/syncMovies.py index 8218a104..89bf500e 100644 --- a/resources/lib/syncMovies.py +++ b/resources/lib/syncMovies.py @@ -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 diff --git a/resources/lib/traktapi.py b/resources/lib/traktapi.py index 5657f15e..8c823aaf 100644 --- a/resources/lib/traktapi.py +++ b/resources/lib/traktapi.py @@ -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):