-
-
Save murat3/1eace37a6c4a681f19fb044690c2aaac to your computer and use it in GitHub Desktop.
#!/usr/bin/env python | |
# | |
# Description: Copy a named playlist to another user | |
# Author: murat3 | |
# Requires: | |
# - python >=3.9 | |
# - pip >=3.x | |
# - plexapi >=4.x | |
# - plex >=4.x | |
# | |
# Usage: python3 copy-playlist.py | |
# | |
# Tested with Plex 4.69.1 | |
from plexapi.server import PlexServer | |
baseurl = 'http://plexhost:32400' | |
plexAdminToken = 'adminToken' | |
targetUser = 'targetUser' | |
nameOfPlaylistToCopy = 'aPlaylist' | |
plexAdmin = PlexServer(baseurl, plexAdminToken) | |
def main(): | |
aPlaylist = plexAdmin.playlist(nameOfPlaylistToCopy) | |
aPlaylist.copyToUser(targetUser) | |
print('Playlist ' + aPlaylist.title + ' copied to user: ' + targetUser) | |
if __name__ == "__main__": | |
main() | |
print("Done") |
Hi @murat3 that is perfect! Indeed, the token could easily be extracted that way :-) Plexapi is not happy yet however:
plexapi.exceptions.BadRequest: Must include items to add when creating new playlist.
python3 copy-playlist.py
Traceback (most recent call last):
File "copy-playlist.py", line 26, in <module>
main()
File "copy-playlist.py", line 22, in main
plexAdmin.createPlaylist(aPlaylist.title, aPlaylist.items())
File "/usr/local/lib/python3.8/dist-packages/plexapi/server.py", line 491, in createPlaylist
return Playlist.create(
File "/usr/local/lib/python3.8/dist-packages/plexapi/playlist.py", line 417, in create
return cls._create(server, title, items)
File "/usr/local/lib/python3.8/dist-packages/plexapi/playlist.py", line 338, in _create
raise BadRequest('Must include items to add when creating new playlist.')
plexapi.exceptions.BadRequest: Must include items to add when creating new playlist.
Would you happen to have a clue how to add a wildcard to select all items, or perhaps anohter way around this 'BadRequest' please?
https://python-plexapi.readthedocs.io/en/latest/modules/playlist.html#
@bbccdd use the new version; this copies a named playlist to another user; pls check the requirements
Hi @murat3 this is great, but the playlist list presented often has non numeric (hex) identifiers, but the "Select the number of the playlist to copy from" prompt only accepts a numeric. Is there a work around for this?
With the script I can only copy lists created by admin to the manged users. If the other way round, the playlist is not found
What am I doing wrong?
Hi @bbccdd
You can use Chrome Developer tools to inspect the HTTP GET request parameters generated using the Plex Web app, logged in as a non-admin user.
X-Plex-Token is part of the URL GET request.