Clean up downloadUtils
This commit is contained in:
parent
213f42f4a5
commit
8b83ae8a00
1 changed files with 20 additions and 14 deletions
|
@ -11,6 +11,7 @@ import xbmcgui
|
||||||
|
|
||||||
import clientinfo
|
import clientinfo
|
||||||
from utils import Logging, window, settings
|
from utils import Logging, window, settings
|
||||||
|
import utils
|
||||||
|
|
||||||
##################################################################################################
|
##################################################################################################
|
||||||
|
|
||||||
|
@ -217,16 +218,10 @@ class DownloadUtils():
|
||||||
log("===== ENTER downloadUrl =====", 2)
|
log("===== ENTER downloadUrl =====", 2)
|
||||||
|
|
||||||
session = requests
|
session = requests
|
||||||
|
kwargs = {}
|
||||||
default_link = ""
|
default_link = ""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
kwargs = {
|
|
||||||
'timeout': self.timeout,
|
|
||||||
'json': postBody,
|
|
||||||
'params': parameters
|
|
||||||
}
|
|
||||||
|
|
||||||
if authenticate:
|
if authenticate:
|
||||||
|
|
||||||
if self.s is not None:
|
if self.s is not None:
|
||||||
|
@ -245,17 +240,16 @@ class DownloadUtils():
|
||||||
if settings('sslcert') != "None":
|
if settings('sslcert') != "None":
|
||||||
verifyssl = settings('sslcert')
|
verifyssl = settings('sslcert')
|
||||||
|
|
||||||
kwargs['headers'] = self.getHeader()
|
kwargs.update({
|
||||||
|
'verify': verifyssl,
|
||||||
|
'headers': self.getHeader()
|
||||||
|
})
|
||||||
|
|
||||||
# Replace for the real values
|
# Replace for the real values
|
||||||
url = url.replace("{server}", self.server)
|
url = url.replace("{server}", self.server)
|
||||||
url = url.replace("{UserId}", self.userId)
|
url = url.replace("{UserId}", self.userId)
|
||||||
kwargs['url'] = url
|
|
||||||
|
|
||||||
else: # User is not authenticated
|
else: # User is not authenticated
|
||||||
kwargs['url'] = url
|
|
||||||
kwargs['headers'] = self.getHeader(authenticate=False)
|
|
||||||
|
|
||||||
# If user enables ssl verification
|
# If user enables ssl verification
|
||||||
try:
|
try:
|
||||||
verifyssl = self.sslverify
|
verifyssl = self.sslverify
|
||||||
|
@ -263,8 +257,19 @@ class DownloadUtils():
|
||||||
verifyssl = self.sslclient
|
verifyssl = self.sslclient
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
verifyssl = False
|
verifyssl = False
|
||||||
finally:
|
|
||||||
kwargs['verify'] = verifyssl
|
kwargs.update({
|
||||||
|
'verify': verifyssl,
|
||||||
|
'headers': self.getHeader(authenticate=False)
|
||||||
|
})
|
||||||
|
|
||||||
|
##### PREPARE REQUEST #####
|
||||||
|
kwargs.update({
|
||||||
|
'url': url,
|
||||||
|
'timeout': self.timeout,
|
||||||
|
'json': postBody,
|
||||||
|
'params': parameters
|
||||||
|
})
|
||||||
|
|
||||||
##### THE RESPONSE #####
|
##### THE RESPONSE #####
|
||||||
log(kwargs, 2)
|
log(kwargs, 2)
|
||||||
|
@ -353,6 +358,7 @@ class DownloadUtils():
|
||||||
|
|
||||||
return default_link
|
return default_link
|
||||||
|
|
||||||
|
@utils.timeIt
|
||||||
def __requests(self, action, session=requests, **kwargs):
|
def __requests(self, action, session=requests, **kwargs):
|
||||||
|
|
||||||
if action == "GET":
|
if action == "GET":
|
||||||
|
|
Loading…
Reference in a new issue