diff --git a/youtube_dlc/extractor/deezer.py b/youtube_dlc/extractor/deezer.py index a38b2683d..3031671c1 100644 --- a/youtube_dlc/extractor/deezer.py +++ b/youtube_dlc/extractor/deezer.py @@ -11,28 +11,15 @@ from ..utils import ( ) -class DeezerPlaylistIE(InfoExtractor): - _VALID_URL = r'https?://(?:www\.)?deezer\.com/playlist/(?P[0-9]+)' - _TEST = { - 'url': 'http://www.deezer.com/playlist/176747451', - 'info_dict': { - 'id': '176747451', - 'title': 'Best!', - 'uploader': 'Anonymous', - 'thumbnail': r're:^https?://cdn-images\.deezer\.com/images/cover/.*\.jpg$', - }, - 'playlist_count': 30, - 'skip': 'Only available in .de', - } - - def _real_extract(self, url): - if 'test' not in self._downloader.params: +class DeezerBaseInfoExtractor(InfoExtractor): + def get_data(self, url): + if not self._downloader.params.get('test'): self._downloader.report_warning('For now, this extractor only supports the 30 second previews. Patches welcome!') mobj = re.match(self._VALID_URL, url) - playlist_id = mobj.group('id') + data_id = mobj.group('id') - webpage = self._download_webpage(url, playlist_id) + webpage = self._download_webpage(url, data_id) geoblocking_msg = self._html_search_regex( r'

(.*?)

', webpage, 'geoblocking message', default=None) @@ -45,6 +32,24 @@ class DeezerPlaylistIE(InfoExtractor): r'naboo\.display\(\'[^\']+\',\s*(.*?)\);\n'), webpage, 'data JSON') data = json.loads(data_json) + return data_id, webpage, data + + +class DeezerPlaylistIE(DeezerBaseInfoExtractor): + _VALID_URL = r'https?://(?:www\.)?deezer\.com/(../)?playlist/(?P[0-9]+)' + _TEST = { + 'url': 'http://www.deezer.com/playlist/176747451', + 'info_dict': { + 'id': '176747451', + 'title': 'Best!', + 'uploader': 'anonymous', + 'thumbnail': r're:^https?://(e-)?cdns-images\.dzcdn\.net/images/cover/.*\.jpg$', + }, + 'playlist_count': 29, + } + + def _real_extract(self, url): + playlist_id, webpage, data = self.get_data(url) playlist_title = data.get('DATA', {}).get('TITLE') playlist_uploader = data.get('DATA', {}).get('PARENT_USERNAME') @@ -52,31 +57,23 @@ class DeezerPlaylistIE(InfoExtractor): r'[0-9]+)' + _TEST = { + 'url': 'https://www.deezer.com/fr/album/67505622', + 'info_dict': { + 'id': '67505622', + 'title': 'Last Week', + 'uploader': 'Home Brew', + 'thumbnail': r're:^https?://(e-)?cdns-images\.dzcdn\.net/images/cover/.*\.jpg$', + }, + 'playlist_count': 7, + } + + def _real_extract(self, url): + album_id, webpage, data = self.get_data(url) + + album_title = data.get('DATA', {}).get('ALB_TITLE') + album_uploader = data.get('DATA', {}).get('ART_NAME') + album_thumbnail = self._search_regex( + r'