Skip to content

Commit

Permalink
[youtube] Extract uploader, uploader_id and uploader_url for playlist…
Browse files Browse the repository at this point in the history
…s (#11427, #15018)
  • Loading branch information
Sergey M․ committed Dec 18, 2017
1 parent c10c932 commit 07aeced
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion youtube_dl/extractor/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -2270,6 +2270,19 @@ def _extract_playlist(self, playlist_id):
r'(?s)<h1 class="pl-header-title[^"]*"[^>]*>\s*(.*?)\s*</h1>',
page, 'title', default=None)

_UPLOADER_BASE = r'class=["\']pl-header-details[^>]+>\s*<li>\s*<a[^>]+\bhref='
uploader = self._search_regex(
r'%s["\']/(?:user|channel)/[^>]+>([^<]+)' % _UPLOADER_BASE,
page, 'uploader', default=None)
mobj = re.search(
r'%s(["\'])(?P<path>/(?:user|channel)/(?P<uploader_id>.+?))\1' % _UPLOADER_BASE,
page)
if mobj:
uploader_id = mobj.group('uploader_id')
uploader_url = compat_urlparse.urljoin(url, mobj.group('path'))
else:
uploader_id = uploader_url = None

has_videos = True

if not playlist_title:
Expand All @@ -2280,8 +2293,15 @@ def _extract_playlist(self, playlist_id):
except StopIteration:
has_videos = False

return has_videos, self.playlist_result(
playlist = self.playlist_result(
self._entries(page, playlist_id), playlist_id, playlist_title)
playlist.update({
'uploader': uploader,
'uploader_id': uploader_id,
'uploader_url': uploader_url,
})

return has_videos, playlist

def _check_download_just_video(self, url, playlist_id):
# Check if it's a video-specific URL
Expand Down

0 comments on commit 07aeced

Please sign in to comment.