From ca06ec947686aa774acafaf3a4e8ae81f948c481 Mon Sep 17 00:00:00 2001 From: Blacktwin Date: Wed, 25 Jul 2018 12:33:10 -0400 Subject: [PATCH] shebang add CONFIG and ssl --- utility/plex_api_share.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/utility/plex_api_share.py b/utility/plex_api_share.py index db56fce..3c886de 100644 --- a/utility/plex_api_share.py +++ b/utility/plex_api_share.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python ''' Share or unshare libraries. @@ -68,20 +69,32 @@ Usage: ''' -from plexapi.server import PlexServer +from plexapi.server import PlexServer, CONFIG from time import sleep import argparse import requests import json -PLEX_URL = 'http://localhost:32400' -PLEX_TOKEN = 'xxxx' +PLEX_URL = '' +PLEX_TOKEN = '' +PLEX_URL = CONFIG.data['auth'].get('server_baseurl', PLEX_URL) +PLEX_TOKEN = CONFIG.data['auth'].get('server_token', PLEX_TOKEN) DEFAULT_MESSAGE = "Steam is being killed by admin." 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)