1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-26 10:24:33 +01:00

[spreaker] Handle when playlist JSON has multiple pages

This commit is contained in:
Andrew Udvare 2017-08-11 00:31:57 -04:00
parent 1c9e16b8b9
commit b653c19f8f

View File

@ -24,12 +24,30 @@ class SpreakerPlaylistIE(InfoExtractor):
html = self._download_webpage(url, None) html = self._download_webpage(url, None)
playlist_url = self._html_search_regex( playlist_url = self._html_search_regex(
r'data-playlist_url="(?P<url>https\://[^"]+")', html, 'url') r'data-playlist_url="(?P<url>https\://[^"]+")', html, 'url')
items = self._download_json(playlist_url, None) items = self._download_json(playlist_url,
items = items['response']['playlist']['items'] None,
'Downloading playlist JSON')
playlist = items['response']['playlist']
next_url = playlist.get('next_url')
items = playlist.get('items', [])
if not items: if not items:
raise ExtractorError('Empty playlist') raise ExtractorError('Empty playlist')
page_no = 2
download_str = 'Downloading playlist JSON page #%d'
while next_url:
items_ = self._download_json(next_url,
None,
download_str % (page_no,))
playlist_ = items_['response']['playlist']
new_items = playlist_.get('items', [])
if not new_items:
break
items += new_items
next_url = playlist_.get('next_url')
page_no += 1
urls = [x['api_url'] for x in items] urls = [x['api_url'] for x in items]
ret = [] ret = []
for index, url in enumerate(urls): for index, url in enumerate(urls):