Catch and raise bad status 400

When the request is malformed. Added logging to hopefully get to the
bottom of a bug pulling albums from server.
This commit is contained in:
angelblue05 2016-10-04 01:14:14 -05:00
parent 43277ac2d6
commit e58d98bc10
2 changed files with 13 additions and 3 deletions

View file

@ -248,6 +248,7 @@ class DownloadUtils(object):
##### THE RESPONSE #####
log.debug(kwargs)
response = self._requests(action_type, session, **kwargs)
#response = requests.get('http://httpbin.org/status/400')
if response.status_code == 204:
# No body in the response
@ -287,6 +288,10 @@ class DownloadUtils(object):
except requests.exceptions.HTTPError as error:
if response.status_code == 400:
log.error("Malformed request: %s", error)
raise Warning('400')
if response.status_code == 401:
# Unauthorized
status = window('emby_serverStatus')

View file

@ -186,7 +186,8 @@ class Read_EmbyServer():
url = "{server}/emby/LiveTv/Recordings/?userid={UserId}&format=json"
return self.doUtils(url, parameters=params)
def getSection(self, parentid, itemtype=None, sortby="SortName", basic=False, dialog=None):
def getSection(self, parentid, itemtype=None, sortby="SortName", basic=False, params=None,
dialog=None):
items = {
@ -238,7 +239,7 @@ class Read_EmbyServer():
if basic:
params['Fields'] = "Etag"
else:
params['Fields'] = (
params['Fields'] = params or (
"Path,Genres,SortName,Studios,Writer,ProductionYear,Taglines,"
"CommunityRating,OfficialRating,CumulativeRunTimeTicks,"
@ -247,9 +248,13 @@ class Read_EmbyServer():
"Tags,ProviderIds,ParentId,RemoteTrailers,SpecialEpisodeNumbers,"
"MediaSources,VoteCount"
)
result = self.doUtils(url, parameters=params)
try:
result = self.doUtils(url, parameters=params)
items['Items'].extend(result['Items'])
except Warning as error:
if error == "400":
log.info("Something went wrong, aborting request.")
break
except TypeError:
# Something happened to the connection
if not throttled: