luigi311 / JellyPlex-Watched

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

[BUG] 'Path' error getting/updating Jellyfin watched #86

Closed bl4ckswordsman closed 1 year ago

bl4ckswordsman commented 1 year ago

Describe the bug I get an issue that seems related to #36 , #31 , #25 and #28 with only my Jellyfin Shows library(that spans through multiple directories) and my main user only. Another Jellyfin library (Anime, which also spans through multiple directories) syncs successfully. I've tried changing merge settings and even select only one folder to be included in the library in question, no luck. I feel like it depends on some Jellyfin setting rather than being a bug but I don't know what exactly.

Logs

[ERROR]: Jellyfin: Failed to get watched for user in library Shows, Error: 'Path'
[ERROR]: Traceback (most recent call last):
  File "/app/src/jellyfin.py", line 333, in get_user_library_watched
    episode_dict = get_episode_guids(episode)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/jellyfin.py", line 53, in get_episode_guids
    [x["Path"].split("/")[-1] for x in episode["MediaSources"]]
  File "/app/src/jellyfin.py", line 53, in <listcomp>
    [x["Path"].split("/")[-1] for x in episode["MediaSources"]]
     ~^^^^^^^^
KeyError: 'Path'

...

[ERROR]: Jellyfin: Error updating watched for user in library Shows, 'Path'
[ERROR]: Traceback (most recent call last):
  File "/app/src/jellyfin.py", line 702, in update_user_watched
    episode_location["Path"].split("/")[-1],
    ~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'Path'

Type:

Additional context Add any other context about the problem here.

luigi311 commented 1 year ago

Looks like this is a different issue where the path variable for one of your jellyfin episodes does not exist so it is failing. I'm not sure how that happens but that wasn't something I built a work around for. It should be as simple as check for path if it exists first prior to doing anything with it like I've done with some other variables in other places.

I am currently out the country through so its not something I can implement right now. You can try white listing your libraries one at a time to leave out the one that fails or if you know which one is failing you can add it to the blacklist.

bl4ckswordsman commented 1 year ago

@luigi311 Thanks for the reply! But how come that syncing finishes without errors for 2 other user account pairs, when I black list my own accounts (server admin account)? The library that is giving me issues is shared with all the users, but fails to sync with my own accounts only.

luigi311 commented 1 year ago

Since it does a search for shows/movies that the user has watched and it is failing on only a single user that would be the episode in question is something that only that user has watched. The script doesn't get the path for all episodes for all users only what is watched.

bl4ckswordsman commented 1 year ago

@luigi311 That explains it. Hopefully you can give it a quick look when you get back home, if possible. Thanks for the help!

luigi311 commented 1 year ago

I think i solved the issue, can you try the dev branch and see if that works for you?

bl4ckswordsman commented 1 year ago

I just tried the running the dev branch and it didn't show any errors. Everything looks like it has been synced successfully so the issue seems fixed. Thanks a lot!