jellyfin / jellyfin-plugin-trakt

https://jellyfin.org
MIT License
179 stars 32 forks source link

Task changing play time for new collected items that were marked as watched on trakt #152

Closed GBMiro closed 1 year ago

GBMiro commented 2 years ago

OS: Windows 10 Jellyfin: 10.8.0 Plugin 19.0.0.0

When I collect new movies or episodes that are marked as watched on track, the next time Jellyfin starts after turning on the pc (not rebooting) this said episodes/movies play time is changed to the time the task has been executed, changing your previous play time.

Example: Collected all Indiana Jones and Jurassic Park movies and all were watched and had a previous play time on Trakt. After adding the films to Jellyfin everything was ok. This morning after booting up the pc, all the play times for the 7 movies have been changed to the time that the task has executed at the start up. So right now I have 7 films as watched today in my history on Trakt.

Shadowghost commented 2 years ago

Check you Jellyfin log for Movies to set watched: {Count}. Watched state is only exported to trakt if you enabled (un)watched syncing and the movie/episode is marked as watched locally (source code).

GBMiro commented 2 years ago

Log (The task executed twice):

First time

[2022-06-21 08:18:09.576 +02:00] [INF] [4] Trakt.ScheduledTasks.SyncLibraryTask: Movies to set ""watched: 3 [2022-06-21 08:18:10.240 +02:00] [INF] [16] Trakt.ScheduledTasks.SyncLibraryTask: Movies to set "un"watched: 4 [2022-06-21 08:18:15.477 +02:00] [INF] [16] Emby.Server.Implementations.ScheduledTasks.TaskManager: "Import watched states and playback progress from trakt.tv" Failed after 0 minute(s) and 7 seconds

Second time

[2022-06-21 08:19:05.984 +02:00] [INF] [16] Trakt.ScheduledTasks.SyncLibraryTask: Movies to set ""watched: 4 [2022-06-21 08:19:09.338 +02:00] [INF] [16] Emby.Server.Implementations.ScheduledTasks.TaskManager: "Import watched states and playback progress from trakt.tv" Failed after 0 minute(s) and 4 seconds

The thing is that I did not have them marked as watched locally. The config is the same as previous versions:

config

By the way, both tasks crash with this error:

[2022-06-21 08:18:15.424 +02:00] [ERR] [16] Trakt.ScheduledTasks.SyncFromTraktTask: Exception handled System.ArgumentOutOfRangeException: The UTC time represented when the offset is applied must be between year 0 and 10,000. (Parameter 'offset')

I can open a new issue for this if necessary.

Shadowghost commented 2 years ago

The error would explain why the time is wrong: the UTC conversion fails. I'll take a look

GBMiro commented 2 years ago

Thank you!

GBMiro commented 2 years ago

I disabled the option "During Scheduled Task, set trakt.tv items to unwatched if local item is unwatched" (I did not want this to happen) and it seems my issue got resolved. I need to do more testing to be 100% sure.

It also removed the UTC conversion error. I guess this option was triggering the error.

Shadowghost commented 2 years ago

Can you try reauthenticating the user, enabling the setting again and ru the task? I have a feeling that the older versions of the plugin didn't populate the fields for refreshing the access token properly for each user. Because in those code paths most of the UTC conversions happen within the code.

This seems to be realted to or a duplicate of #45

GBMiro commented 2 years ago

After doing what you asked I no longer get the UTC conversion error.

I tried reauthenticating the user before opening this issue but got the same error so it seems you need to figure out what setting is triggering the error, disable it and run the task first to see that everything is ok. Then proceed as you said: reauthenticate + enable setting again so the fields are properly populated.