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

Unable to find Libraries after using PlexApi based python script. #1333

Open
amanjosan2008 opened this issue Jan 4, 2024 · 5 comments
Open

Comments

@amanjosan2008
Copy link

amanjosan2008 commented Jan 4, 2024

Describe the Bug

The Libraries disappear from Plex WebUI and Apps everytime I use a PlexApi script. However I dont see any errors in Plex service or logs. The Libraries appear after I restart the Plex Service, which is a bit tedious to do every time.

Ths issue specifically come after runng the "switchUser" class from PlexServer:
userPlex = plex.switchUser("Normal User")

rn_image_picker_lib_temp_362c1155-56af-4c0d-b9b5-dbb3968b579d

Code Snippets

from plexapi.server import PlexServer

baseurl = 'http://192.168.1.1:32400'
token = 'xxxxxxxxxxxxxx'
plex = PlexServer(baseurl, token)
userPlex = plex.switchUser("MyUser")


library = ['My Movies','Tv Shows']

for lib in library:
    print(lib,'\n')
    movies = userPlex.library.section(lib)
    for video in movies.search(userRating=1):
        print("Deleting: ", video.title, "Rating: ", video.userRating)
        print(video.locations)
        #video.delete

Expected Behavior

Plex Libraries should not disappear after running plexapi's switchuser function.

Additional Context

No response

Operating System and Version

Raspbian GNU/Linux 11 (bullseye) Kernel 6.1.47-v8+ aarch64 GNU/Linux

Plex Media Server Version

Version 4.116.1

Python Version

Python 3.9.2

PlexAPI Version

4.15.7

@blacktwin
Copy link
Collaborator

I'm not able to reproduce this issue with a Home, Managed, or Shared User. Might be something else is going on. Is this a Home, Managed, or Shared user account?

Also you won't be able to delete anything while being "signed-in" as a Home, Managed or Shared user because those accounts do not have permission to delete. You would need to capture the ratingKey of the video then use your admin's plex instance delete the video.

@JonnyWong16
Copy link
Collaborator

I'm 100% certain this has nothing to do with using the Python PlexAPI library.

Something else is going wrong with your Plex server/Plex account.

@amanjosan2008
Copy link
Author

amanjosan2008 commented Jan 8, 2024

This user is a managed user.
However, the issue is not with the deletion permissions.

The problem occurs even when listing the media.
I tried the same in the IDE, the issue starts at the same instance when I ran the -> plex.switchUser("MyUser") line:

from plexapi.server import PlexServer

baseurl = 'http://192.168.1.1:32400'
token = 'xxxxxxxxxxxxxx'
plex = PlexServer(baseurl, token)
userPlex = plex.switchUser("MyUser")

I also suspect something wrong with some Plex config on my server/account, but not able to find any logs.

@jjlawren
Copy link
Collaborator

jjlawren commented Jan 8, 2024

Are you sure you mean to switch the user on the PlexServer instance? I'd expect you'd want to switch it on a client.

@amanjosan2008
Copy link
Author

All I want to do is to get the Rating for media given by user "MyUser". The above code is working fine otherwise. Its just the Libraries that disappear in WebUIs & the Plex service becomes unreachable for the Apps on FireStick & TV, thats the issue. I need to restart the service in Plex Server to make it work again. Is this not the recommended/supported way to get ratings for users?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants