Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use history api for importing episodes from trakt #205

Merged
merged 17 commits into from
May 30, 2023

Conversation

h3llrais3r
Copy link
Contributor

@h3llrais3r h3llrais3r commented Mar 1, 2023

The history api includes more details (i.e. indexer id) which can be used to properly match episodes (i.e. when jellyfin is using other indexer than trakt).
Matching by indexer id is a lot more accurate than matching by season and number.
This is a rework of #191 where we are now using the history by default for episode sync.

@Shadowghost Maybe we can only use the history api for episode import from trakt?
Because I think that the history api will always find a match and there is no need anymore for fallback by season/number lookup.
Please provide your feedback. If you agree, I can cleanup the seaons/number logic for episode import and only import based on history api.
Or we just keep the legacy code as well, in case in future the trakt api for watched shows/episodes would contain the indexer id's.

The history api includes more details (i.e. indexer id) which can be used to properly match episodes (i.e. when jellyfin is using other indexer than trakt).
Matching by indexer id is a lot more accurate than matching by season and number.
This is a rework of jellyfin#191 where we are now using the history by default for episode sync.
@Shadowghost
Copy link
Contributor

If there aren't any specific limits on using the history API I don't see why we should not use it instead of the current implementation.

@h3llrais3r
Copy link
Contributor Author

There is only 1 call to the history api every time you launch the import from trakt (it was already like that before with my previous PR).
Maybe let's leave the old logic still in there as fallback, just in case.
If that's ok for you, please review.

Copy link
Contributor

@Shadowghost Shadowghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be the cases in which the fallback would have any results but the history API won't?

Trakt/ScheduledTasks/SyncFromTraktTask.cs Outdated Show resolved Hide resolved
Trakt/ScheduledTasks/SyncFromTraktTask.cs Show resolved Hide resolved
Trakt/ScheduledTasks/SyncFromTraktTask.cs Outdated Show resolved Hide resolved
Trakt/ScheduledTasks/SyncFromTraktTask.cs Outdated Show resolved Hide resolved
@h3llrais3r
Copy link
Contributor Author

What would be the cases in which the fallback would have any results but the history API won't?

I think it's not possible, but not sure.
I don't think that there can be something in the watched api that isn't in the history... just logic thinking... 😉

@Shadowghost
Copy link
Contributor

If it's not possible, we don't need the fallback and you can remove it alltogether.

@h3llrais3r
Copy link
Contributor Author

Maybe we can leave it in for now, and check if it's not used by adding some different logging?
Or I can try on my whole library and see if it's not used...
I don't want to break the old logic, in case I missed out a case with the history implementation.
Please let me know what you prefer.

@Shadowghost
Copy link
Contributor

I'd prefer more testing. Just keeping it in because we aren't sure fells kinda dirty to me

@h3llrais3r
Copy link
Contributor Author

I'd prefer more testing. Just keeping it in because we aren't sure fells kinda dirty to me

I can test it, but not sure if my library is sufficient as test case... 😄
@SenorSmartyPants Could you do some testing as well?

Make distinction between logging for history match and legacy match.
@h3llrais3r
Copy link
Contributor Author

I've changed some logging to see a difference between match by history api or watched api.

@h3llrais3r
Copy link
Contributor Author

h3llrais3r commented Mar 2, 2023

What would be the cases in which the fallback would have any results but the history API won't?

I think it's not possible, but not sure. I don't think that there can be something in the watched api that isn't in the history... just logic thinking... 😉

Actually I think there is still a usecase for the fallback...
If the episode in jellyfin doesn't have any providerId assigned to it (do you know if this is possible?), there should still be a fallback to match by season and episode.
This because the IsMatch only seems to use the provider ids:
image

Or we need to extend this IsMatch to also check on season and number?
Something like this (as the history is also containing season and number info):
image

Example of history data:
image

Sorry for all the questions, but not sure how to reproduce all the cases, as I don't know a lot about jellyfin internals.

@SenorSmartyPants
Copy link
Contributor

I just did my small test case and it didn't behave quite right. I pull from your PR branch and compiled, installed this on my dev setup.

[15:57:34] [DBG] [35] Trakt.ScheduledTasks.SyncFromTraktTask: Episode is in watched history list of user Danzo: Episode: 0x1 'The Cage (Original Pilot)' Series: 'Star Trek' Tvdb id: 248303 Tmdb id: null Imdb id: tt0059753 TvRage id: null
[15:57:34] [DBG] [35] Trakt.ScheduledTasks.SyncFromTraktTask: Marking episode as watched for user Danzo locally: Episode: 0x1 'The Cage (Original Pilot)' Series: 'Star Trek' Tvdb id: 248303 Tmdb id: null Imdb id: tt0059753 TvRage id: null
[15:57:34] [DBG] [35] Trakt.ScheduledTasks.SyncFromTraktTask: Adjusting episode's play count to match a higher remote value (remote: 1 | local: 0) for user Danzo locally: Episode: 0x1 'The Cage (Original Pilot)' Series: 'Star Trek' Tvdb id: 248303 Tmdb id: null Imdb id: tt0059753 TvRage id: null
[15:57:34] [DBG] [35] Trakt.ScheduledTasks.SyncFromTraktTask: Episode is in watched history list of user Danzo: Episode: 1x8 'Balance of Terror' Series: 'Star Trek' Tvdb id: 248317 Tmdb id: null Imdb id: tt0708420 TvRage id: 162321
[15:57:34] [DBG] [35] Trakt.ScheduledTasks.SyncFromTraktTask: Marking episode as watched for user Danzo locally: Episode: 1x8 'Balance of Terror' Series: 'Star Trek' Tvdb id: 248317 Tmdb id: null Imdb id: tt0708420 TvRage id: 162321
[15:57:34] [DBG] [35] Trakt.ScheduledTasks.SyncFromTraktTask: Adjusting episode's play count to match a higher remote value (remote: 1 | local: 0) for user Danzo locally: Episode: 1x8 'Balance of Terror' Series: 'Star Trek' Tvdb id: 248317 Tmdb id: null Imdb id: tt0708420 TvRage id: 162321
[15:57:34] [DBG] [35] Trakt.ScheduledTasks.SyncFromTraktTask: Episode is in watched list of user Danzo: Episode: 1x14 'Court Martial' Series: 'Star Trek' Tvdb id: 248323 Tmdb id: null Imdb id: tt0708425 TvRage id: 162327
[15:57:34] [DBG] [35] Trakt.ScheduledTasks.SyncFromTraktTask: Marking episode as watched for user Danzo locally: Episode: 1x14 'Court Martial' Series: 'Star Trek' Tvdb id: 248323 Tmdb id: null Imdb id: tt0708425 TvRage id: 162327
[15:57:34] [DBG] [35] Trakt.ScheduledTasks.SyncFromTraktTask: Adjusting episode's play count to match a higher remote value (remote: 1 | local: 0) for user Danzo locally: Episode: 1x14 'Court Martial' Series: 'Star Trek' Tvdb id: 248323 Tmdb id: null Imdb id: tt0708425 TvRage id: 162327
[15:57:34] [DBG] [35] Trakt.ScheduledTasks.SyncFromTraktTask: Episode is in watched history list of user Danzo: Episode: 1x28 'The City on the Edge of Forever' Series: 'Star Trek' Tvdb id: 248331 Tmdb id: null Imdb id: tt0708455 TvRage id: 162335
[15:57:34] [DBG] [35] Trakt.ScheduledTasks.SyncFromTraktTask: Marking episode as watched for user Danzo locally: Episode: 1x28 'The City on the Edge of Forever' Series: 'Star Trek' Tvdb id: 248331 Tmdb id: null Imdb id: tt0708455 TvRage id: 162335
[15:57:34] [DBG] [35] Trakt.ScheduledTasks.SyncFromTraktTask: Adjusting episode's play count to match a higher remote value (remote: 1 | local: 0) for user Danzo locally: Episode: 1x28 'The City on the Edge of Forever' Series: 'Star Trek' Tvdb id: 248331 Tmdb id: null Imdb id: tt0708455 TvRage id: 162335
  • 1x8 Balance of terror (1x14 on Trakt) is now correctly marked as watched. Great!
  • But 1x14 (local) is also marked as watched. This one is not in my Trakt history.
  • 1x28 is marked as watched (same SxE on Trakt and local)

All my episode have multiple IDs(TVDB,IMDB,etc) as you can see. All watched episodes in question have exactly 1 play recorded on Trakt.

Thanks for your work on this.

@Shadowghost
Copy link
Contributor

To answer the question if it's possible that no provider id exists on an item: yes it is, if the metadata source is a NFO without provider ids.
Thanks for all the testing, I'd need to setup a whole testing library to check all the cases.

@h3llrais3r
Copy link
Contributor Author

h3llrais3r commented Mar 3, 2023

But 1x14 (local) is also marked as watched. This one is not in my Trakt history.

This is because of the fallback to the season/number.
You see this in the logs, as it doesn't mention Episode is in watched history list...
[15:57:34] [DBG] [35] Trakt.ScheduledTasks.SyncFromTraktTask: Episode is in watched list of user Danzo: Episode: 1x14 'Court Martial' Series: 'Star Trek' Tvdb id: 248323 Tmdb id: null Imdb id: tt0708425 TvRage id: 162327
The provider id is not found in history, but as fallback, it searches for a match by season/number. Since you have season 1, episode 14 in your watched list on trakt (from watched api), it will mark it as watched.

So it seems it works as expected, the only issue you have is because of the additional fallback.

But since it seems that you can have episodes in jellyfin without a provider Id, I don't think we can remove it.

Maybe if we do the fallback to season/number matching from history api itself, it would solve your problem.
Will try to make that change and let you know, so you can retest.

@h3llrais3r
Copy link
Contributor Author

h3llrais3r commented Mar 3, 2023

To answer the question if it's possible that no provider id exists on an item: yes it is, if the metadata source is a NFO without provider ids.

Ok, so we need to keep the fallback by season/number.
Since it's also part of history api, I will try to use it from there.

@h3llrais3r
Copy link
Contributor Author

@SenorSmartyPants
Can you rerun your test case on the new version?

@h3llrais3r
Copy link
Contributor Author

h3llrais3r commented Mar 3, 2023

Ok, so we need to keep the fallback by season/number. Since it's also part of history api, I will try to use it from there.

It seems that with adding the check for season/number in IsMatch it also finds it via the history api for episodes that don't have provider id's.

Below some logs: first 2 don't have id's, other have 1 or more id's

[2023-03-03 16:22:28.842 +01:00] [DBG] [32] Trakt.ScheduledTasks.SyncFromTraktTask: Episode is in watched history list of user "ADMIN": "Episode: 1x1 'The Dead Dance' Series: 'Corpse Princess' Tvdb id: null Tmdb id: null Imdb id: null TvRage id: null"
[2023-03-03 16:22:28.849 +01:00] [DBG] [32] Trakt.ScheduledTasks.SyncFromTraktTask: Marking episode as watched for user "ADMIN" locally: "Episode: 1x1 'The Dead Dance' Series: 'Corpse Princess' Tvdb id: null Tmdb id: null Imdb id: null TvRage id: null"
[2023-03-03 16:22:28.849 +01:00] [DBG] [32] Trakt.ScheduledTasks.SyncFromTraktTask: Adjusting episode's last played date to match a more recent remote last played date (remote: 11/28/2022 20:48:07 | local: null) for user "ADMIN" locally: "The Dead Dance"
[2023-03-03 16:22:28.850 +01:00] [DBG] [32] Trakt.ScheduledTasks.SyncFromTraktTask: Adjusting episode's play count to match a higher remote value (remote: 98 | local: 0) for user "ADMIN" locally: "Episode: 1x1 'The Dead Dance' Series: 'Corpse Princess' Tvdb id: null Tmdb id: null Imdb id: null TvRage id: null"
[2023-03-03 16:22:32.094 +01:00] [DBG] [32] Trakt.ScheduledTasks.SyncFromTraktTask: Episode is in watched history list of user "ADMIN": "Episode: 1x2 'The Game Continues' Series: 'Corpse Princess' Tvdb id: null Tmdb id: null Imdb id: null TvRage id: null"
[2023-03-03 16:22:32.157 +01:00] [DBG] [32] Trakt.ScheduledTasks.SyncFromTraktTask: Marking episode as watched for user "ADMIN" locally: "Episode: 1x2 'The Game Continues' Series: 'Corpse Princess' Tvdb id: null Tmdb id: null Imdb id: null TvRage id: null"
[2023-03-03 16:22:32.161 +01:00] [DBG] [32] Trakt.ScheduledTasks.SyncFromTraktTask: Adjusting episode's last played date to match a more recent remote last played date (remote: 11/28/2022 20:48:07 | local: null) for user "ADMIN" locally: "The Game Continues"
[2023-03-03 16:22:32.172 +01:00] [DBG] [32] Trakt.ScheduledTasks.SyncFromTraktTask: Adjusting episode's play count to match a higher remote value (remote: 98 | local: 0) for user "ADMIN" locally: "Episode: 1x2 'The Game Continues' Series: 'Corpse Princess' Tvdb id: null Tmdb id: null Imdb id: null TvRage id: null"
[2023-03-03 16:22:32.242 +01:00] [DBG] [32] Trakt.ScheduledTasks.SyncFromTraktTask: Episode is in watched history list of user "ADMIN": "Episode: 1x3 'Voice of Night' Series: 'Corpse Princess' Tvdb id: 395968 Tmdb id: null Imdb id: null TvRage id: null"
[2023-03-03 16:22:32.272 +01:00] [DBG] [32] Trakt.ScheduledTasks.SyncFromTraktTask: Marking episode as watched for user "ADMIN" locally: "Episode: 1x3 'Voice of Night' Series: 'Corpse Princess' Tvdb id: 395968 Tmdb id: null Imdb id: null TvRage id: null"
[2023-03-03 16:22:32.273 +01:00] [DBG] [32] Trakt.ScheduledTasks.SyncFromTraktTask: Adjusting episode's last played date to match a more recent remote last played date (remote: 11/28/2022 20:48:07 | local: null) for user "ADMIN" locally: "Voice of Night"
[2023-03-03 16:22:32.273 +01:00] [DBG] [32] Trakt.ScheduledTasks.SyncFromTraktTask: Adjusting episode's play count to match a higher remote value (remote: 98 | local: 0) for user "ADMIN" locally: "Episode: 1x3 'Voice of Night' Series: 'Corpse Princess' Tvdb id: 395968 Tmdb id: null Imdb id: null TvRage id: null"
[2023-03-03 16:22:32.333 +01:00] [DBG] [32] Trakt.ScheduledTasks.SyncFromTraktTask: Episode is in watched history list of user "ADMIN": "Episode: 1x4 'Sanbika' Series: 'Corpse Princess' Tvdb id: 401857 Tmdb id: null Imdb id: tt1346488 TvRage id: null"
[2023-03-03 16:22:32.357 +01:00] [DBG] [32] Trakt.ScheduledTasks.SyncFromTraktTask: Marking episode as watched for user "ADMIN" locally: "Episode: 1x4 'Sanbika' Series: 'Corpse Princess' Tvdb id: 401857 Tmdb id: null Imdb id: tt1346488 TvRage id: null"
[2023-03-03 16:22:32.357 +01:00] [DBG] [32] Trakt.ScheduledTasks.SyncFromTraktTask: Adjusting episode's last played date to match a more recent remote last played date (remote: 11/28/2022 20:48:07 | local: null) for user "ADMIN" locally: "Sanbika"
[2023-03-03 16:22:32.358 +01:00] [DBG] [32] Trakt.ScheduledTasks.SyncFromTraktTask: Adjusting episode's play count to match a higher remote value (remote: 98 | local: 0) for user "ADMIN" locally: "Episode: 1x4 'Sanbika' Series: 'Corpse Princess' Tvdb id: 401857 Tmdb id: null Imdb id: tt1346488 TvRage id: null"
[2023-03-03 16:22:32.414 +01:00] [DBG] [32] Trakt.ScheduledTasks.SyncFromTraktTask: Episode is in watched history list of user "ADMIN": "Episode: 1x5 'Haishinsô' Series: 'Corpse Princess' Tvdb id: 403679 Tmdb id: null Imdb id: tt1346183 TvRage id: null"
[2023-03-03 16:22:32.439 +01:00] [DBG] [32] Trakt.ScheduledTasks.SyncFromTraktTask: Marking episode as watched for user "ADMIN" locally: "Episode: 1x5 'Haishinsô' Series: 'Corpse Princess' Tvdb id: 403679 Tmdb id: null Imdb id: tt1346183 TvRage id: null"
[2023-03-03 16:22:32.439 +01:00] [DBG] [32] Trakt.ScheduledTasks.SyncFromTraktTask: Adjusting episode's last played date to match a more recent remote last played date (remote: 11/28/2022 20:48:07 | local: null) for user "ADMIN" locally: "Haishinsô"

EDIT: there seems to be something wrong with the playcount.
Please wait for testing until this is fixed.

@h3llrais3r
Copy link
Contributor Author

h3llrais3r commented Mar 3, 2023

Ok, I think this should be it. 😉

[2023-03-03 18:39:41.132 +01:00] [DBG] [21] Trakt.ScheduledTasks.SyncFromTraktTask: Episode is in watched history list of user "ADMIN": "Episode: 1x1 'The Dead Dance' Series: 'Corpse Princess' Tvdb id: null Tmdb id: null Imdb id: null TvRage id: null"
[2023-03-03 18:39:41.132 +01:00] [DBG] [21] Trakt.ScheduledTasks.SyncFromTraktTask: Marking episode as watched for user "ADMIN" locally: "Episode: 1x1 'The Dead Dance' Series: 'Corpse Princess' Tvdb id: null Tmdb id: null Imdb id: null TvRage id: null"
[2023-03-03 18:39:41.133 +01:00] [DBG] [21] Trakt.ScheduledTasks.SyncFromTraktTask: Adjusting episode's last played date to match a more recent remote last played date (remote: 03/13/2018 20:50:44 | local: null) for user "ADMIN" locally: "The Dead Dance"
[2023-03-03 18:39:41.170 +01:00] [DBG] [21] Trakt.ScheduledTasks.SyncFromTraktTask: Adjusting episode's play count to match a higher remote value (remote: 1 | local: 0) for user "ADMIN" locally: "Episode: 1x1 'The Dead Dance' Series: 'Corpse Princess' Tvdb id: null Tmdb id: null Imdb id: null TvRage id: null"
[2023-03-03 18:39:41.247 +01:00] [DBG] [21] Trakt.ScheduledTasks.SyncFromTraktTask: Episode is in watched history list of user "ADMIN": "Episode: 1x2 'The Game Continues' Series: 'Corpse Princess' Tvdb id: null Tmdb id: null Imdb id: null TvRage id: null"
[2023-03-03 18:39:41.247 +01:00] [DBG] [21] Trakt.ScheduledTasks.SyncFromTraktTask: Marking episode as watched for user "ADMIN" locally: "Episode: 1x2 'The Game Continues' Series: 'Corpse Princess' Tvdb id: null Tmdb id: null Imdb id: null TvRage id: null"
[2023-03-03 18:39:41.247 +01:00] [DBG] [21] Trakt.ScheduledTasks.SyncFromTraktTask: Adjusting episode's last played date to match a more recent remote last played date (remote: 03/13/2018 20:50:44 | local: null) for user "ADMIN" locally: "The Game Continues"
[2023-03-03 18:39:41.302 +01:00] [DBG] [21] Trakt.ScheduledTasks.SyncFromTraktTask: Adjusting episode's play count to match a higher remote value (remote: 1 | local: 0) for user "ADMIN" locally: "Episode: 1x2 'The Game Continues' Series: 'Corpse Princess' Tvdb id: null Tmdb id: null Imdb id: null TvRage id: null"
[2023-03-03 18:39:41.367 +01:00] [DBG] [21] Trakt.ScheduledTasks.SyncFromTraktTask: Episode is in watched history list of user "ADMIN": "Episode: 1x3 'Voice of Night' Series: 'Corpse Princess' Tvdb id: 395968 Tmdb id: null Imdb id: null TvRage id: null"
[2023-03-03 18:39:41.368 +01:00] [DBG] [21] Trakt.ScheduledTasks.SyncFromTraktTask: Marking episode as watched for user "ADMIN" locally: "Episode: 1x3 'Voice of Night' Series: 'Corpse Princess' Tvdb id: 395968 Tmdb id: null Imdb id: null TvRage id: null"
[2023-03-03 18:39:41.368 +01:00] [DBG] [21] Trakt.ScheduledTasks.SyncFromTraktTask: Adjusting episode's last played date to match a more recent remote last played date (remote: 03/13/2018 20:50:44 | local: null) for user "ADMIN" locally: "Voice of Night"
[2023-03-03 18:39:41.412 +01:00] [DBG] [21] Trakt.ScheduledTasks.SyncFromTraktTask: Adjusting episode's play count to match a higher remote value (remote: 1 | local: 0) for user "ADMIN" locally: "Episode: 1x3 'Voice of Night' Series: 'Corpse Princess' Tvdb id: 395968 Tmdb id: null Imdb id: null TvRage id: null"
[2023-03-03 18:39:41.476 +01:00] [DBG] [21] Trakt.ScheduledTasks.SyncFromTraktTask: Episode is in watched history list of user "ADMIN": "Episode: 1x4 'Sanbika' Series: 'Corpse Princess' Tvdb id: 401857 Tmdb id: null Imdb id: tt1346488 TvRage id: null"
[2023-03-03 18:39:41.476 +01:00] [DBG] [21] Trakt.ScheduledTasks.SyncFromTraktTask: Marking episode as watched for user "ADMIN" locally: "Episode: 1x4 'Sanbika' Series: 'Corpse Princess' Tvdb id: 401857 Tmdb id: null Imdb id: tt1346488 TvRage id: null"
[2023-03-03 18:39:41.476 +01:00] [DBG] [21] Trakt.ScheduledTasks.SyncFromTraktTask: Adjusting episode's last played date to match a more recent remote last played date (remote: 03/13/2018 20:50:44 | local: null) for user "ADMIN" locally: "Sanbika"
[2023-03-03 18:39:41.494 +01:00] [DBG] [21] Trakt.ScheduledTasks.SyncFromTraktTask: Adjusting episode's play count to match a higher remote value (remote: 1 | local: 0) for user "ADMIN" locally: "Episode: 1x4 'Sanbika' Series: 'Corpse Princess' Tvdb id: 401857 Tmdb id: null Imdb id: tt1346488 TvRage id: null"

Play count is now correct.

@SenorSmartyPants
Copy link
Contributor

@SenorSmartyPants Can you rerun your test case on the new version?

This isn't the fix I'm looking for. ;) Same behavior as before. 1x08, 1x14, and 1x28 marked as watched. 1x14 should not be.

Just from looking at the log file, it seems like you are iterating over the series in JF and matching them to the history. I think this is why it's giving the false positive match. If you iterate over the history from trakt, and match that to episodes in JF then one history item will only match to one episode in JF. As opposed to now, where one history item could match to mulitple episodes in JF.

[13:19:30] [DBG] [4] Trakt.ScheduledTasks.SyncFromTraktTask: Adjusting episode's play count to match a higher remote value (remote: 1 | local: 0) for user Danzo locally: Episode: 1x8 'Balance of Terror' Series: 'Star Trek' Tvdb id: 248317 Tmdb id: null Imdb id: tt0708420 TvRage id: 162321
[13:19:30] [DBG] [4] Trakt.ScheduledTasks.SyncFromTraktTask: No episode history data found for user Danzo for Episode: 1x9 'What Are Little Girls Made Of?' Series: 'Star Trek' Tvdb id: 248310 Tmdb id: null Imdb id: tt0708486 TvRage id: 162314
[13:19:30] [DBG] [4] Trakt.ScheduledTasks.SyncFromTraktTask: No episode history data found for user Danzo for Episode: 1x10 'Dagger of the Mind' Series: 'Star Trek' Tvdb id: 248312 Tmdb id: null Imdb id: tt0708426 TvRage id: 162316
[13:19:30] [DBG] [4] Trakt.ScheduledTasks.SyncFromTraktTask: No episode history data found for user Danzo for Episode: 1x11 'Miri' Series: 'Star Trek' Tvdb id: 248311 Tmdb id: null Imdb id: tt0394905 TvRage id: 162315
[13:19:30] [DBG] [4] Trakt.ScheduledTasks.SyncFromTraktTask: No episode history data found for user Danzo for Episode: 1x12 'The Conscience of the King' Series: 'Star Trek' Tvdb id: 248316 Tmdb id: null Imdb id: tt0394903 TvRage id: 162320
[13:19:30] [DBG] [4] Trakt.ScheduledTasks.SyncFromTraktTask: No episode history data found for user Danzo for Episode: 1x13 'The Galileo Seven' Series: 'Star Trek' Tvdb id: 248319 Tmdb id: null Imdb id: tt0708465 TvRage id: 162323
[13:19:30] [DBG] [4] Trakt.ScheduledTasks.SyncFromTraktTask: Episode is in watched history list of user Danzo: Episode: 1x14 'Court Martial' Series: 'Star Trek' Tvdb id: 248323 Tmdb id: null Imdb id: tt0708425 TvRage id: 162327
[13:19:30] [DBG] [4] Trakt.ScheduledTasks.SyncFromTraktTask: Marking episode as watched for user Danzo locally: Episode: 1x14 'Court Martial' Series: 'Star Trek' Tvdb id: 248323 Tmdb id: null Imdb id: tt0708425 TvRage id: 162327
[13:19:30] [DBG] [4] Trakt.ScheduledTasks.SyncFromTraktTask: Adjusting episode's play count to match a higher remote value (remote: 1 | local: 0) for user Danzo locally: Episode: 1x14 'Court Martial' Series: 'Star Trek' Tvdb id: 248323 Tmdb id: null Imdb id: tt0708425 TvRage id: 162327
[13:19:30] [DBG] [4] Trakt.ScheduledTasks.SyncFromTraktTask: No episode history data found for user Danzo for Episode: 1x15 'The Menagerie (1)' Series: 'Star Trek' Tvdb id: 248314 Tmdb id: null Imdb id: tt0394904 TvRage id: 162322
[13:19:30] [DBG] [4] Trakt.ScheduledTasks.SyncFromTraktTask: No episode history data found for user Danzo for Episode: 1x16 'The Menagerie (2)' Series: 'Star Trek' Tvdb id: 248315 Tmdb id: null Imdb id: tt0708472 TvRage id: 162319
[13:19:30] [DBG] [4] Trakt.ScheduledTasks.SyncFromTraktTask: No episode history data found for user Danzo for Episode: 1x17 'Shore Leave' Series: 'Star Trek' Tvdb id: 248318 Tmdb id: null Imdb id: tt0708446 TvRage id: 162322
[13:19:30] [DBG] [4] Trakt.ScheduledTasks.SyncFromTraktTask: No episode history data found for user Danzo for Episode: 1x18 'The Squire of Gothos' Series: 'Star Trek' Tvdb id: 248320 Tmdb id: null Imdb id: tt0708478 TvRage id: 162324
[13:19:30] [DBG] [4] Trakt.ScheduledTasks.SyncFromTraktTask: No episode history data found for user Danzo for Episode: 1x19 'Arena' Series: 'Star Trek' Tvdb id: 248321 Tmdb id: null Imdb id: tt0708418 TvRage id: 162325
[13:19:30] [DBG] [4] Trakt.ScheduledTasks.SyncFromTraktTask: No episode history data found for user Danzo for Episode: 1x20 'The Alternative Factor' Series: 'Star Trek' Tvdb id: 248330 Tmdb id: null Imdb id: tt0708451 TvRage id: 162334
[13:19:30] [DBG] [4] Trakt.ScheduledTasks.SyncFromTraktTask: No episode history data found for user Danzo for Episode: 1x21 'Tomorrow Is Yesterday' Series: 'Star Trek' Tvdb id: 248322 Tmdb id: null Imdb id: tt0708484 TvRage id: 162326
[13:19:30] [DBG] [4] Trakt.ScheduledTasks.SyncFromTraktTask: No episode history data found for user Danzo for Episode: 1x22 'The Return of the Archons' Series: 'Star Trek' Tvdb id: 248324 Tmdb id: null Imdb id: tt0708476 TvRage id: 162328
[13:19:30] [DBG] [4] Trakt.ScheduledTasks.SyncFromTraktTask: No episode history data found for user Danzo for Episode: 1x23 'A Taste of Armageddon' Series: 'Star Trek' Tvdb id: 248326 Tmdb id: null Imdb id: tt0708414 TvRage id: 162330
[13:19:30] [DBG] [4] Trakt.ScheduledTasks.SyncFromTraktTask: No episode history data found for user Danzo for Episode: 1x24 'Space Seed' Series: 'Star Trek' Tvdb id: 248325 Tmdb id: null Imdb id: tt0708447 TvRage id: 162329
[13:19:30] [DBG] [4] Trakt.ScheduledTasks.SyncFromTraktTask: No episode history data found for user Danzo for Episode: 1x25 'This Side of Paradise' Series: 'Star Trek' Tvdb id: 248327 Tmdb id: null Imdb id: tt0708483 TvRage id: 162331
[13:19:30] [DBG] [4] Trakt.ScheduledTasks.SyncFromTraktTask: No episode history data found for user Danzo for Episode: 1x26 'The Devil in the Dark' Series: 'Star Trek' Tvdb id: 248328 Tmdb id: null Imdb id: tt0708460 TvRage id: 162332
[13:19:30] [DBG] [4] Trakt.ScheduledTasks.SyncFromTraktTask: No episode history data found for user Danzo for Episode: 1x27 'Errand of Mercy' Series: 'Star Trek' Tvdb id: 248329 Tmdb id: null Imdb id: tt0708429 TvRage id: 162333
[13:19:30] [DBG] [4] Trakt.ScheduledTasks.SyncFromTraktTask: Episode is in watched history list of user Danzo: Episode: 1x28 'The City on the Edge of Forever' Series: 'Star Trek' Tvdb id: 248331 Tmdb id: null Imdb id: tt0708455 TvRage id: 162335
[13:19:30] [DBG] [4] Trakt.ScheduledTasks.SyncFromTraktTask: Marking episode as watched for user Danzo locally: Episode: 1x28 'The City on the Edge of Forever' Series: 'Star Trek' Tvdb id: 248331 Tmdb id: null Imdb id: tt0708455 TvRage id: 162335
[13:19:30] [DBG] [4] Trakt.ScheduledTasks.SyncFromTraktTask: Adjusting episode's play count to match a higher remote value (remote: 1 | local: 0) for user Danzo locally: Episode: 1x28 'The City on the Edge of Forever' Series: 'Star Trek' Tvdb id: 248331 Tmdb id: null Imdb id: tt0708455 TvRage id: 162335
[13:19:30] [DBG] [4] Trakt.ScheduledTasks.SyncFromTraktTask: No episode history data found for user Danzo for Episode: 1x29 'Operation: Annihilate!' Series: 'Star Trek' Tvdb id: 248332 Tmdb id: null Imdb id: tt0708441 TvRage id: 162336

BTW, debug lines would be easier for me to read if series name was listed before episode details.

@h3llrais3r
Copy link
Contributor Author

Please try again 😉

@SenorSmartyPants
Copy link
Contributor

Tested before the refactoring. Works right in my test case.

One thing that might happen (not sure how often): JF could have ids and Trakt might not. Your test doesn't currently account for that.

Trakt/Extensions.cs Fixed Show fixed Hide fixed
@Shadowghost
Copy link
Contributor

You'd need to explicitly check for the id types. It doesn't help that Trakt only guarantees the tmdb ids (and maybe IMDb) to be correct. Afaik tvdb ids aren't updated anymore.

@SenorSmartyPants
Copy link
Contributor

I think if TVDB ids are stored on TMDB Trakt gets them.

But a possibly bigger problem is that JF doesn't store TMDB ids AFAICT

@h3llrais3r
Copy link
Contributor Author

I now only match by provider id when both trakt and jellyfin have at least 1 provider id.
Can you check again?

Trakt/Extensions.cs Fixed Show fixed Hide fixed
@h3llrais3r
Copy link
Contributor Author

You'd need to explicitly check for the id types. It doesn't help that Trakt only guarantees the tmdb ids (and maybe IMDb) to be correct. Afaik tvdb ids aren't updated anymore.

So what you are saying is that we should check if both jellyfin and trakt have the id of the specific type (tvdb, imdb, ...) and only compare when both have it?

Trakt/Extensions.cs Show resolved Hide resolved
@h3llrais3r
Copy link
Contributor Author

I hope this should be fine now. At least for me it seems to work.

@h3llrais3r
Copy link
Contributor Author

@Shadowghost Did you already get any change to test this from your side?

@h3llrais3r
Copy link
Contributor Author

Bump.

@h3llrais3r
Copy link
Contributor Author

FYI: I've ran the plugin on my whole library and all my missing watched shows are now properly imported.
So for me the changes are working fine:

  • sync on id's if they are present in both source and destination
  • fallback to season/number sync when no matching id's are present

@Shadowghost
Copy link
Contributor

I'm still busy with my thesis, will look at this again once I'm done (~2 weeks).

@dabl2
Copy link

dabl2 commented May 26, 2023

Just a regular user here very interested in seeing this released, hoping it fixes the problem I'm seeing as described in #190

In my case, none of the watched movies or shows in my Trakt.tv account are marked as watched in jellyfin on import using the plugin.

I'm running Jellyfin.Server 10.8.10.0, with Trakt plug-in 23.0.0.0 in a docker on unraid

One thing I don't understand is how to see more information than I do in the below log output, for example any indexer IDs being used and/or what exactly is happening during/after 'ExecuteQueuedTasks' when (presumably) shows are supposed to be getting marked in jellyfin as watched?

I also don't understand why I don't seem to see anything in the log about how the plugin settings are enabled such as 'Skip unwatched import from trakt.tv' etc which seems like it would be helpful if not critical to know when trying to debug?

In my case I'm using the default out of the box settings.

Anyway don't mean to clutter the thread but am appreciative of this work being done to fix the problems and am looking forward to trying it, though as I understand it I wouldn't be able to help test given my docker only environment.

[2023-05-26 11:18:41.967 -04:00] [INF] [59] Emby.Server.Implementations.ScheduledTasks.TaskManager: Executing "Import watched states and playback progress from trakt.tv"
[2023-05-26 11:18:43.159 -04:00] [INF] [51] Trakt.ScheduledTasks.SyncFromTraktTask: Trakt.tv watched movies for user "dabl": 109
[2023-05-26 11:18:43.159 -04:00] [INF] [51] Trakt.ScheduledTasks.SyncFromTraktTask: Trakt.tv watched movies history for user "dabl": 129
[2023-05-26 11:18:43.159 -04:00] [INF] [51] Trakt.ScheduledTasks.SyncFromTraktTask: Trakt.tv paused movies for user "dabl": 1
[2023-05-26 11:18:43.159 -04:00] [INF] [51] Trakt.ScheduledTasks.SyncFromTraktTask: Trakt.tv watched shows for user "dabl": 75
[2023-05-26 11:18:43.159 -04:00] [INF] [51] Trakt.ScheduledTasks.SyncFromTraktTask: Trakt.tv watched episodes history for user "dabl": 937
[2023-05-26 11:18:43.159 -04:00] [INF] [51] Trakt.ScheduledTasks.SyncFromTraktTask: Trakt.tv paused episodes for user "dabl": 37
[2023-05-26 11:18:45.985 -04:00] [INF] [51] Emby.Server.Implementations.ScheduledTasks.TaskManager: "Import watched states and playback progress from trakt.tv" Completed after 0 minute(s) and 4 seconds
[2023-05-26 11:18:45.986 -04:00] [INF] [51] Emby.Server.Implementations.ScheduledTasks.TaskManager: ExecuteQueuedTasks

@Shadowghost
Copy link
Contributor

@h3llrais3r from the limited testing I did and your discussion in this issue I think this is good to go.

@h3llrais3r
Copy link
Contributor Author

h3llrais3r commented May 27, 2023

@Shadowghost I ran it on my complete library and I'm also satisfied with it. It has a better import rate from trakt then before. All the ones that were not imported before are now working. 😉

@h3llrais3r
Copy link
Contributor Author

h3llrais3r commented May 27, 2023

One thing I don't understand is how to see more information than I do in the below log output, for example any indexer IDs being used and/or what exactly is happening during/after 'ExecuteQueuedTasks' when (presumably) shows are supposed to be getting marked in jellyfin as watched?

I also don't understand why I don't seem to see anything in the log about how the plugin settings are enabled such as 'Skip unwatched import from trakt.tv' etc which seems like it would be helpful if not critical to know when trying to debug?

@dabl2 Enable debug logging: https://jellyfin.org/docs/general/administration/troubleshooting/#debug-logging

@dabl2
Copy link

dabl2 commented May 27, 2023

One thing I don't understand is how to see more information than I do in the below log output, for example any indexer IDs being used and/or what exactly is happening during/after 'ExecuteQueuedTasks' when (presumably) shows are supposed to be getting marked in jellyfin as watched?
I also don't understand why I don't seem to see anything in the log about how the plugin settings are enabled such as 'Skip unwatched import from trakt.tv' etc which seems like it would be helpful if not critical to know when trying to debug?

@dabl2 Enable debug logging: https://jellyfin.org/docs/general/administration/troubleshooting/#debug-logging

Ah thanks. RTFM

@crobibero crobibero added the feature This PR or Issue requests or introduces a new feature label May 30, 2023
@crobibero crobibero merged commit 404a102 into jellyfin:master May 30, 2023
@h3llrais3r h3llrais3r deleted the history-episode-import branch May 30, 2023 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This PR or Issue requests or introduces a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants