4 from .common import InfoExtractor
10 class JukeboxIE(InfoExtractor):
11 _VALID_URL = r'^http://www\.jukebox?\..+?\/.+[,](?P<video_id>[a-z0-9\-]+)\.html'
12 _IFRAME = r'<iframe .*src="(?P<iframe>[^"]*)".*>'
13 _VIDEO_URL = r'"config":{"file":"(?P<video_url>http:[^"]+[.](?P<video_ext>[^.?]+)[?]mdtk=[0-9]+)"'
14 _TITLE = r'<h1 class="inline">(?P<title>[^<]+)</h1>.*<span id="infos_article_artist">(?P<artist>[^<]+)</span>'
15 _IS_YOUTUBE = r'config":{"file":"(?P<youtube_url>http:[\\][/][\\][/]www[.]youtube[.]com[\\][/]watch[?]v=[^"]+)"'
17 def _real_extract(self, url):
18 mobj = re.match(self._VALID_URL, url)
19 video_id = mobj.group('video_id')
21 html = self._download_webpage(url, video_id)
23 mobj = re.search(self._IFRAME, html)
25 raise ExtractorError(u'Cannot extract iframe url')
26 iframe_url = unescapeHTML(mobj.group('iframe'))
28 iframe_html = self._download_webpage(iframe_url, video_id, 'Downloading iframe')
29 mobj = re.search(r'class="jkb_waiting"', iframe_html)
31 raise ExtractorError(u'Video is not available(in your country?)!')
33 self.report_extraction(video_id)
35 mobj = re.search(self._VIDEO_URL, iframe_html)
37 mobj = re.search(self._IS_YOUTUBE, iframe_html)
39 raise ExtractorError(u'Cannot extract video url')
40 youtube_url = unescapeHTML(mobj.group('youtube_url')).replace('\/','/')
41 self.to_screen(u'Youtube video detected')
42 return self.url_result(youtube_url,ie='Youtube')
43 video_url = unescapeHTML(mobj.group('video_url')).replace('\/','/')
44 video_ext = unescapeHTML(mobj.group('video_ext'))
46 mobj = re.search(self._TITLE, html)
48 raise ExtractorError(u'Cannot extract title')
49 title = unescapeHTML(mobj.group('title'))
50 artist = unescapeHTML(mobj.group('artist'))
52 return [{'id': video_id,
54 'title': artist + '-' + title,