]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/jukebox.py
3 from .common
import InfoExtractor
9 class JukeboxIE(InfoExtractor
):
10 _VALID_URL
= r
'^http://www\.jukebox\.es\/.+[,](?P<video_id>[a-z0-9]+).html'
11 _IFRAME
= r
'<iframe .*src="(?P<iframe>[^"]*)".*>'
12 _VIDEO_URL
= r
'"config":{"file":"(?P<video_url>http:[^"]+[.](?P<video_ext>[^.?]+)[?]mdtk=[0-9]+)"'
13 _TITLE
= r
'<h1 class="inline">(?P<title>[^<]+)</h1>.*<span id="infos_article_artist">(?P<artist>[^<]+)</span>'
14 _NOT_AVAILABLE
= r
'<span>Este video no está disponible por el momento [!]</span>'
15 _IS_YOUTUBE
= r
'config":{"file":"(?P<youtube_url>http:[\\][/][\\][/]www[.]youtube[.]com[\\][/]watch[?]v=[^"]+)"'
18 def _real_extract(self
, url
):
19 mobj
= re
.match(self
._VALID
_URL
, url
)
21 raise ExtractorError(u
'Invalid URL: %s' % url
)
22 video_id
= mobj
.group('video_id')
24 html
= self
._download
_webpage
(url
, video_id
)
26 mobj
= re
.search(self
._IFRAME
, html
)
28 raise ExtractorError(u
'Cannot extract iframe url')
29 iframe_url
= unescapeHTML(mobj
.group('iframe'))
31 iframe_html
= self
._download
_webpage
(iframe_url
, video_id
, 'Downloading iframe')
32 mobj
= re
.search(self
._NOT
_AVAILABLE
, iframe_html
)
34 raise ExtractorError(u
'Video is not available(in your country?)!')
36 self
.report_extraction(video_id
)
38 mobj
= re
.search(self
._VIDEO
_URL
, iframe_html
)
40 mobj
= re
.search(self
._IS
_YOUTUBE
, iframe_html
)
42 raise ExtractorError(u
'Cannot extract video url')
43 youtube_url
= unescapeHTML(mobj
.group('youtube_url')).replace('\/','/')
44 self
.to_screen(u
'Youtube video detected')
45 return self
.url_result(youtube_url
,ie
='Youtube')
46 video_url
= unescapeHTML(mobj
.group('video_url')).replace('\/','/')
47 video_ext
= unescapeHTML(mobj
.group('video_ext'))
49 mobj
= re
.search(self
._TITLE
, html
)
51 raise ExtractorError(u
'Cannot extract title')
52 title
= unescapeHTML(mobj
.group('title'))
53 artist
= unescapeHTML(mobj
.group('artist'))
55 return [{'id': video_id
,
57 'title': artist
+ '-' + title
,