Skip to content

Commit

Permalink
YouTubeUi: use exception for all searchResponse results
Browse files Browse the repository at this point in the history
I assume that if there is any internet problem, the searchResponse may not return correct information.
This should fix #27
  • Loading branch information
Taapat committed Sep 5, 2017
1 parent 2ac3936 commit 8dddc5a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/YouTubeUi.py
Expand Up @@ -868,7 +868,10 @@ def createEntryList(self):
self.prevPageToken = searchResponse.get('prevPageToken')
self.setSearchResults(searchResponse.get('pageInfo', {}).get('totalResults', 0))
for result in searchResponse.get('items', []):
channel = result['contentDetails']['relatedPlaylists'][playlist]
try:
channel = result['contentDetails']['relatedPlaylists'][playlist]
except:
pass

videos = self.videoIdFromPlaylist(channel)
return self.extractVideoIdList(videos)
Expand Down Expand Up @@ -926,7 +929,10 @@ def createEntryList(self):
self.prevPageToken = searchResponse.get('prevPageToken')
self.setSearchResults(searchResponse.get('pageInfo', {}).get('totalResults', 0))
for result in searchResponse.get('items', []):
videos.append(result['id']['videoId'])
try:
videos.append(result['id']['videoId'])
except:
pass
return self.extractVideoIdList(videos)

def extractVideoIdList(self, videos):
Expand Down

0 comments on commit 8dddc5a

Please sign in to comment.