]> jfr.im git - yt-dlp.git/commitdiff
[extractor/bandcamp] Extract `uploader_url`
authorpukkandan <redacted>
Thu, 1 Sep 2022 20:08:21 +0000 (01:38 +0530)
committerpukkandan <redacted>
Thu, 1 Sep 2022 20:31:57 +0000 (02:01 +0530)
Closes #4755

yt_dlp/extractor/bandcamp.py

index b34fcb10817b7f9554a6b600f22f2df4ae546788..2dae49e77007d3c1447253353a725e55d1502e9e 100644 (file)
@@ -21,7 +21,7 @@
 
 
 class BandcampIE(InfoExtractor):
-    _VALID_URL = r'https?://[^/]+\.bandcamp\.com/track/(?P<id>[^/?#&]+)'
+    _VALID_URL = r'https?://(?P<uploader>[^/]+)\.bandcamp\.com/track/(?P<id>[^/?#&]+)'
     _EMBED_REGEX = [r'<meta property="og:url"[^>]*?content="(?P<url>.*?bandcamp\.com.*?)"']
     _TESTS = [{
         'url': 'http://youtube-dl.bandcamp.com/track/youtube-dl-test-song',
@@ -85,7 +85,7 @@ def _extract_data_attr(self, webpage, video_id, attr='tralbum', fatal=True):
             attr + ' data', group=2), video_id, fatal=fatal)
 
     def _real_extract(self, url):
-        title = self._match_id(url)
+        title, uploader = self._match_valid_url(url).group('id', 'uploader')
         webpage = self._download_webpage(url, title)
         tralbum = self._extract_data_attr(webpage, title)
         thumbnail = self._og_search_thumbnail(webpage)
@@ -197,6 +197,8 @@ def _real_extract(self, url):
             'title': title,
             'thumbnail': thumbnail,
             'uploader': artist,
+            'uploader_id': uploader,
+            'uploader_url': f'https://{uploader}.bandcamp.com',
             'timestamp': timestamp,
             'release_timestamp': unified_timestamp(tralbum.get('album_release_date')),
             'duration': duration,