diff --git a/resources/lib/PlexAPI.py b/resources/lib/PlexAPI.py index f7b54551..20845c81 100644 --- a/resources/lib/PlexAPI.py +++ b/resources/lib/PlexAPI.py @@ -217,8 +217,7 @@ class PlexAPI(): """ # Try to get a temporary token xml = self.doUtils('https://plex.tv/pins/%s.xml' % identifier, - authenticate=False, - type="GET") + authenticate=False) try: temp_token = xml.find('auth_token').text except: @@ -230,8 +229,7 @@ class PlexAPI(): # Use temp token to get the final plex credentials xml = self.doUtils('https://plex.tv/users/account', authenticate=False, - parameters={'X-Plex-Token': temp_token}, - type="GET") + parameters={'X-Plex-Token': temp_token}) return xml def GetPlexPin(self): @@ -243,7 +241,7 @@ class PlexAPI(): # Download xml = self.doUtils('https://plex.tv/pins.xml', authenticate=False, - type="POST") + action_type="POST") try: xml.attrib except: @@ -907,7 +905,7 @@ class PlexAPI(): self.logMsg('Switching to user %s' % userId, 0) answer = self.doUtils(url, authenticate=False, - type="POST", + action_type="POST", headerOptions={'X-Plex-Token': token}) try: answer.attrib diff --git a/resources/lib/PlexFunctions.py b/resources/lib/PlexFunctions.py index 35dc794e..f6ba413f 100644 --- a/resources/lib/PlexFunctions.py +++ b/resources/lib/PlexFunctions.py @@ -139,7 +139,7 @@ def SelectStreams(url, args): chosen. """ downloadutils.DownloadUtils().downloadUrl( - url + '?' + urlencode(args), type='PUT') + url + '?' + urlencode(args), action_type='PUT') def GetPlayQueue(playQueueID): @@ -388,7 +388,7 @@ def GetPlexPlaylist(itemid, librarySectionUUID, mediatype='movie'): 'repeat': '0' } xml = downloadutils.DownloadUtils().downloadUrl( - url + '?' + urlencode(args), type="POST") + url + '?' + urlencode(args), action_type="POST") try: xml[0].tag except (IndexError, TypeError, AttributeError): @@ -448,8 +448,7 @@ def GetMachineIdentifier(url): Returns None if something went wrong """ - xml = downloadutils.DownloadUtils().downloadUrl( - url + '/identity', type="GET") + xml = downloadutils.DownloadUtils().downloadUrl(url + '/identity') try: xml.attrib except: @@ -480,7 +479,6 @@ def GetPMSStatus(token): answer = {} xml = downloadutils.DownloadUtils().downloadUrl( '{server}/status/sessions', - type="GET", headerOptions={'X-Plex-Token': token}) try: xml.attrib @@ -519,5 +517,5 @@ def scrobble(ratingKey, state): url = "{server}/:/unscrobble?" + urlencode(args) else: return - downloadutils.DownloadUtils().downloadUrl(url, type="GET") + downloadutils.DownloadUtils().downloadUrl(url) logMsg(title, "Toggled watched state for Plex item %s" % ratingKey, 1) diff --git a/resources/lib/downloadutils.py b/resources/lib/downloadutils.py index 402395a2..5a0d1fc9 100644 --- a/resources/lib/downloadutils.py +++ b/resources/lib/downloadutils.py @@ -142,21 +142,22 @@ class DownloadUtils(): header.update(options) return header - def __doDownload(self, s, type, **kwargs): - if type == "GET": + def __doDownload(self, s, action_type, **kwargs): + if action_type == "GET": r = s.get(**kwargs) - elif type == "POST": + elif action_type == "POST": r = s.post(**kwargs) - elif type == "DELETE": + elif action_type == "DELETE": r = s.delete(**kwargs) - elif type == "OPTIONS": + elif action_type == "OPTIONS": r = s.options(**kwargs) - elif type == "PUT": + elif action_type == "PUT": r = s.put(**kwargs) return r - def downloadUrl(self, url, type="GET", postBody=None, parameters=None, - authenticate=True, headerOptions=None, verifySSL=True): + def downloadUrl(self, url, action_type="GET", postBody=None, + parameters=None, authenticate=True, headerOptions=None, + verifySSL=True): """ Override SSL check with verifySSL=False @@ -205,7 +206,7 @@ class DownloadUtils(): # ACTUAL DOWNLOAD HAPPENING HERE try: - r = self.__doDownload(s, type, **kwargs) + r = self.__doDownload(s, action_type, **kwargs) # THE EXCEPTIONS except requests.exceptions.ConnectionError as e: diff --git a/resources/lib/itemtypes.py b/resources/lib/itemtypes.py index 0f0bbc2f..f68be1ed 100644 --- a/resources/lib/itemtypes.py +++ b/resources/lib/itemtypes.py @@ -11,7 +11,6 @@ import xbmcgui import xbmcvfs import artwork -import downloadutils import utils import embydb_functions as embydb import kodidb_functions as kodidb @@ -34,7 +33,6 @@ class Items(object): """ def __init__(self): - self.doUtils = downloadutils.DownloadUtils() self.kodiversion = int(xbmc.getInfoLabel("System.BuildVersion")[:2]) # self.directpath = utils.settings('useDirectPaths') == "1" self.directpath = True if utils.window('useDirectPaths') == 'true' \ diff --git a/resources/lib/player.py b/resources/lib/player.py index d6304675..d9fb1a2c 100644 --- a/resources/lib/player.py +++ b/resources/lib/player.py @@ -521,7 +521,7 @@ class Player(xbmc.Player): url = "{server}/emby/Items/%s?format=json" % itemid log("Deleting request: %s" % itemid, 1) - doUtils(url, type="DELETE") + doUtils(url, action_type="DELETE") self.stopPlayback(data) # Clean the WINDOW properties diff --git a/resources/lib/plexbmchelper/subscribers.py b/resources/lib/plexbmchelper/subscribers.py index 12f88dcc..962c2a3b 100644 --- a/resources/lib/plexbmchelper/subscribers.py +++ b/resources/lib/plexbmchelper/subscribers.py @@ -172,7 +172,7 @@ class SubscriptionManager: url = serv.get('protocol', 'http') + '://' \ + serv.get('server', 'localhost') + ':' \ + serv.get('port', '32400') + "/:/timeline" - self.doUtils(url, type="GET", parameters=params) + self.doUtils(url, parameters=params) # requests.getwithparams(serv.get('server', 'localhost'), serv.get('port', 32400), "/:/timeline", params, getPlexHeaders(), serv.get('protocol', 'http')) self.logMsg("sent server notification with state = %s" % params['state'], 2) @@ -283,6 +283,6 @@ class Subscriber: """ response = self.doUtils(url, postBody=msg, - type="POST") + action_type="POST") if response in [False, None, 401]: self.subMgr.removeSubscriber(self.uuid)