]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/jamendo.py
c218276184ab4acf9086404cdb679a74e24f353b
2 from __future__
import unicode_literals
6 from ..compat
import compat_urlparse
7 from .common
import InfoExtractor
8 from ..utils
import parse_duration
11 class JamendoBaseIE(InfoExtractor
):
12 def _extract_meta(self
, webpage
, fatal
=True):
13 title
= self
._og
_search
_title
(
14 webpage
, default
=None) or self
._search
_regex
(
15 r
'<title>([^<]+)', webpage
,
16 'title', default
=None)
18 title
= self
._search
_regex
(
19 r
'(.+?)\s*\|\s*Jamendo Music', title
, 'title', default
=None)
21 title
= self
._html
_search
_meta
(
22 'name', webpage
, 'title', fatal
=fatal
)
23 mobj
= re
.search(r
'(.+) - (.+)', title
or '')
24 artist
, second
= mobj
.groups() if mobj
else [None] * 2
25 return title
, artist
, second
28 class JamendoIE(JamendoBaseIE
):
32 licensing\.jamendo\.com/[^/]+|
33 (?:www\.)?jamendo\.com
35 /track/(?P<id>[0-9]+)/(?P<display_id>[^/?#&]+)
38 'url': 'https://www.jamendo.com/track/196219/stories-from-emona-i',
39 'md5': '6e9e82ed6db98678f171c25a8ed09ffd',
42 'display_id': 'stories-from-emona-i',
44 'title': 'Maya Filipič - Stories from Emona I',
45 'artist': 'Maya Filipič',
46 'track': 'Stories from Emona I',
48 'thumbnail': r
're:^https?://.*\.jpg'
51 'url': 'https://licensing.jamendo.com/en/track/1496667/energetic-rock',
52 'only_matching': True,
55 def _real_extract(self
, url
):
56 mobj
= self
._VALID
_URL
_RE
.match(url
)
57 track_id
= mobj
.group('id')
58 display_id
= mobj
.group('display_id')
60 webpage
= self
._download
_webpage
(
61 'https://www.jamendo.com/track/%s/%s' % (track_id
, display_id
),
64 title
, artist
, track
= self
._extract
_meta
(webpage
)
67 'url': 'https://%s.jamendo.com/?trackid=%s&format=%s&from=app-97dab294'
68 % (sub_domain
, track_id
, format_id
),
69 'format_id': format_id
,
72 } for quality
, (format_id
, sub_domain
, ext
) in enumerate((
73 ('mp31', 'mp3l', 'mp3'),
74 ('mp32', 'mp3d', 'mp3'),
75 ('ogg1', 'ogg', 'ogg'),
76 ('flac', 'flac', 'flac'),
78 self
._sort
_formats
(formats
)
80 thumbnail
= self
._html
_search
_meta
(
81 'image', webpage
, 'thumbnail', fatal
=False)
82 duration
= parse_duration(self
._search
_regex
(
83 r
'<span[^>]+itemprop=["\']duration
["\'][^>]+content=["\'](.+?
)["\']',
84 webpage, 'duration', fatal=False))
88 'display_id': display_id,
89 'thumbnail': thumbnail,
98 class JamendoAlbumIE(JamendoBaseIE):
99 _VALID_URL = r'https?://(?:www\.)?jamendo\.com/album/(?P<id>[0-9]+)/(?P<display_id>[\w-]+)'
101 'url': 'https://www.jamendo.com/album/121486/duck-on-cover',
104 'title': 'Shearer - Duck On Cover'
107 'md5': 'e1a2fcb42bda30dfac990212924149a8',
111 'title': 'Shearer - Warmachine',
113 'track': 'Warmachine',
116 'md5': '1f358d7b2f98edfe90fd55dac0799d50',
120 'title': 'Shearer - Without Your Ghost',
122 'track': 'Without Your Ghost',
130 def _real_extract(self, url):
131 mobj = self._VALID_URL_RE.match(url)
132 album_id = mobj.group('id')
134 webpage = self._download_webpage(url, mobj.group('display_id'))
136 title, artist, album = self._extract_meta(webpage, fatal=False)
139 '_type': 'url_transparent',
140 'url': compat_urlparse.urljoin(url, m.group('path')),
141 'ie_key': JamendoIE.ie_key(),
142 'id': self._search_regex(
143 r'/track/(\d+)', m.group('path'), 'track id', default=None),
146 } for m in re.finditer(
147 r'<a[^>]+href=(["\'])(?P
<path
>(?
:(?
!\
1).)+)\
1[^
>]+class=["\'][^>]*js-trackrow-albumpage-link',
150 return self.playlist_result(entries, album_id, title)