Merge conflicts: download action_type

This commit is contained in:
tomkat83 2016-04-26 14:02:19 +02:00
parent 450437b812
commit c7b52a1fa4
6 changed files with 21 additions and 26 deletions

View file

@ -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

View file

@ -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)

View file

@ -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:

View file

@ -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' \

View file

@ -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

View file

@ -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)