mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 18:26:15 +00:00
refine download function, more exceptions
This commit is contained in:
parent
f7c79e366e
commit
c8b1e738c6
2 changed files with 12 additions and 25 deletions
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<addon id="plugin.video.emby"
|
<addon id="plugin.video.emby"
|
||||||
name="Emby"
|
name="Emby"
|
||||||
version="2.3.43"
|
version="2.3.44"
|
||||||
provider-name="Emby.media">
|
provider-name="Emby.media">
|
||||||
<requires>
|
<requires>
|
||||||
<import addon="xbmc.python" version="2.19.0"/>
|
<import addon="xbmc.python" version="2.19.0"/>
|
||||||
|
|
|
@ -238,7 +238,7 @@ class DownloadUtils(object):
|
||||||
# does the URL look ok
|
# does the URL look ok
|
||||||
if url.startswith('/'):
|
if url.startswith('/'):
|
||||||
exc = Exception("URL Error: " + url)
|
exc = Exception("URL Error: " + url)
|
||||||
exc.quiet = True
|
#exc.quiet = True
|
||||||
raise exc
|
raise exc
|
||||||
|
|
||||||
##### PREPARE REQUEST #####
|
##### PREPARE REQUEST #####
|
||||||
|
@ -260,7 +260,7 @@ class DownloadUtils(object):
|
||||||
# Read response to release connection
|
# Read response to release connection
|
||||||
response.content
|
response.content
|
||||||
if action_type == "GET":
|
if action_type == "GET":
|
||||||
raise Warning("Response Code 204: No Content for GET request")
|
raise Exception("Response Code 204 for GET request")
|
||||||
else:
|
else:
|
||||||
# this is probably valid for DELETE and PUT
|
# this is probably valid for DELETE and PUT
|
||||||
return None
|
return None
|
||||||
|
@ -279,7 +279,7 @@ class DownloadUtils(object):
|
||||||
##### EXCEPTIONS #####
|
##### EXCEPTIONS #####
|
||||||
|
|
||||||
except requests.exceptions.SSLError as error:
|
except requests.exceptions.SSLError as error:
|
||||||
log.error("invalid SSL certificate for: %s", url)
|
log.error("Invalid SSL certificate for: %s", url)
|
||||||
error.quiet = True
|
error.quiet = True
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
@ -303,11 +303,6 @@ class DownloadUtils(object):
|
||||||
|
|
||||||
except requests.exceptions.HTTPError as error:
|
except requests.exceptions.HTTPError as error:
|
||||||
|
|
||||||
if response.status_code == 400:
|
|
||||||
log.error("Malformed request: %s", error)
|
|
||||||
error.quiet = True
|
|
||||||
raise
|
|
||||||
|
|
||||||
if response.status_code == 401:
|
if response.status_code == 401:
|
||||||
# Unauthorized
|
# Unauthorized
|
||||||
status = window('emby_serverStatus')
|
status = window('emby_serverStatus')
|
||||||
|
@ -322,16 +317,6 @@ class DownloadUtils(object):
|
||||||
icon=xbmcgui.NOTIFICATION_ERROR,
|
icon=xbmcgui.NOTIFICATION_ERROR,
|
||||||
time=5000)
|
time=5000)
|
||||||
window('emby_serverStatus', value="restricted")
|
window('emby_serverStatus', value="restricted")
|
||||||
exc = Exception("restricted: " + str(error))
|
|
||||||
exc.quiet = True
|
|
||||||
raise exc
|
|
||||||
|
|
||||||
elif (response.headers['X-Application-Error-Code'] ==
|
|
||||||
"UnauthorizedAccessException"):
|
|
||||||
# User tried to do something his emby account doesn't allow
|
|
||||||
exc = Exception("UnauthorizedAccessException: " + str(error))
|
|
||||||
exc.quiet = True
|
|
||||||
raise exc
|
|
||||||
|
|
||||||
elif status not in ("401", "Auth"):
|
elif status not in ("401", "Auth"):
|
||||||
# Tell userclient token has been revoked.
|
# Tell userclient token has been revoked.
|
||||||
|
@ -340,13 +325,15 @@ class DownloadUtils(object):
|
||||||
xbmcgui.Dialog().notification(heading="Error connecting",
|
xbmcgui.Dialog().notification(heading="Error connecting",
|
||||||
message="Unauthorized.",
|
message="Unauthorized.",
|
||||||
icon=xbmcgui.NOTIFICATION_ERROR)
|
icon=xbmcgui.NOTIFICATION_ERROR)
|
||||||
exc = Exception("401: " + str(error))
|
|
||||||
exc.quiet = True
|
exc = Exception("HTTPError : " + str(response.status_code) + " : " + str(error))
|
||||||
|
#exc.quiet = True
|
||||||
raise exc
|
raise exc
|
||||||
|
|
||||||
except requests.exceptions.RequestException as error:
|
# if we got to here and did not process the download for some reason then that is bad
|
||||||
log.error("unknown error connecting to: %s", url)
|
exc = Exception("Unhandled Download : %s", url)
|
||||||
raise
|
#exc.quiet = True
|
||||||
|
raise exc
|
||||||
|
|
||||||
def _ensure_server(self, server_id=None):
|
def _ensure_server(self, server_id=None):
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue