]> jfr.im git - yt-dlp.git/commitdiff
[youtube] added Youtube Music channel info
authorinsaneracist <redacted>
Wed, 4 Nov 2020 20:00:51 +0000 (12:00 -0800)
committerinsaneracist <redacted>
Wed, 4 Nov 2020 20:07:14 +0000 (12:07 -0800)
youtube_dlc/extractor/youtube.py

index d6550a77668ab1f9f99a3df30a54e1c692942455..cd4e844a0250c502aaf9a7f489ff8640421c2c22 100644 (file)
@@ -2631,6 +2631,12 @@ class YoutubePlaylistIE(YoutubePlaylistBaseInfoExtractor):
     _VIDEO_RE_TPL = r'href="\s*/watch\?v=%s(?:&amp;(?:[^"]*?index=(?P<index>\d+))?(?:[^>]+>(?P<title>[^<]+))?)?'
     _VIDEO_RE = _VIDEO_RE_TPL % r'(?P<id>[0-9A-Za-z_-]{11})'
     IE_NAME = 'youtube:playlist'
+    _YTM_PLAYLIST_PREFIX = 'RDCLAK5uy_'
+    _YTM_CHANNEL_INFO = {
+        'uploader': 'Youtube Music',
+        'uploader_id': 'music',  # or "UC-9-kyTW8ZkZNDHQJ6FgpwQ"
+        'uploader_url': 'https://www.youtube.com/music'
+    }
     _TESTS = [{
         'url': 'https://www.youtube.com/playlist?list=PL4lCao7KL_QFVb7Iudeipvc2BCavECqzc',
         'info_dict': {
@@ -2936,6 +2942,8 @@ def _extract_playlist(self, playlist_id):
             'uploader_id': uploader_id,
             'uploader_url': uploader_url,
         })
+        if playlist_id.startswith(self._YTM_PLAYLIST_PREFIX):
+            playlist.update(self._YTM_CHANNEL_INFO)
 
         return has_videos, playlist
 
@@ -2965,9 +2973,8 @@ def _real_extract(self, url):
         if video:
             return video
 
-        youtube_music_playlist_prefix = 'RDCLAK5uy_'
         if playlist_id.startswith(('RD', 'UL', 'PU')):
-            if not playlist_id.startswith(youtube_music_playlist_prefix):
+            if not playlist_id.startswith(self._YTM_PLAYLIST_PREFIX):
                 # Mixes require a custom extraction process,
                 # Youtube Music playlists act like normal playlists (with randomized order)
                 return self._extract_mix(playlist_id)