2 from __future__ import unicode_literals
6 from ..compat import compat_urlparse
7 from .common import InfoExtractor
10 class JamendoIE(InfoExtractor):
11 _VALID_URL = r'https?://(?:www\.)?jamendo\.com/track/(?P<id>[0-9]+)/(?P<display_id>[^/?#&]+)'
13 'url': 'https://www.jamendo.com/track/196219/stories-from-emona-i',
14 'md5': '6e9e82ed6db98678f171c25a8ed09ffd',
17 'display_id': 'stories-from-emona-i',
19 'title': 'Stories from Emona I',
20 'thumbnail': r're:^https?://.*\.jpg'
24 def _real_extract(self, url):
25 mobj = self._VALID_URL_RE.match(url)
26 track_id = mobj.group('id')
27 display_id = mobj.group('display_id')
29 webpage = self._download_webpage(url, display_id)
31 title = self._html_search_meta('name', webpage, 'title')
34 'url': 'https://%s.jamendo.com/?trackid=%s&format=%s&from=app-97dab294'
35 % (sub_domain, track_id, format_id),
36 'format_id': format_id,
39 } for quality, (format_id, sub_domain, ext) in enumerate((
40 ('mp31', 'mp3l', 'mp3'),
41 ('mp32', 'mp3d', 'mp3'),
42 ('ogg1', 'ogg', 'ogg'),
43 ('flac', 'flac', 'flac'),
45 self._sort_formats(formats)
47 thumbnail = self._html_search_meta(
48 'image', webpage, 'thumbnail', fatal=False)
52 'display_id': display_id,
53 'thumbnail': thumbnail,
59 class JamendoAlbumIE(InfoExtractor):
60 _VALID_URL = r'https?://(?:www\.)?jamendo\.com/album/(?P<id>[0-9]+)/(?P<display_id>[\w-]+)'
62 'url': 'https://www.jamendo.com/album/121486/duck-on-cover',
65 'title': 'Duck On Cover'
68 'md5': 'e1a2fcb42bda30dfac990212924149a8',
75 'md5': '1f358d7b2f98edfe90fd55dac0799d50',
79 'title': 'Without Your Ghost'
87 def _real_extract(self, url):
88 mobj = self._VALID_URL_RE.match(url)
89 album_id = mobj.group('id')
91 webpage = self._download_webpage(url, mobj.group('display_id'))
93 title = self._html_search_meta('name', webpage, 'title')
97 compat_urlparse.urljoin(url, m.group('path')),
98 ie=JamendoIE.ie_key(),
99 video_id=self._search_regex(
100 r'/track/(\d+)', m.group('path'),
101 'track id', default=None))
102 for m in re.finditer(
103 r'<a[^>]+href=(["\'])(?P<path>(?:(?!\1).)+)\1[^>]+class=["\'][^>]*js-trackrow-albumpage-link',
107 return self.playlist_result(entries, album_id, title)