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

2-way sync maybe possible now? #20

Closed
Andy2244 opened this issue Jun 10, 2022 · 15 comments
Closed

2-way sync maybe possible now? #20

Andy2244 opened this issue Jun 10, 2022 · 15 comments
Labels
enhancement New feature or request

Comments

@Andy2244
Copy link
Contributor

Andy2244 commented Jun 10, 2022

With the higher accuracy, maybe a 2-way sync like the trakt plugin is now possible?

Maybe there is a somewhat reasonable way to-do this now, its just super convienent to have all your watched status in trakt and simply do a sync on a fresh install, so everything is back where you left.

So for normal shows/movies using the trakt plugin i dont have to care about any backup or library state, i can just reinstall the server point it to my libs and via a trakt resync all watched states are set to where i left off.

Would be super cool to have this also for Anime, but i understand that this can be more complex to get right.

@vosmiic
Copy link
Owner

vosmiic commented Jun 10, 2022

So instead of doing an "outwards" sync (Jellyfin -> AniList/MAL/Kitsu), we sync the Jellyfin library to a provider (AniList/MAL/Kitsu -> Jellyfin)?
This has been requested before here #12.
While it wasn't exactly the original idea of the plugin, I still feel like it falls into the same realm.
We could even make it an optional scheduled event, for those who update their AniList/MAL/Kitsu manually outside of Jellyfin.
I can't see how it would be that difficult to achieve, simply retrieve the users complete/in progress list and update the Jellyfin library.
I'll look into it and keep you updated.

@Andy2244
Copy link
Contributor Author

Andy2244 commented Jun 10, 2022

The main issue is you need to-be very carefully how/what you sync and also offer/study the settings options the trakt plugin has.

There can be catastrophic cases, where you wrongly sync the "unwatched" state from remote to local library or vice-versa and than quickly via a scheduled task, resync this new bad "unwatched" state back to the external list, basically wiping your watched states.

To prevent this case all trakt plugins by default disable remote->local "unwatched" sync via settings and also arrange the update jobs, so that the user has a chance to fix setting issues, before a full resync happens.

So by default you want the plugin to handle mainly "watched" states between local<->remote lists and via settings allow certain "unwatched" state combinations.

As example, the trakt plugin has specific settings to only set remote "watched/unwatched" if the user manually set the state. This is safer, since we detect a specific user toggled state change instead of doing some general assumptions on the whole library.

So if you don't use the trakt plugin already, i strongly recommend to check it out and check what settings combinations it offers, so you can avoid running into those catastrophic cases. We want safe defaults and carefully worded settings, similar to trakt so users quickly understand whats happening.

@vosmiic vosmiic added this to todo in general ideas Jun 10, 2022
@Andy2244
Copy link
Contributor Author

@vosmiic btw i took the liberty to add the plugin to the official documentation: jellyfin-archive/jellyfin-docs#675

@vosmiic
Copy link
Owner

vosmiic commented Jun 11, 2022

btw i took the liberty to add the plugin to the official documentation

Ah great, thanks. I think we are now in a comfortable enough position to have it there.

@Nocifer
Copy link

Nocifer commented Jun 11, 2022

Just as a FYI, #12 isn't really about what @Andy2244 is asking for here, which is importing watch status from a remote Trakt-like third-party provider (i.e. AniList/MAL/Kitsu -> Jellyfin) but rather an extended functionality of what Ani-Sync already does, which is exporting watch status to a third-party provider (i.e. Jellyfin -> AniList/MAL/Kitsu) but without the hard requirement that I must first initiate playback of an anime for AniSync to scan it and update its remote status.

My issue (and I'm pretty certain I'm far from the only one affected) is that many of my anime were already watched or in various states of in medias res before I ever installed AniSync, but I'd just never bothered to manually update my MAL profile. So what I'd love for AniSync to be able to do, and what I asked for in #12, would be that it be able to scan my local Jellyfin library, find which anime I have already watched and which shows I'm currently watching, and then update my MAL profile accordingly. And if it could also add my completely untouched anime to the "plan to watch" category, that would be even more awesome.

After this has been done, then adding what @Andy2244 is actually asking for, i.e. the ability to also import watch state from MAL et al to Jellyfin, would be the cherry on top.

@Andy2244
Copy link
Contributor Author

I kinda included your scenario, its just a subpart of what a full 2-way sync does.

@Nocifer
Copy link

Nocifer commented Jun 11, 2022

I know, I was replying to @vosmiic here:

So instead of doing an "outwards" sync (Jellyfin -> AniList/MAL/Kitsu), we sync the Jellyfin library to a provider (AniList/MAL/Kitsu -> Jellyfin)?
This has been requested before here #12.

"This" isn't what has been requested in #12 :)

@vosmiic
Copy link
Owner

vosmiic commented Jun 11, 2022

"This" isn't what has been requested in #12 :)

Yeah sorry I got a bit confused.
I think I understand what would like to be achieved here, as it has been said before we would like both way sync between Jellyfin and the providers.
I also understand what @Andy2244 said with being careful how we handle it. Need to make sure it doesn't turn into a nasty loop of updating each others lists and end up with broken watch statuses on both sides. I can see that you explained how the trakt plugin handles it, and it seems to be the best method.
I'll take all of this into account when implementing these changes.

@vosmiic vosmiic moved this from todo to doing in general ideas Jun 16, 2022
@vosmiic vosmiic added the enhancement New feature or request label Jun 17, 2022
@vosmiic
Copy link
Owner

vosmiic commented Jun 20, 2022

Hitting into some trouble syncing Jellyfin from the providers (AniList/MAL/Kitsu -> Jellyfin).
As most of the APIs don't contain the season number, we can't actually tell what season the user is on. Luckily each item in the providers database is a separate season.
The obvious way to accomplish this is to get the users watch list from the appropriate provider, get the IDs of the anime in said list and then run them through the anime offline database to get the AniDB ID and AniList ID of each season (if we are not using it as the selected provider to sync from) and then cross reference that to Jellyfin's database to see which seasons we have locally that match the IDs (we cannot use the local anime list XML file as that would only give us a TVDB ID which is bound to the series, not the season).
Only problem being is that Jellyfin does not seem to store season provider IDs, at least not for me. It stores the series provider IDs, but not separate seasons.
The only time that we will get a match with a provider ID from the Jellyfin database is if we are working with the first season of a show from the users watch list.
Could someone please confirm that it isn't only me not having any provider IDs (labelled "external IDs" in the Jellyfin interface) for seasons? I have tried running the metadata fetcher multiple times and I don't get any extra provider IDs for seasons. I get a TVDB ID, but when I cross reference it with the XML file I get no results. I'm not entirely sure what the ID represents as I even tried looking it up on TVDB but got no results.

@Andy2244
Copy link
Contributor Author

Andy2244 commented Jun 21, 2022

As most of the APIs don't contain the season number

Thats tobe expected as most Anime has no "official" seasons, so have no season numbers. Those are just made up by
TVDB/TMDB based on air dates.

Only problem being is that Jellyfin does not seem to store season provider IDs, at least not for me. It stores the series provider IDs, but not separate seasons.

Same for me, i think tvdb does not have separate season id's for a series?

So here is how this can work, lets use "Megalo Box 2nd" aka Second seasons as example:

  • get the AniList ID via api/watched/watching list https://anilist.co/anime/113359/MEGALOBOX-2-NOMAD/ so 113359
  • get the AniDB id via xrossref the AniList id 113359 from the offline list: we get 15271
  • find the AniDB entry in the anime-list.xml <anime anidbid="15271" tvdbid="341437" defaulttvdbseason="2">
  • check if there is a series for the user libs the plugin handles with a tvdbid="341437" main id
    • match the defaulttvdbseason season numbers and try find the season by number
    • sync watched states of episodes, accounting for possible episode offset's

we may need to also filter by ova/movies/special stuff.
The full Anime offline db file has those infos:

      "title": "Nomad: Megalo Box 2",
      "type": "TV",
      "episodes": 13,
      "status": "FINISHED",
      "animeSeason": {
        "season": "SPRING",
        "year": 2021 }

So i think the type, animeSeason can be used to ensure we actually match a series or movie, just check for examples.

@vosmiic
Copy link
Owner

vosmiic commented Jun 21, 2022

find the AniDB entry in the anime-list.xml

Good idea, yeah this should work. Feels like its really inefficient but we have to work with what we have.

we may need to also filter by ova/movies/special stuff

Luckily AniList uses GraphQL so we can filter our results on the API side. Much more efficient. But we will have to manually filter by checking the anime offline db with MAL.

@vosmiic
Copy link
Owner

vosmiic commented Jun 23, 2022

I have now got it updating shows from a users AniList watched list.
Just need to clean it up and get it working with other providers.

@vosmiic
Copy link
Owner

vosmiic commented Jul 5, 2022

Forgot to update here recently but I believe I have got updating the Jellyfin library from providers anime list fully working.
I have added a warning to let users know that the feature is in "alpha" and that it may disrupt their Jellyfin libraries.
Next to do is to get the other direction working (Jellyfin to provider anime list).

@vosmiic
Copy link
Owner

vosmiic commented Jul 19, 2022

This feature is now fully implemented on master.
Just doing some testing and then I should be able to release a new version with this functionality included.

@vosmiic
Copy link
Owner

vosmiic commented Jul 21, 2022

Okay, the update with this has been released. Currently testing it locally and I am not hitting into any trouble.
That being said, I would be very careful using this - it could quite easily mess up your Jellyfin library or provider watch lists.

@vosmiic vosmiic closed this as completed Jul 21, 2022
@vosmiic vosmiic moved this from doing to done in general ideas Jul 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: done
Development

No branches or pull requests

3 participants