Set default url and token in Plex object

This commit is contained in:
JonnyWong16 2021-02-20 13:19:21 -08:00
parent 1cc98e7f7d
commit dd64a4a3d7
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
3 changed files with 6 additions and 4 deletions

View file

@ -1598,7 +1598,7 @@ class Export(object):
else: else:
plex_token = plexpy.CONFIG.PMS_TOKEN plex_token = plexpy.CONFIG.PMS_TOKEN
plex = Plex(plexpy.CONFIG.PMS_URL, plex_token) plex = Plex(token=plex_token)
if self.rating_key: if self.rating_key:
logger.debug( logger.debug(

View file

@ -148,7 +148,7 @@ def has_library_type(section_type):
def get_collections(section_id=None): def get_collections(section_id=None):
plex = Plex(plexpy.CONFIG.PMS_URL, session.get_session_user_token()) plex = Plex(token=session.get_session_user_token())
library = plex.get_library(section_id) library = plex.get_library(section_id)
if library.type not in ('movie', 'show', 'artist'): if library.type not in ('movie', 'show', 'artist'):
@ -245,7 +245,7 @@ def get_playlists(section_id=None, user_id=None):
if not plex_token: if not plex_token:
return [] return []
plex = Plex(plexpy.CONFIG.PMS_URL, plex_token) plex = Plex(token=plex_token)
if user_id: if user_id:
playlists = plex.plex.playlists() playlists = plex.plex.playlists()

View file

@ -52,7 +52,9 @@ else:
class Plex(object): class Plex(object):
def __init__(self, url, token): def __init__(self, url=None, token=None):
url = url or plexpy.CONFIG.PMS_URL
token = token or plexpy.CONFIG.PMS_TOKEN
self.plex = PlexServer(url, token) self.plex = PlexServer(url, token)
def get_library(self, section_id): def get_library(self, section_id):