diff --git a/core/__init__.py b/core/__init__.py index c59daa92..9468f5a1 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -11,9 +11,9 @@ import subprocess import sys import time +import eol import libs.autoload import libs.util -import eol if not libs.autoload.completed: sys.exit('Could not load vendored libraries.') @@ -56,6 +56,7 @@ from core.plugins.downloaders.utils import ( remove_torrent, resume_torrent, ) +from core.plugins.plex import configure_plex from core.utils import ( RunningProcess, category_search, @@ -443,28 +444,6 @@ def configure_remote_paths(): ] -def configure_plex(): - global PLEX_SSL - global PLEX_HOST - global PLEX_PORT - global PLEX_TOKEN - global PLEX_SECTION - - PLEX_SSL = int(CFG['Plex']['plex_ssl']) - PLEX_HOST = CFG['Plex']['plex_host'] - PLEX_PORT = CFG['Plex']['plex_port'] - PLEX_TOKEN = CFG['Plex']['plex_token'] - PLEX_SECTION = CFG['Plex']['plex_sections'] or [] - - if PLEX_SECTION: - if isinstance(PLEX_SECTION, list): - PLEX_SECTION = ','.join(PLEX_SECTION) # fix in case this imported as list. - PLEX_SECTION = [ - tuple(item.split(',')) - for item in PLEX_SECTION.split('|') - ] - - def configure_niceness(): global NICENESS @@ -1012,7 +991,7 @@ def initialize(section=None): configure_nzbs(CFG) configure_torrents(CFG) configure_remote_paths() - configure_plex() + configure_plex(CFG) configure_niceness() configure_containers() configure_transcoder() diff --git a/core/plugins/plex.py b/core/plugins/plex.py new file mode 100644 index 00000000..180cca66 --- /dev/null +++ b/core/plugins/plex.py @@ -0,0 +1,19 @@ +import core + + +def configure_plex(config): + core.PLEX_SSL = int(config['Plex']['plex_ssl']) + core.PLEX_HOST = config['Plex']['plex_host'] + core.PLEX_PORT = config['Plex']['plex_port'] + core.PLEX_TOKEN = config['Plex']['plex_token'] + plex_section = config['Plex']['plex_sections'] or [] + + if plex_section: + if isinstance(plex_section, list): + plex_section = ','.join(plex_section) # fix in case this imported as list. + plex_section = [ + tuple(item.split(',')) + for item in plex_section.split('|') + ] + + core.PLEX_SECTION = plex_section