Skip to content

Instantly share code, notes, and snippets.

@miigotu
Created January 3, 2016 18:21
Show Gist options
  • Save miigotu/cfc5a83b3d1eb6cd70cf to your computer and use it in GitHub Desktop.
Save miigotu/cfc5a83b3d1eb6cd70cf to your computer and use it in GitHub Desktop.
diff --git a/gui/slick/views/config_notifications.mako b/gui/slick/views/config_notifications.mako
index 98953e2..a3cd656 100644
--- a/gui/slick/views/config_notifications.mako
+++ b/gui/slick/views/config_notifications.mako
@@ -294,6 +294,15 @@
</span>
</label>
</div>
+ <div class="field-pair">
+ <label for="plex_https_required">
+ <span class="component-title">HTTPS Required:</span>
+ <span class="component-desc">
+ <input type="checkbox" name="plex_https_required" id="plex_https_required" ${('', 'checked="checked"')[bool(sickbeard.PLEX_HTTPS_REQUIRED)]}/>
+ <p>send a notification when a download finishes ?</p>
+ </span>
+ </label>
+ </div>
<div class="component-group" style="padding: 0; min-height: 130px">
<div class="field-pair">
<label for="plex_username">
diff --git a/sickbeard/__init__.py b/sickbeard/__init__.py
index 6e6edb0..711d363 100644
--- a/sickbeard/__init__.py
+++ b/sickbeard/__init__.py
@@ -355,6 +355,7 @@ PLEX_PASSWORD = None
USE_PLEX_CLIENT = False
PLEX_CLIENT_USERNAME = None
PLEX_CLIENT_PASSWORD = None
+PLEX_HTTPS_REQUIRED = None
USE_EMBY = False
EMBY_HOST = None
@@ -587,7 +588,7 @@ def initialize(consoleLogging=True):
KODI_UPDATE_LIBRARY, KODI_HOST, KODI_USERNAME, KODI_PASSWORD, BACKLOG_FREQUENCY, \
USE_TRAKT, TRAKT_USERNAME, TRAKT_ACCESS_TOKEN, TRAKT_REFRESH_TOKEN, TRAKT_REMOVE_WATCHLIST, TRAKT_SYNC_WATCHLIST, TRAKT_REMOVE_SHOW_FROM_SICKRAGE, TRAKT_METHOD_ADD, TRAKT_START_PAUSED, traktCheckerScheduler, TRAKT_USE_RECOMMENDED, TRAKT_SYNC, TRAKT_SYNC_REMOVE, TRAKT_DEFAULT_INDEXER, TRAKT_REMOVE_SERIESLIST, TRAKT_TIMEOUT, TRAKT_BLACKLIST_NAME, \
USE_PLEX, PLEX_NOTIFY_ONSNATCH, PLEX_NOTIFY_ONDOWNLOAD, PLEX_NOTIFY_ONSUBTITLEDOWNLOAD, PLEX_UPDATE_LIBRARY, USE_PLEX_CLIENT, PLEX_CLIENT_USERNAME, PLEX_CLIENT_PASSWORD, \
- PLEX_SERVER_HOST, PLEX_SERVER_TOKEN, PLEX_HOST, PLEX_USERNAME, PLEX_PASSWORD, MIN_BACKLOG_FREQUENCY, SKIP_REMOVED_FILES, ALLOWED_EXTENSIONS, \
+ PLEX_SERVER_HOST, PLEX_SERVER_TOKEN, PLEX_HOST, PLEX_USERNAME, PLEX_PASSWORD, PLEX_HTTPS_REQUIRED, MIN_BACKLOG_FREQUENCY, SKIP_REMOVED_FILES, ALLOWED_EXTENSIONS, \
USE_EMBY, EMBY_HOST, EMBY_APIKEY, \
showUpdateScheduler, __INITIALIZED__, INDEXER_DEFAULT_LANGUAGE, EP_DEFAULT_DELETED_STATUS, LAUNCH_BROWSER, TRASH_REMOVE_SHOW, TRASH_ROTATE_LOGS, SORT_ARTICLE, showList, loadingShowList, \
NEWZNAB_DATA, NZBS, NZBS_UID, NZBS_HASH, INDEXER_DEFAULT, INDEXER_TIMEOUT, USENET_RETENTION, TORRENT_DIR, \
@@ -1000,6 +1001,7 @@ def initialize(consoleLogging=True):
USE_PLEX_CLIENT = bool(check_setting_int(CFG, 'Plex', 'use_plex_client', 0))
PLEX_CLIENT_USERNAME = check_setting_str(CFG, 'Plex', 'plex_client_username', '', censor_log=True)
PLEX_CLIENT_PASSWORD = check_setting_str(CFG, 'Plex', 'plex_client_password', '', censor_log=True)
+ PLEX_HTTPS_REQUIRED = bool(check_setting_int(CFG, 'Plex', 'plex_https_required', 0))
USE_EMBY = bool(check_setting_int(CFG, 'Emby', 'use_emby', 0))
EMBY_HOST = check_setting_str(CFG, 'Emby', 'emby_host', '')
@@ -1905,6 +1907,11 @@ def save_config():
new_config['Plex']['plex_username'] = PLEX_USERNAME
new_config['Plex']['plex_password'] = helpers.encrypt(PLEX_PASSWORD, ENCRYPTION_VERSION)
+ new_config['Plex']['use_plex_client'] = int(USE_PLEX_CLIENT)
+ new_config['Plex']['plex_client_username'] = PLEX_CLIENT_USERNAME
+ new_config['Plex']['plex_client_password'] = helpers.encrypt(PLEX_CLIENT_PASSWORD, ENCRYPTION_VERSION)
+ new_config['Plex']['plex_https_required'] = int(PLEX_HTTPS_REQUIRED)
+
new_config['Emby'] = {}
new_config['Emby']['use_emby'] = int(USE_EMBY)
new_config['Emby']['emby_host'] = EMBY_HOST
diff --git a/sickbeard/notifiers/plex.py b/sickbeard/notifiers/plex.py
index c3c2e12..0152200 100644
--- a/sickbeard/notifiers/plex.py
+++ b/sickbeard/notifiers/plex.py
@@ -68,7 +68,7 @@ class PLEXNotifier(object):
enc_command = urllib.urlencode(command)
logger.log(u'PLEX: Encoded API command: ' + enc_command, logger.DEBUG)
- url = u'http://%s/xbmcCmds/xbmcHttp/?%s' % (host, enc_command)
+ url = u'http%s://%s/xbmcCmds/xbmcHttp/?%s' % (('', 's')[sickbeard.PLEX_HTTPS_REQUIRED], host, enc_command)
try:
req = urllib2.Request(url)
# if we have a password, use authentication
@@ -227,7 +227,7 @@ class PLEXNotifier(object):
hosts_failed = []
for cur_host in host_list:
- url = 'http://%s/library/sections%s' % (cur_host, token_arg)
+ url = 'http%s://%s/library/sections%s' % (('', 's')[sickbeard.PLEX_HTTPS_REQUIRED], cur_host, token_arg)
try:
xml_tree = etree.parse(urllib.urlopen(url))
media_container = xml_tree.getroot()
@@ -269,7 +269,7 @@ class PLEXNotifier(object):
host_list = []
for section_key, cur_host in hosts_try.iteritems():
- url = 'http://%s/library/sections/%s/refresh%s' % (cur_host, section_key, token_arg)
+ url = 'http%s://%s/library/sections/%s/refresh%s' % (('', 's')[sickbeard.PLEX_HTTPS_REQUIRED], cur_host, section_key, token_arg)
try:
force and urllib.urlopen(url)
host_list.append(cur_host)
diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py
index e8ec5ad..b7825b9 100644
--- a/sickbeard/webserve.py
+++ b/sickbeard/webserve.py
@@ -4745,7 +4745,7 @@ class ConfigNotifications(Config):
plex_notify_onsubtitledownload=None, plex_update_library=None,
plex_server_host=None, plex_server_token=None, plex_host=None, plex_username=None, plex_password=None,
use_plex_client=None, plex_client_username=None, plex_client_password=None,
- use_emby=None, emby_host=None, emby_apikey=None,
+ plex_https_required=None, use_emby=None, emby_host=None, emby_apikey=None,
use_growl=None, growl_notify_onsnatch=None, growl_notify_ondownload=None,
growl_notify_onsubtitledownload=None, growl_host=None, growl_password=None,
use_freemobile=None, freemobile_notify_onsnatch=None, freemobile_notify_ondownload=None,
@@ -4811,6 +4811,7 @@ class ConfigNotifications(Config):
sickbeard.USE_PLEX_CLIENT = config.checkbox_to_value(use_plex)
sickbeard.PLEX_CLIENT_USERNAME = plex_username
sickbeard.PLEX_CLIENT_PASSWORD = plex_password
+ sickbeard.PLEX_HTTPS_REQUIRED = plex_https_required
sickbeard.USE_EMBY = config.checkbox_to_value(use_emby)
sickbeard.EMBY_HOST = config.clean_host(emby_host)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment