[youtube:channel] Fix the extraction of autogenerated channels
The ajax pages are empty, now it looks directly in the channel's /videos page
This commit is contained in:
parent
feee2ecfa9
commit
b9643eed7c
1 changed files with 24 additions and 13 deletions
|
@ -1594,20 +1594,31 @@ class YoutubeChannelIE(InfoExtractor):
|
||||||
# Download channel page
|
# Download channel page
|
||||||
channel_id = mobj.group(1)
|
channel_id = mobj.group(1)
|
||||||
video_ids = []
|
video_ids = []
|
||||||
|
url = 'https://www.youtube.com/channel/%s/videos' % channel_id
|
||||||
|
channel_page = self._download_webpage(url, channel_id)
|
||||||
|
if re.search(r'channel-header-autogenerated-label', channel_page) is not None:
|
||||||
|
autogenerated = True
|
||||||
|
else:
|
||||||
|
autogenerated = False
|
||||||
|
|
||||||
# Download all channel pages using the json-based channel_ajax query
|
if autogenerated:
|
||||||
for pagenum in itertools.count(1):
|
# The videos are contained in a single page
|
||||||
url = self._MORE_PAGES_URL % (pagenum, channel_id)
|
# the ajax pages can't be used, they are empty
|
||||||
page = self._download_webpage(url, channel_id,
|
video_ids = self.extract_videos_from_page(channel_page)
|
||||||
u'Downloading page #%s' % pagenum)
|
else:
|
||||||
|
# Download all channel pages using the json-based channel_ajax query
|
||||||
page = json.loads(page)
|
for pagenum in itertools.count(1):
|
||||||
|
url = self._MORE_PAGES_URL % (pagenum, channel_id)
|
||||||
ids_in_page = self.extract_videos_from_page(page['content_html'])
|
page = self._download_webpage(url, channel_id,
|
||||||
video_ids.extend(ids_in_page)
|
u'Downloading page #%s' % pagenum)
|
||||||
|
|
||||||
if self._MORE_PAGES_INDICATOR not in page['load_more_widget_html']:
|
page = json.loads(page)
|
||||||
break
|
|
||||||
|
ids_in_page = self.extract_videos_from_page(page['content_html'])
|
||||||
|
video_ids.extend(ids_in_page)
|
||||||
|
|
||||||
|
if self._MORE_PAGES_INDICATOR not in page['load_more_widget_html']:
|
||||||
|
break
|
||||||
|
|
||||||
self._downloader.to_screen(u'[youtube] Channel %s: Found %i videos' % (channel_id, len(video_ids)))
|
self._downloader.to_screen(u'[youtube] Channel %s: Found %i videos' % (channel_id, len(video_ids)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue