1
0
mirror of https://github.com/l1ving/youtube-dl synced 2024-11-22 09:52:52 +08:00
youtube-dl/youtube_dl/extractor/jukebox.py

60 lines
2.1 KiB
Python
Raw Normal View History

2014-03-10 01:13:17 +08:00
from __future__ import unicode_literals
2013-06-25 19:28:59 +08:00
import re
from .common import InfoExtractor
from ..utils import (
ExtractorError,
2014-03-10 01:13:17 +08:00
RegexNotFoundError,
2013-06-25 19:28:59 +08:00
unescapeHTML,
)
2014-03-10 01:13:17 +08:00
2013-06-25 19:28:59 +08:00
class JukeboxIE(InfoExtractor):
_VALID_URL = r'^http://www\.jukebox?\..+?\/.+[,](?P<id>[a-z0-9\-]+)\.html'
2014-03-10 01:13:17 +08:00
_TEST = {
'url': 'http://www.jukebox.es/kosheen/videoclip,pride,r303r.html',
'info_dict': {
'id': 'r303r',
'ext': 'flv',
'title': 'Kosheen-En Vivo Pride',
'uploader': 'Kosheen',
},
}
2013-06-25 19:28:59 +08:00
def _real_extract(self, url):
video_id = self._match_id(url)
2013-06-25 19:28:59 +08:00
html = self._download_webpage(url, video_id)
2014-03-10 01:13:17 +08:00
iframe_url = unescapeHTML(self._search_regex(r'<iframe .*src="([^"]*)"', html, 'iframe url'))
2013-06-25 19:28:59 +08:00
iframe_html = self._download_webpage(iframe_url, video_id, 'Downloading iframe')
2014-03-10 01:13:17 +08:00
if re.search(r'class="jkb_waiting"', iframe_html) is not None:
raise ExtractorError('Video is not available(in your country?)!')
2013-06-25 19:28:59 +08:00
self.report_extraction(video_id)
2014-03-10 01:13:17 +08:00
try:
video_url = self._search_regex(r'"config":{"file":"(?P<video_url>http:[^"]+\?mdtk=[0-9]+)"',
2014-11-24 04:39:15 +08:00
iframe_html, 'video url')
2014-03-10 01:13:17 +08:00
video_url = unescapeHTML(video_url).replace('\/', '/')
except RegexNotFoundError:
youtube_url = self._search_regex(
r'config":{"file":"(http:\\/\\/www\.youtube\.com\\/watch\?v=[^"]+)"',
iframe_html, 'youtube url')
youtube_url = unescapeHTML(youtube_url).replace('\/', '/')
self.to_screen('Youtube video detected')
return self.url_result(youtube_url, ie='Youtube')
title = self._html_search_regex(r'<h1 class="inline">([^<]+)</h1>',
2014-11-24 04:39:15 +08:00
html, 'title')
2014-03-10 01:13:17 +08:00
artist = self._html_search_regex(r'<span id="infos_article_artist">([^<]+)</span>',
2014-11-24 04:39:15 +08:00
html, 'artist')
2014-03-10 01:13:17 +08:00
return {
'id': video_id,
'url': video_url,
'title': artist + '-' + title,
'uploader': artist,
}