blacktwin / JBOPS

Just a Bunch Of Plex Scripts
1.7k stars 304 forks source link

Filter argument does not work #288

Closed irodimus closed 3 years ago

irodimus commented 3 years ago

Describe the bug

Using the filter argument in commit https://github.com/blacktwin/JBOPS/commit/96831b59909eeed0f1e4a0525e580e61ebdd6f68 gives error. For example:

python3 playlist_manager.py --jbop random --action update --name "01 Science Fiction" --libraries Movies --limit 50 --filter genre=sci-fi

gives this result:

(genre) was not found in filters list: []

This command was working previously but no longer is. Using Python 3.9.2 and PlexAPI 4.4.1. Please let me know if you need any more information.

blacktwin commented 3 years ago

There was a recent PR merged into PexAPI that is related to search. I'll have to check to see how that PR impacted this script. Thanks for the heads up.

Only change should be, but this is not required yet. filters_lst = list(set([y.key for x in sections if x.type != 'photo' for y in x.filterFields()])) to filters_lst = list(set([y.key for x in sections if x.type != 'photo' for y in x.listFields()]))

Use pip install git+https://github.com/pkkid/python-plexapi to pull the latest PRs. I just checked on my end and your command string works after updating PlexAPI.

irodimus commented 3 years ago

Ok, I did a force upgrade to PlexAPI and it did see 4.5.0 and upgraded it. Reran command afterwards and it did give the deprecation warning but it did update the playlist. Thanks for looking at this. I will close it.

irodimus commented 3 years ago

Seems with PlexAPI 4.5.2, this no longer works. The deprecation warning appears and it errors out now instead of continuing. I did make the change

filters_lst = list(set([y.key for x in sections if x.type != 'photo' for y in x.listFields()]))

and the warning does not come out but it errors with


Traceback (most recent call last):
  File "/Applications/Plex Scripts/Scripts/playlist_manager.py", line 839, in <module>
    share_playlists(selected_playlists, users)
  File "/Applications/Plex Scripts/Scripts/playlist_manager.py", line 538, in share_playlists
    plex.playlist(title).copyToUser(user)
  File "/usr/local/lib/python3.9/site-packages/plexapi/server.py", line 481, in playlist
    return self.fetchItem('/playlists', title=title)
  File "/usr/local/lib/python3.9/site-packages/plexapi/base.py", line 156, in fetchItem
    if self._checkAttrs(elem, **kwargs):
  File "/usr/local/lib/python3.9/site-packages/plexapi/base.py", line 339, in _checkAttrs
    if operator(value, query):
  File "/usr/local/lib/python3.9/site-packages/plexapi/base.py", line 13, in <lambda>
    'exact': lambda v, q: v == q,
  File "/usr/local/lib/python3.9/site-packages/plexapi/base.py", line 418, in __eq__
    return other not in [None, []] and self.key == other.key
AttributeError: 'str' object has no attribute 'key'
blacktwin commented 3 years ago

Works for me. Same PlexAPI version. I've updated the script to use listFields. Do you have an empty non Photo library?

irodimus commented 3 years ago

Recopied the latest commit and retested. Everything worked out fine. Unsure what had gone wrong.