luigi311 / JellyPlex-Watched

Sync watched between jellyfin and plex locally
GNU General Public License v3.0
394 stars 22 forks source link

TV Shows syncs, Movies do not #31

Closed daveonkels closed 1 year ago

daveonkels commented 1 year ago

Attempting to sync from Jellyfin to Plex and have no issues with TV Shows but the script seems to ignore the Movies sync. I've run a number of variations including explicitly whitelisting Movies and doing a manual mapping of the libraries (Movies:Movies) to no avail. Are there any other adjustments I should be looking at or other ways to debug?

[INFO]: Dryrun: False
[INFO]: User Mapping: {'usernameredacted': 'usernameredacted'}
[INFO]: Library Mapping: {'movies': 'Movies'}
[INFO]: Creating (black/white)lists
[INFO]: Blacklist Library: []
[INFO]: Whitelist Library: ['Movies', 'Movies']
[INFO]: Blacklist Library Type: ['tv shows']
[INFO]: Whitelist Library Type: []
[INFO]: Blacklist Users: []
[INFO]: Whitelist Users: []
[INFO]: Creating server connections
[INFO]: Creating users list
Server 1: plex <src.plex.Plex object at 0x7f32feb76050>
Server 2: jellyfin <src.jellyfin.Jellyfin object at 0x7f32feb75e10>
[INFO]: User list that exist on both servers {'usernameredacted': 'usernameredacted'}
[INFO]: Filtered user list {'usernameredacted': 'usernameredacted'}
[INFO]: Server 1 users: [<MyPlexAccount:usernameredacted:usernameredacted>]
[INFO]: Server 2 users: {'usernameredacted': 'usernameredacted'}
[INFO]: Creating watched lists
[INFO]: Plex: Skipping library TV Shows is not whitelist_library
Plex: Generating watched for usernameredacted in library Movies
[INFO]: Finished creating watched list server 1
[INFO]: Jellyfin: Skipping library Shows is not whitelist_library
[INFO]: Jellyfin: Skipping library Collections is not whitelist_library
Jellyfin: Generating watched for usernameredacted in library Movies
[INFO]: Finished creating watched list server 2
[INFO]: Cleaning Server 1 Watched
[INFO]: library Movies and Movies not found in watched list 2
[INFO]: Removing Movies from usernameredacted because it is empty
[INFO]: Removing usernameredacted from watched list 1 because it is empty
[INFO]: Cleaning Server 2 Watched
[INFO]: Removing usernameredacted from watched list 1 because it is empty
[INFO]: server 1 watched that needs to be synced to server 2:
{}
[INFO]: server 2 watched that needs to be synced to server 1:
{}
Average time: 1.2631806570570916
Looping in 3600.

docker run --rm -it -e LOGFILE="log.log" -e LIBRARY_MAPPING='{ "movies": "Movies" }' -e WHITELIST_LIBRARY="Movies" -e BLACKLIST_LIBRARY_TYPE="TV Shows" -e USER_MAPPING='{ "redacted": "redacted" }' -e SLEEP_DURATION="3600" -e DEBUG_LEVEL="info" -e DRYRUN="False" -e PLEX_TOKEN="redacted" -e PLEX_BASEURL="http://10.10.0.128:32400" -e JELLYFIN_TOKEN="redacted" -e JELLYFIN_BASEURL="https://jellyfin.redacted.com" luigi311/jellyplex-watched:latest

luigi311 commented 1 year ago

Can you try running this with DEBUG_LEVEL="debug"

This will spit out a lot more information but should show us what it finds on the gathering steps and we can see if something is going wrong with my cleaning function.

daveonkels commented 1 year ago

I had that enabled as well but wasn't seeing anything that explained the issue. Here's what is displayed if I leave TV Shows active:

Server 1: plex <src.plex.Plex object at 0x7f9d68b52c90>
Server 2: jellyfin <src.jellyfin.Jellyfin object at 0x7f9d68acb090>
Plex: Generating watched for <<PLEXUSERNAME>> in library Movies
Plex: Generating watched for <<PLEXUSERNAME>> in library TV Shows
Jellyfin: Generating watched for <<JELLYFINUSERNAME>> in library Movies
Jellyfin: Generating watched for <<JELLYFINUSERNAME>> in library Shows
Jellyfin: Generating watched for <<JELLYFINUSERNAME>> in library Collections
[DEBUG]: Server 1 watched: {'cooper2050': {'Movies': [], 'TV Shows': {frozenset({('tmdb', '90669'), ('tvdb', '384429'), ('locations', ('1899',)), ('imdb', 'tt9319668'), ('title', '1899')}): {'Season 1': [{'imdb': 'tt14574184', 'tmdb': '3915213', 'tvdb': '9348590', 'locations': ('1899 - 01x05 - The Calling.mkv',)}]}, frozenset({('tvdb', '279536'),<<REDACTED FOR BREVITY>>{'tvdb': '9342109', 'imdb': 'tt15800778', 'locations': ('The Peripheral - 01x05 - What About Bob.mkv',)}, {'tvdb': '9342110', 'imdb': 'tt15801370', 'locations': ('The Peripheral - 01x06 - Fuck You and Eat Shit.mkv',)}]}, frozenset({('tmdb', '90669'), ('tvdb', '384429'), ('locations', ('1899',)), ('imdb', 'tt9319668'), ('title', '1899')}): {'Season 1': [{'tvdb': '9348590', 'imdb': 'tt14574184', 'locations': ('1899 - 01x05 - The Calling.mkv',)}]}}}}
[ERROR]: Plex: Library Shows not found in library list
[ERROR]: Jellyfin: Library TV Shows not found in library list
Average time: 19.231942122103646
Looping in 3600.0

As you can see it's almost as if it's not seeing any movies, even though it seems to indicate finding the libraries.

luigi311 commented 1 year ago

can you try the dev branch and run it with that debug_level="debug" and post the full log with anything you want redacted still. I found some issues but not sure if your issue was one of them.

daveonkels commented 1 year ago

Thanks - just to confirm, the process to build from the dev branch would be:

git clone --single-branch --branch=dev https://github.com/luigi311/JellyPlex-Watched.git

then cd into the folder and

docker build -t jellyplex-watched .

followed by this to run

docker run --rm -it -e DEBUG_LEVEL="debug" -e DRYRUN="False" -e PLEX_TOKEN="REDACTED" -e PLEX_BASEURL="http://REDACTED" -e JELLYFIN_TOKEN="REDACTED" -e JELLYFIN_BASEURL="https://jellyfin.tarscase.com" jellyplex-watched

If this is the case, my output is fairly similar:

Server 1: plex <src.plex.Plex object at 0x7f7770d4a4d0>
Server 2: jellyfin <src.jellyfin.Jellyfin object at 0x7f7770d219d0>
Plex: Generating watched for REDACTED in library Movies
Plex: Generating watched for REDACTED in library TV Shows
Jellyfin: Generating watched for REDACTED in library Movies
Jellyfin: Generating watched for REDACTED in library Shows
Jellyfin: Generating watched for REDACTED in library Collections
[DEBUG]: Server 1 watched: {'REDACTED': {'Movies': [], 'TV Shows': {frozenset({('imdb', 'tt9319668'), ('locations', ('1899',)), ('title', '1899'), ('tvdb', '384429'), ('tmdb', '90669')}): {'Season 1': [{'imdb': 'tt14574184', 'tmdb': '3915213', 'tvdb': '9348590', 'locations': ('1899 - 01x05 - The Calling.mkv',)}]}, frozenset({('tvdb', '279536'), ('title', 'Billions'), ('tmdb', '62852'), ('locations', ('Billions',)), ('imdb', 'tt4270492')}): {'Season 4': [{'imdb': 'tt8490712', 'tmdb': '1647355', 'tvdb': '6945782', <<REDACTED>> {'tvdb': '9342109', 'imdb': 'tt15800778', 'title': 'What About Bob?', 'locations': ('The Peripheral - 01x05 - What About Bob.mkv',)}, {'tvdb': '9342110', 'imdb': 'tt15801370', 'title': 'Fuck You and Eat Shit', 'locations': ('The Peripheral - 01x06 - Fuck You and Eat Shit.mkv',)}]}, frozenset({('imdb', 'tt9319668'), ('locations', ('1899',)), ('title', '1899'), ('tvdb', '384429'), ('tmdb', '90669')}): {'Season 1': [{'tvdb': '9348590', 'imdb': 'tt14574184', 'title': 'The Calling', 'locations': ('1899 - 01x05 - The Calling.mkv',)}]}}}}
Average time: 18.056319360155612
luigi311 commented 1 year ago

Looks like there was an issue with some of the logging so i fixed that and added way more logging so we should hopefully see what is going on. Go ahead and do a git pull and rebuild the docker image and run your command again and add -e DEBUG="true". You should see a lot more debugging information.

daveonkels commented 1 year ago

So I re-ran the latest build and am happy to share the output but it didn't explain much more. That said, I kept tinkering with the settings - particularly focusing on Jellyfin since the logs indicated there was nothing to match against. Not sure if it was something to do with my Jellyfin setup but on a whim, I renamed my Movie library to Cinema and bam - it worked like a champ! Maybe that unstuck something or maybe your script struggled with libraries of the same name?

luigi311 commented 1 year ago

Theres no reason it shouldnt work with the name Movies. I have my named Movies on both plex and jellyfin can you post the log before the name change just so i can see it.

daveonkels commented 1 year ago

Apologies, I can't recreate the problem now. Renamed the library back to "Movies" and the sync still works for both TV Shows and Movies.

Psu798076 commented 1 year ago

So I think I have the same problem that @daveonkels had previously - and it appears to be due to having multiple folders in each library (as for me, I had the issue with TV Shows as well). I have two folders for Movies (4k and non-4k) and same for TV. And when it does the search, it only returns the top level. When I modify the query for jellyfin_search to include recursive folders, but filtered for either Movie or Series, it seems to work ok (I think)

`jellyfin_search = await self.query( f"/Users/{user_id}/Items"

`jellyfin_search = await self.query( f"/Users/{user_id}/Items"