jellyfin / jellyfin-plugin-trakt

https://jellyfin.org
MIT License
173 stars 33 forks source link

Show episodes marked as watched in trakt not being synced to jellyfin on import task #190

Closed h3llrais3r closed 1 year ago

h3llrais3r commented 1 year ago

I recently moved from kodi to jellyfin and want to import my watched status from trakt to jellyfin.

I have been doing some analysis already myself and it seems that the import from trakt to jellyfin is not working for shows/episodes that are not aligned between tmdb and tvdb.

This most likely has been the result of the switch in trakt from tvdb to tmdb. Quite a few series are split in seasons on tvdb, while on tmdb they are not. I have the most issues with anime series, as they are typically split up in a lot more seasons on tvdb. Since I'm maintaining my library via sonarr, which uses tvdb, my files are organized with the tvdb seasoning.

Example: Inuyasha trakt: https://trakt.tv/shows/inuyasha/ tmdb: https://www.themoviedb.org/tv/35610-inuyasha/seasons (2 seasons) tvdb: https://thetvdb.com/series/inuyasha (7 seasons)

All shows have been watched in the past from kodi (when trakt was still using tvdb). image This is tmdb seasoning: image

When I'm now importing from scratch in jellyfin, only the 26 episodes from season 1 are imported and the 26 episodes from season 2 (tmdb seasoning) as those are the only ones that are matching between tmdb and tvdb. image

When looking at the code, it seems that the problem comes from the fact that there is first a check on season number matching... While looping over all episodes in jellyfin (1) if will normally at least find a match in trakt if it's watched (2), but the check for season match (3) will never return a match for seasons that exist in tvdb, but not exist in tmdb. (For example: season 3 till 7 don't exist in tmdb so the check will return no match and the check for episode doens't happen) image

Maybe a proposal to work the way around: Why not looping all watched episodes in trakt and then try to find a match in jellyfin? I think we also need to use the history api from trakt, as this is returning more details for the watched episodes. image

As you can see, all episodes id's (tvdb, imdb, tmdb, ...) so I think it's easier to find a match with the episodes in jellyfin. Using the season and number, will always cause issues if they are not the same across the indexers.

I hope it's clear what I'm trying to say and I really hope this could be solved.

I might look for a solution myself (I'm a developer) but haven't been coding in dotnet for the last 20 years :( But if I manage to setup a build environment, I might try to fix it myself and make a PR. ;) But I don't know the jellyfin code yet...

Shadowghost commented 1 year ago

I won't have the time to look at it over the next next week, but I'll look at it later on. Thanks for the research and proposals!

h3llrais3r commented 1 year ago

Have been digging inside the code this weekend and I found a solution. Trying it out but it seems promising. 😆 Edit: PR created. 😉