blacktwin / JBOPS

Just a Bunch Of Plex Scripts
1.66k stars 308 forks source link

Error when trying media manager #362

Closed cyturralde closed 1 year ago

cyturralde commented 1 year ago

Using code python "\media-manager.py" --libraries "*library*" --select watched --users *user* --action delete

I get the error below. I am running this through a bat file if that matters.

Finding watched items from user: username Checking library: 'library' watch statuses... The following items were added before None and marked for deletion. Traceback (most recent call last): File "\media-manager.py", line 774, in plex_deletion(watched_by_all, libraries, opts.toggleDeletion) File "\media-manager.py", line 325, in plex_deletion section = plex.library.sectionByID(_library.key) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Home PC\AppData\Local\Programs\Python\Python311\Lib\site-packages\plexapi\library.py", line 84, in sectionByID raise NotFound(f'Invalid library sectionID: {sectionID}') from None plexapi.exceptions.NotFound: Invalid library sectionID: 9

blacktwin commented 1 year ago

Seems like Tautulli and Plex are not in sync. Tautulli thinks there is a library with ID 9 but Plex says no. Any changes to your libraries? You may need to run this https://gist.github.com/JonnyWong16/f554f407832076919dc6864a78432db2

cyturralde commented 1 year ago

I just tried that..I then ran it again and got this:

Finding watched items from user: *user*
Checking library: '*library*' watch statuses...
The following items were added before None and marked for deletion.
Traceback (most recent call last):
  File "\media-manager.py", line 774, in <module>
    plex_deletion(watched_by_all, libraries, opts.toggleDeletion)
  File "\media-manager.py", line 325, in plex_deletion
    section = plex.library.sectionByID(_library.key)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Home PC\AppData\Local\Programs\Python\Python311\Lib\site-packages\plexapi\library.py", line 84, in sectionByID
    raise NotFound(f'Invalid library sectionID: {sectionID}') from None
plexapi.exceptions.NotFound: Invalid library sectionID: 9
blacktwin commented 1 year ago

What do you see when you go to http://TAUTULLI_IP:PORT/library?section_id=9 in Tautulli?

What do you see when you go to https://app.plex.tv/desktop/#!/media/YOUR_SERVER_MACHINE_ID/com.plexapp.plugins.library?source=9

cyturralde commented 1 year ago

Both of those pull up the correct corresponding libraries.

cyturralde commented 1 year ago

@blacktwin just curious if you had any other thoughts or ideas?

blacktwin commented 1 year ago

On line 325 Change: section = plex.library.sectionByID(_library.key) to section = plex.library.sectionByID(int(_library.key))

and see if that fixes it.

cyturralde commented 1 year ago

That seems to of fixed it. Thanks for all the help!

dama-de commented 7 months ago

I've just stumbled upon the same error. It still needs to be fixed in the repo. @blacktwin