mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-07-15 01:32:53 -07:00
Refactor PLEX*
This commit is contained in:
parent
182a542bda
commit
d2346b0ea6
2 changed files with 21 additions and 21 deletions
|
@ -169,11 +169,11 @@ QBITTORRENT_PORT = None
|
||||||
QBITTORRENT_USER = None
|
QBITTORRENT_USER = None
|
||||||
QBITTORRENT_PASSWORD = None
|
QBITTORRENT_PASSWORD = None
|
||||||
|
|
||||||
PLEXSSL = None
|
PLEX_SSL = None
|
||||||
PLEXHOST = None
|
PLEX_HOST = None
|
||||||
PLEXPORT = None
|
PLEX_PORT = None
|
||||||
PLEXTOKEN = None
|
PLEX_TOKEN = None
|
||||||
PLEXSEC = []
|
PLEX_SECTION = []
|
||||||
|
|
||||||
EXTCONTAINER = []
|
EXTCONTAINER = []
|
||||||
COMPRESSEDCONTAINER = []
|
COMPRESSEDCONTAINER = []
|
||||||
|
@ -269,7 +269,7 @@ def initialize(section=None):
|
||||||
DELETE_ORIGINAL, TORRENT_CHMOD_DIRECTORY, PASSWORDSFILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \
|
DELETE_ORIGINAL, TORRENT_CHMOD_DIRECTORY, PASSWORDSFILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \
|
||||||
USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOADINFO, CHECK_MEDIA, SAFE_MODE, \
|
USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOADINFO, CHECK_MEDIA, SAFE_MODE, \
|
||||||
TORRENT_DEFAULTDIR, TORRENT_RESUME_ON_FAILURE, NZB_DEFAULTDIR, REMOTEPATHS, LOG_ENV, PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \
|
TORRENT_DEFAULTDIR, TORRENT_RESUME_ON_FAILURE, NZB_DEFAULTDIR, REMOTEPATHS, LOG_ENV, PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \
|
||||||
PLEXSSL, PLEXHOST, PLEXPORT, PLEXTOKEN, PLEXSEC, TORRENT_RESUME, PAR2CMD, QBITTORRENT_HOST, QBITTORRENT_PORT, QBITTORRENT_USER, QBITTORRENT_PASSWORD
|
PLEX_SSL, PLEX_HOST, PLEX_PORT, PLEX_TOKEN, PLEX_SECTION, TORRENT_RESUME, PAR2CMD, QBITTORRENT_HOST, QBITTORRENT_PORT, QBITTORRENT_USER, QBITTORRENT_PASSWORD
|
||||||
|
|
||||||
if __INITIALIZED__:
|
if __INITIALIZED__:
|
||||||
return False
|
return False
|
||||||
|
@ -434,15 +434,15 @@ def initialize(section=None):
|
||||||
REMOTEPATHS = [(local.strip(), remote.strip()) for local, remote in
|
REMOTEPATHS = [(local.strip(), remote.strip()) for local, remote in
|
||||||
REMOTEPATHS] # strip trailing and leading whitespaces
|
REMOTEPATHS] # strip trailing and leading whitespaces
|
||||||
|
|
||||||
PLEXSSL = int(CFG['Plex']['plex_ssl'])
|
PLEX_SSL = int(CFG['Plex']['plex_ssl'])
|
||||||
PLEXHOST = CFG['Plex']['plex_host']
|
PLEX_HOST = CFG['Plex']['plex_host']
|
||||||
PLEXPORT = CFG['Plex']['plex_port']
|
PLEX_PORT = CFG['Plex']['plex_port']
|
||||||
PLEXTOKEN = CFG['Plex']['plex_token']
|
PLEX_TOKEN = CFG['Plex']['plex_token']
|
||||||
PLEXSEC = CFG['Plex']['plex_sections'] or []
|
PLEX_SECTION = CFG['Plex']['plex_sections'] or []
|
||||||
if PLEXSEC:
|
if PLEX_SECTION:
|
||||||
if isinstance(PLEXSEC, list):
|
if isinstance(PLEX_SECTION, list):
|
||||||
PLEXSEC = ','.join(PLEXSEC) # fix in case this imported as list.
|
PLEX_SECTION = ','.join(PLEX_SECTION) # fix in case this imported as list.
|
||||||
PLEXSEC = [tuple(item.split(',')) for item in PLEXSEC.split('|')]
|
PLEX_SECTION = [tuple(item.split(',')) for item in PLEX_SECTION.split('|')]
|
||||||
|
|
||||||
devnull = open(os.devnull, 'w')
|
devnull = open(os.devnull, 'w')
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -8,20 +8,20 @@ def plex_update(category):
|
||||||
if core.FAILED:
|
if core.FAILED:
|
||||||
return
|
return
|
||||||
url = '{scheme}://{host}:{port}/library/sections/'.format(
|
url = '{scheme}://{host}:{port}/library/sections/'.format(
|
||||||
scheme='https' if core.PLEXSSL else 'http',
|
scheme='https' if core.PLEX_SSL else 'http',
|
||||||
host=core.PLEXHOST,
|
host=core.PLEX_HOST,
|
||||||
port=core.PLEXPORT,
|
port=core.PLEX_PORT,
|
||||||
)
|
)
|
||||||
section = None
|
section = None
|
||||||
if not core.PLEXSEC:
|
if not core.PLEX_SECTION:
|
||||||
return
|
return
|
||||||
logger.debug('Attempting to update Plex Library for category {0}.'.format(category), 'PLEX')
|
logger.debug('Attempting to update Plex Library for category {0}.'.format(category), 'PLEX')
|
||||||
for item in core.PLEXSEC:
|
for item in core.PLEX_SECTION:
|
||||||
if item[0] == category:
|
if item[0] == category:
|
||||||
section = item[1]
|
section = item[1]
|
||||||
|
|
||||||
if section:
|
if section:
|
||||||
url = '{url}{section}/refresh?X-Plex-Token={token}'.format(url=url, section=section, token=core.PLEXTOKEN)
|
url = '{url}{section}/refresh?X-Plex-Token={token}'.format(url=url, section=section, token=core.PLEX_TOKEN)
|
||||||
requests.get(url, timeout=(60, 120), verify=False)
|
requests.get(url, timeout=(60, 120), verify=False)
|
||||||
logger.debug('Plex Library has been refreshed.', 'PLEX')
|
logger.debug('Plex Library has been refreshed.', 'PLEX')
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue