2 from __future__ import unicode_literals
5 from collections import namedtuple
7 from ..compat import compat_urlparse
8 from .common import InfoExtractor
10 FormatData = namedtuple('FormatData', [
11 'format_id', 'sub_domain', 'ext', 'quality'])
14 class JamendoIE(InfoExtractor):
15 _VALID_URL = r'https?://(?:www\.)?jamendo\.com/track/(?P<id>[0-9]+)/(?P<display_id>[\w-]+)'
17 'url': 'https://www.jamendo.com/track/196219/stories-from-emona-i',
18 'md5': '6e9e82ed6db98678f171c25a8ed09ffd',
21 'display_id': 'stories-from-emona-i',
23 'title': 'Stories from Emona I',
24 'thumbnail': 're:^https?://.*\.jpg'
28 def _real_extract(self, url):
29 url_data = self._VALID_URL_RE.match(url)
30 track_id = url_data.group('id')
31 display_id = url_data.group('display_id')
32 webpage = self._download_webpage(url, display_id)
34 thumbnail = self._html_search_meta(
35 'image', webpage, 'thumbnail', fatal=False)
36 title = self._html_search_meta('name', webpage, 'title')
38 url_template = 'https://%s.jamendo.com/?trackid=%s&format=%s&from=app-97dab294'
41 format_id='mp31', sub_domain='mp3l', ext='mp3', quality=0),
43 format_id='mp32', sub_domain='mp3d', ext='mp3', quality=1),
45 format_id='ogg1', sub_domain='ogg', ext='ogg', quality=2),
47 format_id='flac', sub_domain='flac', ext='flac', quality=3),
51 'format_id': fd.format_id,
52 'url': url_template % (fd.sub_domain, track_id, fd.format_id),
58 self._check_formats(formats, video_id=display_id)
61 'display_id': display_id,
62 'thumbnail': thumbnail,
68 class JamendoAlbumIE(InfoExtractor):
69 _VALID_URL = r'https?://(?:www\.)?jamendo\.com/album/(?P<id>[0-9]+)/(?P<display_id>[\w-]+)'
71 'url': 'https://www.jamendo.com/album/121486/duck-on-cover',
74 'title': 'Duck On Cover'
76 'playlist_mincount': 2,
79 'md5': 'e1a2fcb42bda30dfac990212924149a8',
87 'md5': '1f358d7b2f98edfe90fd55dac0799d50',
91 'title': 'Without Your Ghost'
100 def _real_extract(self, url):
101 url_data = self._VALID_URL_RE.match(url)
102 album_id = url_data.group('id')
103 webpage = self._download_webpage(url, url_data.group('display_id'))
105 title = self._html_search_meta('name', webpage, 'title')
107 track_paths = re.findall(r'<a href="(.+)" class="link-wrap js-trackrow-albumpage-link" itemprop="url">', webpage)
109 self.url_result(compat_urlparse.urljoin(url, path), ie=JamendoIE.ie_key())
110 for path in track_paths