From 8d7f0fc11b4e8e9ad8d6ad6a29dc8e91cd9977a5 Mon Sep 17 00:00:00 2001 From: Blacktwin Date: Thu, 23 Aug 2018 06:32:52 -0400 Subject: [PATCH] CONFIG and SSL --- utility/plex_popular_playlist.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/utility/plex_popular_playlist.py b/utility/plex_popular_playlist.py index d1bb9ed..03a4b11 100644 --- a/utility/plex_popular_playlist.py +++ b/utility/plex_popular_playlist.py @@ -18,13 +18,15 @@ optional arguments: import requests -from plexapi.server import PlexServer +from plexapi.server import PlexServer, CONFIG import argparse import random # Edit -PLEX_URL = 'http://localhost:32400' -PLEX_TOKEN = 'xxxxxx' +PLEX_URL = '' +PLEX_TOKEN = '' +PLEX_URL = CONFIG.data['auth'].get('server_baseurl', PLEX_URL) +PLEX_TOKEN = CONFIG.data['auth'].get('server_token', PLEX_TOKEN) LIBRARY_EXCLUDE = ['Audio Books', 'Podcasts', 'Soundtracks'] DEFAULT_NAME = 'Popular Music Playlist' @@ -32,7 +34,17 @@ DEFAULT_NAME = 'Popular Music Playlist' # /Edit sess = requests.Session() -sess.verify = False +# Ignore verifying the SSL certificate +sess.verify = False # '/path/to/certfile' +# If verify is set to a path to a directory, +# the directory must have been processed using the c_rehash utility supplied +# with OpenSSL. +if sess.verify is False: + # Disable the warning that the request is insecure, we know that... + import urllib3 + + urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) + plex = PlexServer(PLEX_URL, PLEX_TOKEN, session=sess) music_sections = [x.title for x in plex.library.sections() if x.type == 'artist' and x.title not in LIBRARY_EXCLUDE]