Last active
July 23, 2017 21:09
-
-
Save blacktwin/1e678fa96809637f8d4f59c579c17972 to your computer and use it in GitHub Desktop.
Create playlist of random albums.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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