1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-24 08:48:50 -05:00

Added support for Plex Media Center updates with Auth Token.

This because PMS does not allow unauthed connections when using Plex Home
This commit is contained in:
Joris Vandalon 2015-01-15 11:05:10 +01:00
parent 33e95870e0
commit 03b17d63e0
4 changed files with 25 additions and 3 deletions

View File

@ -220,6 +220,20 @@
<span class="component-desc">host running Plex Media Server (eg. 192.168.1.100:32400)</span>
</label>
</div>
<div class="field-pair">
<label for="plex_server_token">
<span class="component-title">Plex Media Server Auth Token</span>
<input type="text" name="plex_server_token" id="plex_server_token" value="$sickbeard.PLEX_SERVER_TOKEN" class="form-control input-sm input250" />
</label>
<label>
<span class="component-title">&nbsp;</span>
<span class="component-desc">Auth Token used by plex</span>
</label>
<label>
<span class="component-title">&nbsp;</span>
<span class="component-desc">(<a href="<%= anon_url('https://support.plex.tv/hc/en-us/articles/204059436-Finding-your-account-token-X-Plex-Token') %>" rel="noreferrer" onclick="window.open(this.href, '_blank'); return false;"><u>Finding your account token</u></a>)</span>
</label>
</div>
<div class="field-pair">
<label for="plex_host">
<span class="component-title">Plex Client IP:Port</span>

View File

@ -301,6 +301,7 @@ PLEX_NOTIFY_ONDOWNLOAD = False
PLEX_NOTIFY_ONSUBTITLEDOWNLOAD = False
PLEX_UPDATE_LIBRARY = False
PLEX_SERVER_HOST = None
PLEX_SERVER_TOKEN = None
PLEX_HOST = None
PLEX_USERNAME = None
PLEX_PASSWORD = None
@ -493,7 +494,7 @@ def initialize(consoleLogging=True):
KODI_UPDATE_LIBRARY, KODI_HOST, KODI_USERNAME, KODI_PASSWORD, BACKLOG_FREQUENCY, \
USE_TRAKT, TRAKT_USERNAME, TRAKT_PASSWORD, TRAKT_API, TRAKT_REMOVE_WATCHLIST, TRAKT_USE_WATCHLIST, TRAKT_METHOD_ADD, TRAKT_START_PAUSED, traktCheckerScheduler, TRAKT_USE_RECOMMENDED, TRAKT_SYNC, TRAKT_DEFAULT_INDEXER, TRAKT_REMOVE_SERIESLIST, \
USE_PLEX, PLEX_NOTIFY_ONSNATCH, PLEX_NOTIFY_ONDOWNLOAD, PLEX_NOTIFY_ONSUBTITLEDOWNLOAD, PLEX_UPDATE_LIBRARY, \
PLEX_SERVER_HOST, PLEX_HOST, PLEX_USERNAME, PLEX_PASSWORD, DEFAULT_BACKLOG_FREQUENCY, MIN_BACKLOG_FREQUENCY, BACKLOG_STARTUP, SKIP_REMOVED_FILES, \
PLEX_SERVER_HOST, PLEX_SERVER_TOKEN, PLEX_HOST, PLEX_USERNAME, PLEX_PASSWORD, DEFAULT_BACKLOG_FREQUENCY, MIN_BACKLOG_FREQUENCY, BACKLOG_STARTUP, SKIP_REMOVED_FILES, \
showUpdateScheduler, __INITIALIZED__, LAUNCH_BROWSER, UPDATE_SHOWS_ON_START, 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, \
QUALITY_DEFAULT, FLATTEN_FOLDERS_DEFAULT, SUBTITLES_DEFAULT, STATUS_DEFAULT, DAILYSEARCH_STARTUP, \
@ -813,6 +814,7 @@ def initialize(consoleLogging=True):
PLEX_NOTIFY_ONSUBTITLEDOWNLOAD = bool(check_setting_int(CFG, 'Plex', 'plex_notify_onsubtitledownload', 0))
PLEX_UPDATE_LIBRARY = bool(check_setting_int(CFG, 'Plex', 'plex_update_library', 0))
PLEX_SERVER_HOST = check_setting_str(CFG, 'Plex', 'plex_server_host', '')
PLEX_SERVER_TOKEN = check_setting_str(CFG, 'Plex', 'plex_server_token', '')
PLEX_HOST = check_setting_str(CFG, 'Plex', 'plex_host', '')
PLEX_USERNAME = check_setting_str(CFG, 'Plex', 'plex_username', '', censor_log=True)
PLEX_PASSWORD = check_setting_str(CFG, 'Plex', 'plex_password', '', censor_log=True)
@ -1666,6 +1668,7 @@ def save_config():
new_config['Plex']['plex_notify_onsubtitledownload'] = int(PLEX_NOTIFY_ONSUBTITLEDOWNLOAD)
new_config['Plex']['plex_update_library'] = int(PLEX_UPDATE_LIBRARY)
new_config['Plex']['plex_server_host'] = PLEX_SERVER_HOST
new_config['Plex']['plex_server_token'] = PLEX_SERVER_TOKEN
new_config['Plex']['plex_host'] = PLEX_HOST
new_config['Plex']['plex_username'] = PLEX_USERNAME
new_config['Plex']['plex_password'] = helpers.encrypt(PLEX_PASSWORD, ENCRYPTION_VERSION)

View File

@ -96,6 +96,8 @@ class PLEXNotifier(KODINotifier):
logger.INFO)
url = "http://%s/library/sections" % sickbeard.PLEX_SERVER_HOST
if sickbeard.PLEX_SERVER_TOKEN:
url += "/?X-Plex-Token=" + sickbeard.PLEX_SERVER_TOKEN
try:
xml_sections = minidom.parse(urllib.urlopen(url))
except IOError, e:
@ -110,6 +112,8 @@ class PLEXNotifier(KODINotifier):
for s in sections:
if s.getAttribute('type') == "show":
url = "http://%s/library/sections/%s/refresh" % (sickbeard.PLEX_SERVER_HOST, s.getAttribute('key'))
if sickbeard.PLEX_SERVER_TOKEN:
url += "/?X-Plex-Token=" + sickbeard.PLEX_SERVER_TOKEN
try:
urllib.urlopen(url)
except Exception, e:

View File

@ -4329,7 +4329,7 @@ class ConfigNotifications(Config):
kodi_password=None,
use_plex=None, plex_notify_onsnatch=None, plex_notify_ondownload=None,
plex_notify_onsubtitledownload=None, plex_update_library=None,
plex_server_host=None, plex_host=None, plex_username=None, plex_password=None,
plex_server_host=None, plex_server_token=None, plex_host=None, plex_username=None, plex_password=None,
use_growl=None, growl_notify_onsnatch=None, growl_notify_ondownload=None,
growl_notify_onsubtitledownload=None, growl_host=None, growl_password=None,
use_prowl=None, prowl_notify_onsnatch=None, prowl_notify_ondownload=None,
@ -4388,6 +4388,7 @@ class ConfigNotifications(Config):
sickbeard.PLEX_UPDATE_LIBRARY = config.checkbox_to_value(plex_update_library)
sickbeard.PLEX_HOST = config.clean_hosts(plex_host)
sickbeard.PLEX_SERVER_HOST = config.clean_host(plex_server_host)
sickbeard.PLEX_SERVER_TOKEN = config.clean_host(plex_server_token)
sickbeard.PLEX_USERNAME = plex_username
sickbeard.PLEX_PASSWORD = plex_password
@ -4716,4 +4717,4 @@ class ErrorLogs(WebRoot):
if issue:
ui.notifications.message('Your issue ticket #%s was submitted successfully!' % issue.number)
return self.redirect("/errorlogs/")
return self.redirect("/errorlogs/")