diff --git a/lib/features/doc_viewer/container/video_viewer.dart b/lib/features/doc_viewer/container/video_viewer.dart index 1911dc3..d29abdf 100644 --- a/lib/features/doc_viewer/container/video_viewer.dart +++ b/lib/features/doc_viewer/container/video_viewer.dart @@ -180,6 +180,8 @@ class _VideoViewerState extends State { bool canCallOnce = false; + int? traktId; + Future setDurationFromTrakt() async { if (player.state.duration.inSeconds < 2) { return; @@ -203,10 +205,12 @@ class _VideoViewerState extends State { return; } + traktId = progress!.first.traktId; + final duration = Duration( seconds: calculateSecondsFromProgress( player.state.duration.inSeconds.toDouble(), - progress!.first.progress, + progress.first.progress, ), ); @@ -406,6 +410,7 @@ class _VideoViewerState extends State { meta: widget.meta as types.Meta, progress: currentProgressInPercentage, shouldClearCache: true, + traktId: traktId, ); } diff --git a/lib/features/trakt/service/trakt.service.dart b/lib/features/trakt/service/trakt.service.dart index 866f973..32d7228 100644 --- a/lib/features/trakt/service/trakt.service.dart +++ b/lib/features/trakt/service/trakt.service.dart @@ -755,6 +755,7 @@ class TraktService { required Meta meta, required double progress, bool shouldClearCache = false, + int? traktId, }) async { if (!isEnabled()) { _logger.info('Trakt integration is not enabled'); @@ -783,6 +784,7 @@ class TraktService { _cache.remove('$_baseUrl/sync/playback'); final keys = [ + if (traktId != null) "$_baseUrl/shows/$traktId/progress/watched", "continue_watching", if (meta.type == "series") "up_next_series", ]; @@ -821,7 +823,7 @@ class TraktService { } final isShow = - item["show"]["ids"]["imdb"] == (meta.imdbId ?? meta.id); + item["show"]?["ids"]?["imdb"] == (meta.imdbId ?? meta.id); final currentEpisode = item["episode"]["number"]; final currentSeason = item["episode"]["season"]; @@ -835,6 +837,7 @@ class TraktService { progress: item["progress"]!, episode: currentEpisode, season: currentSeason, + traktId: item["show"]["ids"]["trakt"], ), ); } diff --git a/lib/features/trakt/types/common.dart b/lib/features/trakt/types/common.dart index eb8f7b7..492fffd 100644 --- a/lib/features/trakt/types/common.dart +++ b/lib/features/trakt/types/common.dart @@ -3,11 +3,13 @@ class TraktProgress { final int? episode; final int? season; final double progress; + final int? traktId; TraktProgress({ required this.id, this.episode, this.season, required this.progress, + this.traktId, }); }