From 5ca81849485bf62c41f1a36ea6aa6aca1578c903 Mon Sep 17 00:00:00 2001 From: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> Date: Mon, 25 Jan 2021 18:30:47 -0800 Subject: [PATCH] Create DummyObject to not crash when starting with Python 2 * This disables the collections, playlists, and exporter features --- plexpy/plex.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/plexpy/plex.py b/plexpy/plex.py index b46f0722..240b362b 100644 --- a/plexpy/plex.py +++ b/plexpy/plex.py @@ -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)