From 5112500f4d64e85638d6b0365c94ac7c99012d2e Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Thu, 14 Jan 2016 02:59:02 -0600 Subject: [PATCH] Fix missing mediasources Also add a throttle to avoid crash if server connection times out. --- resources/lib/read_embyserver.py | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/resources/lib/read_embyserver.py b/resources/lib/read_embyserver.py index 182c33fb..d0158b0e 100644 --- a/resources/lib/read_embyserver.py +++ b/resources/lib/read_embyserver.py @@ -80,8 +80,9 @@ class Read_EmbyServer(): "Path,Genres,SortName,Studios,Writer,ProductionYear,Taglines," "CommunityRating,OfficialRating,CumulativeRunTimeTicks," "Metascore,AirTime,DateCreated,MediaStreams,People,Overview," - "CriticRating,CriticRatingSummary,Etag,ProductionLocations," - "Tags,ProviderIds,RemoteTrailers,SpecialEpisodeNumbers" + "CriticRating,CriticRatingSummary,Etag,ShortOverview,ProductionLocations," + "Tags,ProviderIds,ParentId,RemoteTrailers,SpecialEpisodeNumbers," + "MediaSources" ) } result = self.doUtils.downloadUrl(url, parameters=params) @@ -205,12 +206,19 @@ class Read_EmbyServer(): "CommunityRating,OfficialRating,CumulativeRunTimeTicks," "Metascore,AirTime,DateCreated,MediaStreams,People,Overview," "CriticRating,CriticRatingSummary,Etag,ShortOverview,ProductionLocations," - "Tags,ProviderIds,ParentId,RemoteTrailers,SpecialEpisodeNumbers" + "Tags,ProviderIds,ParentId,RemoteTrailers,SpecialEpisodeNumbers," + "MediaSources" ) result = doUtils.downloadUrl(url, parameters=params) - items['Items'].extend(result['Items']) - - index += jump + try: + items['Items'].extend(result['Items']) + except TypeError: + # Connection timed out, reduce the number + jump -= 50 + self.limitindex = jump + self.logMsg("New throttle for items requested: %s" % jump, 1) + else: + index += jump return items @@ -389,9 +397,15 @@ class Read_EmbyServer(): ) } result = doUtils.downloadUrl(url, parameters=params) - items['Items'].extend(result['Items']) - - index += jump + try: + items['Items'].extend(result['Items']) + except TypeError: + # Connection timed out, reduce the number + jump -= 50 + self.limitindex = jump + self.logMsg("New throttle for items requested: %s" % jump, 1) + else: + index += jump return items