Create DummyObject to not crash when starting with Python 2

* This disables the collections, playlists, and exporter features
This commit is contained in:
JonnyWong16 2021-01-25 18:30:47 -08:00
commit 5ca8184948
No known key found for this signature in database
GPG key ID: B1F1F9807184697A

View file

@ -19,7 +19,7 @@ from __future__ import unicode_literals
from future.builtins import object
from future.builtins import str
from plexapi.server import PlexServer
import sys
import plexpy
if plexpy.PYTHON2:
@ -28,6 +28,29 @@ else:
from plexpy import logger
class DummyObject(object):
def __init__(self, *args, **kwargs):
pass
def __call__(self, *args, **kwargs):
return self
def __getattr__(self, attr):
return self
def __iter__(self):
return self
def __next__(self):
raise StopIteration
if sys.version_info >= (3, 6):
from plexapi.server import PlexServer
else:
PlexServer = DummyObject
class Plex(object):
def __init__(self, url, token):
self.plex = PlexServer(url, token)