Skip to content

Instantly share code, notes, and snippets.

@blacktwin
Last active July 23, 2017 21:09
Show Gist options
  • Save blacktwin/1e678fa96809637f8d4f59c579c17972 to your computer and use it in GitHub Desktop.
Save blacktwin/1e678fa96809637f8d4f59c579c17972 to your computer and use it in GitHub Desktop.
Create playlist of random albums.
# pip install plexapi
from plexapi.server import PlexServer
import random
### Edit Settings ###
PLEX_URL = 'http://localhost:32400'
TOKEN = 'xxxx'
MUSIC_LIBRARY = 'Music'
PLAYLIST_TITLE = 'Random Album Playlist'
TOTAL_ALBUMS = 6
###/ Edit Settings ###
plex = PlexServer(PLEX_URL, TOKEN)
tmp_lst = []
artists = plex.library.section(MUSIC_LIBRARY).all()
for artist in artists:
tmp_lst += artist.albums()
play_list = random.sample(tmp_lst, TOTAL_ALBUMS)
plex.createPlaylist(PLAYLIST_TITLE, play_list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment