mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-13 00:32:58 -07:00
Add function to initialize plexapi
This commit is contained in:
parent
af8a5342fb
commit
3b5801a2cd
2 changed files with 13 additions and 14 deletions
|
@ -53,6 +53,7 @@ if PYTHON2:
|
||||||
import newsletter_handler
|
import newsletter_handler
|
||||||
import notification_handler
|
import notification_handler
|
||||||
import notifiers
|
import notifiers
|
||||||
|
import plex
|
||||||
import plextv
|
import plextv
|
||||||
import users
|
import users
|
||||||
import versioncheck
|
import versioncheck
|
||||||
|
@ -73,6 +74,7 @@ else:
|
||||||
from plexpy import newsletter_handler
|
from plexpy import newsletter_handler
|
||||||
from plexpy import notification_handler
|
from plexpy import notification_handler
|
||||||
from plexpy import notifiers
|
from plexpy import notifiers
|
||||||
|
from plexpy import plex
|
||||||
from plexpy import plextv
|
from plexpy import plextv
|
||||||
from plexpy import users
|
from plexpy import users
|
||||||
from plexpy import versioncheck
|
from plexpy import versioncheck
|
||||||
|
@ -206,14 +208,10 @@ def initialize(config_file):
|
||||||
logger.initLogger(console=not QUIET, log_dir=CONFIG.LOG_DIR if log_writable else None,
|
logger.initLogger(console=not QUIET, log_dir=CONFIG.LOG_DIR if log_writable else None,
|
||||||
verbose=VERBOSE)
|
verbose=VERBOSE)
|
||||||
|
|
||||||
|
if not PYTHON2:
|
||||||
os.environ['PLEXAPI_CONFIG_PATH'] = os.path.join(DATA_DIR, 'plexapi.config.ini')
|
os.environ['PLEXAPI_CONFIG_PATH'] = os.path.join(DATA_DIR, 'plexapi.config.ini')
|
||||||
os.environ['PLEXAPI_LOG_PATH'] = os.path.join(CONFIG.LOG_DIR, 'plexapi.log')
|
os.environ['PLEXAPI_LOG_PATH'] = os.path.join(CONFIG.LOG_DIR, 'plexapi.log')
|
||||||
try:
|
plex.initialize_plexapi()
|
||||||
import plexapi
|
|
||||||
import importlib
|
|
||||||
importlib.reload(plexapi)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if DOCKER:
|
if DOCKER:
|
||||||
build = '[Docker] '
|
build = '[Docker] '
|
||||||
|
|
|
@ -19,8 +19,6 @@ from __future__ import unicode_literals
|
||||||
from future.builtins import object
|
from future.builtins import object
|
||||||
from future.builtins import str
|
from future.builtins import str
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
import plexpy
|
import plexpy
|
||||||
if plexpy.PYTHON2:
|
if plexpy.PYTHON2:
|
||||||
import logger
|
import logger
|
||||||
|
@ -45,17 +43,20 @@ class DummyObject(object):
|
||||||
raise StopIteration
|
raise StopIteration
|
||||||
|
|
||||||
|
|
||||||
if sys.version_info >= (3, 6):
|
PlexObject = DummyObject
|
||||||
|
|
||||||
|
|
||||||
|
def initialize_plexapi():
|
||||||
from plexapi.server import PlexServer
|
from plexapi.server import PlexServer
|
||||||
else:
|
global PlexObject
|
||||||
PlexServer = DummyObject
|
PlexObject = PlexServer
|
||||||
|
|
||||||
|
|
||||||
class Plex(object):
|
class Plex(object):
|
||||||
def __init__(self, url=None, token=None):
|
def __init__(self, url=None, token=None):
|
||||||
url = url or plexpy.CONFIG.PMS_URL
|
url = url or plexpy.CONFIG.PMS_URL
|
||||||
token = token or plexpy.CONFIG.PMS_TOKEN
|
token = token or plexpy.CONFIG.PMS_TOKEN
|
||||||
self.plex = PlexServer(url, token)
|
self.plex = PlexObject(url, token)
|
||||||
|
|
||||||
def get_library(self, section_id):
|
def get_library(self, section_id):
|
||||||
return self.plex.library.sectionByID(str(section_id))
|
return self.plex.library.sectionByID(str(section_id))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue