aboutsummaryrefslogtreecommitdiffstats
path: root/youtube_dl/extractor/deezer.py
diff options
context:
space:
mode:
authorLucas <lucas.bergeron@outlook.fr>2019-08-18 23:39:06 +0200
committerLucas <lucas.bergeron@outlook.fr>2019-08-18 23:39:06 +0200
commit480f2d89f6b461123e24a1288fddc287c3838d37 (patch)
treea2be6ea7f5102d6da191323d2d0a76658cd42885 /youtube_dl/extractor/deezer.py
parent0b3cb7df0d567c2dbe9e30f3a30c3020fc8962fc (diff)
downloadhypervideo-pre-480f2d89f6b461123e24a1288fddc287c3838d37.tar.lz
hypervideo-pre-480f2d89f6b461123e24a1288fddc287c3838d37.tar.xz
hypervideo-pre-480f2d89f6b461123e24a1288fddc287c3838d37.zip
Add base info extractor class
Diffstat (limited to 'youtube_dl/extractor/deezer.py')
-rw-r--r--youtube_dl/extractor/deezer.py36
1 files changed, 21 insertions, 15 deletions
diff --git a/youtube_dl/extractor/deezer.py b/youtube_dl/extractor/deezer.py
index 0aff4074e..6a21f2ffa 100644
--- a/youtube_dl/extractor/deezer.py
+++ b/youtube_dl/extractor/deezer.py
@@ -10,27 +10,16 @@ from ..utils import (
orderedSet,
)
-class DeezerPlaylistIE(InfoExtractor):
- _VALID_URL = r'https?://(?:www\.)?deezer\.com/(../)?playlist/(?P<id>[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,
- }
+class DeezerBaseInfoExtractor(InfoExtractor):
- def _real_extract(self, url):
+ def get_data(self, url):
if 'test' not in self._downloader.params:
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')
+ id = mobj.group('id')
- webpage = self._download_webpage(url, playlist_id)
+ webpage = self._download_webpage(url, id)
geoblocking_msg = self._html_search_regex(
r'<p class="soon-txt">(.*?)</p>', webpage, 'geoblocking message',
default=None)
@@ -43,6 +32,23 @@ class DeezerPlaylistIE(InfoExtractor):
r'naboo\.display\(\'[^\']+\',\s*(.*?)\);\n'),
webpage, 'data JSON')
data = json.loads(data_json)
+ return id, webpage, data
+
+class DeezerPlaylistIE(DeezerBaseInfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?deezer\.com/(../)?playlist/(?P<id>[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')