mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Handling broken youtube feeds.
This commit is contained in:
parent
82fbccd1c2
commit
e446103392
1 changed files with 14 additions and 5 deletions
|
@ -166,14 +166,20 @@ class FetchFeed:
|
||||||
channel_json = requests.get("https://www.googleapis.com/youtube/v3/channels?part=snippet&id=%s&key=%s" %
|
channel_json = requests.get("https://www.googleapis.com/youtube/v3/channels?part=snippet&id=%s&key=%s" %
|
||||||
(channel_id, settings.YOUTUBE_API_KEY))
|
(channel_id, settings.YOUTUBE_API_KEY))
|
||||||
channel = json.decode(channel_json.content)
|
channel = json.decode(channel_json.content)
|
||||||
|
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:
|
||||||
|
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" %
|
||||||
(list_id, settings.YOUTUBE_API_KEY))
|
(list_id, settings.YOUTUBE_API_KEY))
|
||||||
playlist = json.decode(playlist_json.content)
|
playlist = json.decode(playlist_json.content)
|
||||||
|
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:
|
||||||
|
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:
|
||||||
video_ids_xml = requests.get("https://www.youtube.com/feeds/videos.xml?user=%s" % username)
|
video_ids_xml = requests.get("https://www.youtube.com/feeds/videos.xml?user=%s" % username)
|
||||||
|
@ -185,7 +191,10 @@ class FetchFeed:
|
||||||
playlist_json = requests.get("https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=%s&key=%s" %
|
playlist_json = requests.get("https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=%s&key=%s" %
|
||||||
(list_id, settings.YOUTUBE_API_KEY))
|
(list_id, settings.YOUTUBE_API_KEY))
|
||||||
playlist = json.decode(playlist_json.content)
|
playlist = json.decode(playlist_json.content)
|
||||||
|
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:
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
if video_ids_xml.status_code != 200:
|
if video_ids_xml.status_code != 200:
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Reference in a new issue