cmathews393 / spotify-to-plex

A python script/app to sync Spotify Playlists into Plex (optionally via Lidarr)
GNU General Public License v3.0
34 stars 3 forks source link

Unable to find user for Plex #18

Closed luckycold closed 5 months ago

luckycold commented 5 months ago

Describe the bug Try to run the script with all other items working and even creates the playlist within Plex. But leaves an error that I think causes it to not let itself run in the background on docker.

To Reproduce Steps to reproduce the behavior:

  1. Configure env file
  2. Run docker

Expected behavior Have it run on a regular basis to update a playlist with new songs from Spotify.

Screenshots I have logs here:

2024-01-28 14:36:02.173589-06:00Initiating Plex connection...
2024-01-28 14:36:02.177929-06:00Plex connection succeeded
2024-01-28 14:36:02.177954-06:00Initiating Spotify Connection
2024-01-28 14:36:02.177965-06:00Spotify connection succeeded
2024-01-28 14:36:02.177972-06:00Getting synced Lidarr playlists...
2024-01-28 14:36:02.182999-06:00Playlists grabbed
2024-01-28 14:36:02.183026-06:00['6ioCUPMGoKO9YWX33Sk3bZ']
2024-01-28 14:36:02.183033-06:006ioCUPMGoKO9YWX33Sk3bZ
2024-01-28 14:36:03.336648-06:00Liked Songs  is being processed
2024-01-28 14:36:06.108772-06:00Playlist found, matching and updating: Liked Songs
2024-01-28 14:36:06.155513-06:00<Playlist:11339:Liked-Songs>
2024-01-28 14:36:06.179604-06:00Processed playlist 'Liked Songs'.
2024-01-28 14:36:07.415931-06:00Traceback (most recent call last):
2024-01-28 14:36:07.415959-06:00File "/usr/bin/spotiplex/main.py", line 111, in <module>
2024-01-28 14:36:07.415983-06:00main()
2024-01-28 14:36:07.416007-06:00File "/usr/bin/spotiplex/main.py", line 107, in main
2024-01-28 14:36:07.416074-06:00process_for_user(user.strip(), plex, sp, lidarr_playlists, workercount, replace)
2024-01-28 14:36:07.416095-06:00File "/usr/bin/spotiplex/main.py", line 22, in process_for_user
2024-01-28 14:36:07.416157-06:00plex = plex.switchUser(user)
2024-01-28 14:36:07.416184-06:00^^^^^^^^^^^^^^^^^^^^^
2024-01-28 14:36:07.416193-06:00File "/usr/local/lib/python3.12/site-packages/plexapi/server.py", line 271, in switchUser
2024-01-28 14:36:07.416402-06:00user = user if isinstance(user, MyPlexUser) else self.myPlexAccount().user(user)
2024-01-28 14:36:07.416472-06:00^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-01-28 14:36:07.416481-06:00File "/usr/local/lib/python3.12/site-packages/plexapi/myplex.py", line 659, in user
2024-01-28 14:36:07.416732-06:00raise NotFound(f'Unable to find user {username}')
2024-01-28 14:36:07.416753-06:00plexapi.exceptions.NotFound: Unable to find user luckycold
failed to create fsnotify watcher: too many open files

Desktop (please complete the following information):

cmathews393 commented 5 months ago

Will look into this this evening or tomorrow.

cmathews393 commented 5 months ago

@luckycold Can you confirm your Plex username is correct? I can build in error handling for if the user doesn't exist, but that's not going to solve the problem if your user doesn't exist. Would also be helpful to see your (redacted) env file as well, just so I can see how you're formatting the usernames

luckycold commented 5 months ago

Yup, here's an image of my user: image And here's an image of my configured env variables (I use TrueNAS scale which just sends the environment variables to the docker image): image image

cmathews393 commented 5 months ago

Hmm, I can't seem to replicate this. Are you the only user on this plex server? And is that the user you're authenticating with? i.e. the user you were logged in with when you grabbed the API key?

cmathews393 commented 5 months ago

@luckycold Please try using the :debug tag on the docker image, and set an env variable DEBUG to True. It should output the list of system accounts on your plex server.

cmathews393 commented 5 months ago

Nevermind, we don't need to do all that. Just remove your user from the list. Just tested on my end. The API by default assumes that you want to sync with the user that you are authing with, USERS should only be used if you have other users that you want to sync to as well.

cmathews393 commented 5 months ago

Will fix this in rewrite, should do a check against authing user and userlist.