mirror of
https://github.com/soimort/you-get.git
synced 2025-01-23 21:45:02 +03:00
[youtube] fix playlist extraction & comprehensive error output
This commit is contained in:
parent
980ba1bc2e
commit
3ab931a6a0
@ -157,7 +157,12 @@ class YouTube(VideoExtractor):
|
|||||||
log.wtf('[Failed] Unsupported URL pattern.')
|
log.wtf('[Failed] Unsupported URL pattern.')
|
||||||
|
|
||||||
video_page = get_content('https://www.youtube.com/playlist?list=%s' % playlist_id)
|
video_page = get_content('https://www.youtube.com/playlist?list=%s' % playlist_id)
|
||||||
ytInitialData = json.loads(match1(video_page, r'window\["ytInitialData"\]\s*=\s*(.+);'))
|
playlist_json_serialized = match1(video_page, r'window\["ytInitialData"\]\s*=\s*(.+);', r'var\s+ytInitialData\s*=\s*([^;]+);')
|
||||||
|
|
||||||
|
if len(playlist_json_serialized) == 0:
|
||||||
|
log.wtf('[Failed] Unable to extract playlist data')
|
||||||
|
|
||||||
|
ytInitialData = json.loads(playlist_json_serialized[0])
|
||||||
|
|
||||||
tab0 = ytInitialData['contents']['twoColumnBrowseResultsRenderer']['tabs'][0]
|
tab0 = ytInitialData['contents']['twoColumnBrowseResultsRenderer']['tabs'][0]
|
||||||
itemSection0 = tab0['tabRenderer']['content']['sectionListRenderer']['contents'][0]
|
itemSection0 = tab0['tabRenderer']['content']['sectionListRenderer']['contents'][0]
|
||||||
|
Loading…
Reference in New Issue
Block a user