mirror of
https://github.com/viq/NewsBlur.git
synced 2025-08-05 16:49:45 +00:00
Handling YouTube client errors gracefully.
This commit is contained in:
parent
b6e1e03bd5
commit
3d92dfd0ad
1 changed files with 3 additions and 3 deletions
|
@ -172,7 +172,7 @@ class FetchFeed:
|
||||||
try:
|
try:
|
||||||
username = channel['items'][0]['snippet']['title']
|
username = channel['items'][0]['snippet']['title']
|
||||||
description = channel['items'][0]['snippet']['description']
|
description = channel['items'][0]['snippet']['description']
|
||||||
except IndexError:
|
except (IndexError, KeyError):
|
||||||
return
|
return
|
||||||
elif list_id:
|
elif list_id:
|
||||||
playlist_json = requests.get("https://www.googleapis.com/youtube/v3/playlists?part=snippet&id=%s&key=%s" %
|
playlist_json = requests.get("https://www.googleapis.com/youtube/v3/playlists?part=snippet&id=%s&key=%s" %
|
||||||
|
@ -181,7 +181,7 @@ class FetchFeed:
|
||||||
try:
|
try:
|
||||||
username = playlist['items'][0]['snippet']['title']
|
username = playlist['items'][0]['snippet']['title']
|
||||||
description = playlist['items'][0]['snippet']['description']
|
description = playlist['items'][0]['snippet']['description']
|
||||||
except IndexError:
|
except (IndexError, KeyError):
|
||||||
return
|
return
|
||||||
channel_url = "https://www.youtube.com/playlist?list=%s" % list_id
|
channel_url = "https://www.youtube.com/playlist?list=%s" % list_id
|
||||||
elif username:
|
elif username:
|
||||||
|
@ -196,7 +196,7 @@ class FetchFeed:
|
||||||
playlist = json.decode(playlist_json.content)
|
playlist = json.decode(playlist_json.content)
|
||||||
try:
|
try:
|
||||||
video_ids = [video['snippet']['resourceId']['videoId'] for video in playlist['items']]
|
video_ids = [video['snippet']['resourceId']['videoId'] for video in playlist['items']]
|
||||||
except IndexError:
|
except (IndexError, KeyError):
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
if video_ids_xml.status_code != 200:
|
if video_ids_xml.status_code != 200:
|
||||||
|
|
Loading…
Add table
Reference in a new issue