Server Version#: 1.20.5.3600
Player Version#: Chrome Web
I’ve been using python scripts to manage my Plex library for well over a year now with no issues. Specifically, I have cron jobs to download around 60 podcasts a day on average. All 60 get played before the day is over, the cron scripts remove the played podcasts from the daily playlists (which are also created by cron jobs).
After upgrading a few days and also yesterday to the latest server version, I noticed that my scripts were crashing on playlist.delete(). My script calls playlist.delete() when all items have been removed from a playlist and there’s nothing left.
With the latest PMS, the playlist doesn’t delete. The script crashes with the following error message:
Traceback (most recent call last):
File "/usr/local/plexScripts/clean", line 47, in <module>
playlist.delete()
File "/usr/lib/python2.7/site-packages/plexapi/playlist.py", line 123, in delete
return self._server.query(self.key, method=self._server._session.delete)
File "/usr/lib/python2.7/site-packages/plexapi/server.py", line 348, in query
raise BadRequest('(%s) %s; %s %s' % (response.status_code, codename, response.url, errtext))
plexapi.exceptions.BadRequest: (204) no_content; http://plex.swiftlab.local:32400/playlists/125812
The relevant part of my script looks like this:
for playlist in plex.playlists():
if ((u"Podcast" in playlist.title ) or (playlist.title in podcasts)):
for item in playlist.items():
if ((item.viewCount > 0) or (item.userRating > 0) or (item.ratingKey in ids)):
print("[ {} ] removing playlist item [{}] {}".format(playlist.title, item.artist().title, item.title))
playlist.removeItem(item)
if (len(playlist.items()) == 0):
print("[ {} ] playlist now empty, deleting".format(playlist.title))
playlist.delete()
It basically goes through a playlist, checks the viewCount for each item. If the item has been played, delete it from the playlist, if the playlist is empty, delete the playlist.
This has all worked fine for over a year now. Upgraded the server seems to have broke it. Is there a workaround? Has playlist.delete() been deprecated or replaced with something else?