From 793092ddc81e6b2f6f5aaef8a1a62cdece6e9da7 Mon Sep 17 00:00:00 2001 From: Blacktwin Date: Thu, 23 Aug 2018 06:29:13 -0400 Subject: [PATCH] CONFIG and SSL --- utility/plex_api_parental_control.py | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/utility/plex_api_parental_control.py b/utility/plex_api_parental_control.py index 344da69..0edaf7d 100644 --- a/utility/plex_api_parental_control.py +++ b/utility/plex_api_parental_control.py @@ -37,19 +37,34 @@ Usage: import argparse +import requests from time import sleep -from plexapi.server import PlexServer +from plexapi.server import PlexServer, CONFIG +MESSAGE = "GET TO BED!" -PLEX_URL = 'http://localhost:32400' -PLEX_TOKEN = 'xxxxxx' -plex = PlexServer(PLEX_URL, PLEX_TOKEN) +PLEX_URL = '' +PLEX_TOKEN = '' +PLEX_URL = CONFIG.data['auth'].get('server_baseurl', PLEX_URL) +PLEX_TOKEN = CONFIG.data['auth'].get('server_token', PLEX_TOKEN) + +sess = requests.Session() +# 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) user_lst = [x.title for x in plex.myPlexAccount().users()] sections_lst = [x.title for x in plex.library.sections()] -MESSAGE = "GET TO BED!" - def share(user, libraries): plex.myPlexAccount().updateFriend(user=user, server=plex, sections=libraries)