diff --git a/youtube_dl/extractor/bandcamp.py b/youtube_dl/extractor/bandcamp.py index f14b407dc..32b0313bf 100644 --- a/youtube_dl/extractor/bandcamp.py +++ b/youtube_dl/extractor/bandcamp.py @@ -22,6 +22,7 @@ from ..utils import ( unified_strdate, unified_timestamp, url_or_none, + RegexNotFoundError, ) @@ -415,3 +416,52 @@ class BandcampWeeklyIE(InfoExtractor): 'episode_id': compat_str(video_id), 'formats': formats } + + +class BandcampUserIE(InfoExtractor): + IE_NAME = 'Bandcamp:user' + _VALID_URL = r'https?://(?:(?P[^.]+)\.)?bandcamp\.com' + + _TESTS = [{ + 'url': 'https://adrianvonziegler.bandcamp.com', + 'info_dict': { + 'id': 'adrianvonziegler', + 'title': 'Albums of adrianvonziegler', + }, + 'playlist_mincount': 20, + }, { + 'url': 'http://dotscale.bandcamp.com', + 'info_dict': { + 'id': 'dotscale', + 'title': 'Albums of dotscale', + }, + 'playlist_count': 1, + }] + + def _real_extract(self, url): + mobj = re.match(self._VALID_URL, url) + uploader = mobj.group('subdomain') + + webpage = self._download_webpage(url, uploader) + + album_elements = re.findall(r'', webpage) + + if not album_elements: + raise ExtractorError('The page doesn\'t contain any albums') + + entries = [ + self.url_result( + compat_urlparse.urljoin(url, 'album/{}'.format(album_id)), + ie=BandcampAlbumIE.ie_key(), + video_id='{}-{}'.format(uploader, album_id), + video_title=album_id, + ) + for album_id in album_elements + ] + + return { + '_type': 'playlist', + 'id': uploader, + 'title': 'Albums of {}'.format(uploader), + 'entries': entries, + } diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index ae7079a6a..f106f0d02 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -80,7 +80,12 @@ from .awaan import ( ) from .azmedien import AZMedienIE from .baidu import BaiduVideoIE -from .bandcamp import BandcampIE, BandcampAlbumIE, BandcampWeeklyIE +from .bandcamp import ( + BandcampIE, + BandcampAlbumIE, + BandcampWeeklyIE, + BandcampUserIE, +) from .bbc import ( BBCCoUkIE, BBCCoUkArticleIE,