|
|
@ -1,28 +1,32 @@
|
|
|
|
# coding: utf-8
|
|
|
|
# coding: utf-8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
|
|
|
from .common import InfoExtractor
|
|
|
|
from ..utils import (
|
|
|
|
from ..utils import (
|
|
|
|
int_or_none,
|
|
|
|
int_or_none,
|
|
|
|
parse_duration,
|
|
|
|
mimetype2ext,
|
|
|
|
|
|
|
|
parse_codecs,
|
|
|
|
xpath_element,
|
|
|
|
xpath_element,
|
|
|
|
xpath_text,
|
|
|
|
xpath_text,
|
|
|
|
xpath_attr,
|
|
|
|
|
|
|
|
urlencode_postdata,
|
|
|
|
|
|
|
|
unescapeHTML,
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VideaIE(InfoExtractor):
|
|
|
|
class VideaIE(InfoExtractor):
|
|
|
|
_VALID_URL = r'https?://(?:.+?\.)?videa\.hu/videok/(?P<id>[^#?]+)'
|
|
|
|
_VALID_URL = r'''(?x)
|
|
|
|
|
|
|
|
https?://
|
|
|
|
|
|
|
|
videa\.hu/
|
|
|
|
|
|
|
|
(?:
|
|
|
|
|
|
|
|
videok/(?:[^/]+/)*[^?#&]+-|
|
|
|
|
|
|
|
|
player\?.*?\bv=|
|
|
|
|
|
|
|
|
player/v/
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
(?P<id>[^?#&]+)
|
|
|
|
|
|
|
|
'''
|
|
|
|
_TESTS = [{
|
|
|
|
_TESTS = [{
|
|
|
|
'url': 'http://videa.hu/videok/allatok/az-orult-kigyasz-285-kigyot-kigyo-8YfIAjxwWGwT8HVQ',
|
|
|
|
'url': 'http://videa.hu/videok/allatok/az-orult-kigyasz-285-kigyot-kigyo-8YfIAjxwWGwT8HVQ',
|
|
|
|
'md5': '97a7af41faeaffd9f1fc864a7c7e7603',
|
|
|
|
'md5': '97a7af41faeaffd9f1fc864a7c7e7603',
|
|
|
|
'info_dict': {
|
|
|
|
'info_dict': {
|
|
|
|
'id': '8YfIAjxwWGwT8HVQ',
|
|
|
|
'id': '8YfIAjxwWGwT8HVQ',
|
|
|
|
'display_id': '8YfIAjxwWGwT8HVQ',
|
|
|
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Az őrült kígyász 285 kígyót enged szabadon',
|
|
|
|
'title': 'Az őrült kígyász 285 kígyót enged szabadon',
|
|
|
|
'thumbnail': 'http://videa.hu/static/still/1.4.1.1007274.1204470.3',
|
|
|
|
'thumbnail': 'http://videa.hu/static/still/1.4.1.1007274.1204470.3',
|
|
|
@ -31,68 +35,55 @@ class VideaIE(InfoExtractor):
|
|
|
|
}, {
|
|
|
|
}, {
|
|
|
|
'url': 'http://videa.hu/videok/origo/jarmuvek/supercars-elozes-jAHDWfWSJH5XuFhH',
|
|
|
|
'url': 'http://videa.hu/videok/origo/jarmuvek/supercars-elozes-jAHDWfWSJH5XuFhH',
|
|
|
|
'only_matching': True,
|
|
|
|
'only_matching': True,
|
|
|
|
|
|
|
|
}, {
|
|
|
|
|
|
|
|
'url': 'http://videa.hu/player?v=8YfIAjxwWGwT8HVQ',
|
|
|
|
|
|
|
|
'only_matching': True,
|
|
|
|
|
|
|
|
}, {
|
|
|
|
|
|
|
|
'url': 'http://videa.hu/player/v/8YfIAjxwWGwT8HVQ?autoplay=1',
|
|
|
|
|
|
|
|
'only_matching': True,
|
|
|
|
}]
|
|
|
|
}]
|
|
|
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
def _real_extract(self, url):
|
|
|
|
video_id = self._match_id(url)
|
|
|
|
video_id = self._match_id(url)
|
|
|
|
|
|
|
|
|
|
|
|
video_data = self._download_json("http://videa.hu/oembed/?" + urlencode_postdata({"url": url.split('?')[0], "format": "json"}), video_id)
|
|
|
|
info = self._download_xml(
|
|
|
|
video_url = self._search_regex(
|
|
|
|
'http://videa.hu/videaplayer_get_xml.php', video_id,
|
|
|
|
r'src="(.+?)"', video_data.get('html'), 'embed url')
|
|
|
|
query={'v': video_id})
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
video = xpath_element(info, './/video', 'video', fatal=True)
|
|
|
|
'_type': 'url_transparent',
|
|
|
|
sources = xpath_element(info, './/video_sources', 'sources', fatal=True)
|
|
|
|
'url': video_url,
|
|
|
|
|
|
|
|
'ie_key': 'VideaEmbed'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VideaEmbedIE(InfoExtractor):
|
|
|
|
title = xpath_text(video, './title', fatal=True)
|
|
|
|
_VALID_URL = r'(?P<protocol>https?:)(?P<baseurl>//(?:.+?\.)?videa\.hu)/player(?:\?v=|/v/)(?P<id>[^/#?]+)';
|
|
|
|
|
|
|
|
_TESTS = [{
|
|
|
|
|
|
|
|
'url': 'http://videa.hu/player?v=8YfIAjxwWGwT8HVQ',
|
|
|
|
|
|
|
|
'md5': '97a7af41faeaffd9f1fc864a7c7e7603',
|
|
|
|
|
|
|
|
'info_dict': {
|
|
|
|
|
|
|
|
'id': '8YfIAjxwWGwT8HVQ',
|
|
|
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
|
|
|
'title': 'Az őrült kígyász 285 kígyót enged szabadon',
|
|
|
|
|
|
|
|
'thumbnail': 'http://videa.hu/static/still/1.4.1.1007274.1204470.3',
|
|
|
|
|
|
|
|
'duration': 21
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
}, {
|
|
|
|
|
|
|
|
'url': 'http://videa.hu/player?v=jAHDWfWSJH5XuFhH',
|
|
|
|
|
|
|
|
'only_matching': True,
|
|
|
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
formats = []
|
|
|
|
def _extract_url(webpage):
|
|
|
|
for source in sources.findall('./video_source'):
|
|
|
|
mobj = re.search(
|
|
|
|
source_url = source.text
|
|
|
|
r'<iframe[^>]+src=(["\'])(?P<url>(?:https?:)?//(?:.+?\.)?videa\.hu/player(?:\?v=|/v/)[^/#?]+)\1',
|
|
|
|
if not source_url:
|
|
|
|
webpage)
|
|
|
|
continue
|
|
|
|
if mobj:
|
|
|
|
f = parse_codecs(source.get('codecs'))
|
|
|
|
return mobj.group('url')
|
|
|
|
f.update({
|
|
|
|
|
|
|
|
'url': source_url,
|
|
|
|
|
|
|
|
'ext': mimetype2ext(source.get('mimetype')) or 'mp4',
|
|
|
|
|
|
|
|
'format_id': source.get('name'),
|
|
|
|
|
|
|
|
'width': int_or_none(source.get('width')),
|
|
|
|
|
|
|
|
'height': int_or_none(source.get('height')),
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
formats.append(f)
|
|
|
|
|
|
|
|
self._sort_formats(formats)
|
|
|
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
thumbnail = xpath_text(video, './poster_src')
|
|
|
|
protocol, base_url, display_id = re.search(self._VALID_URL, url).groups()
|
|
|
|
duration = int_or_none(xpath_text(video, './duration'))
|
|
|
|
xml = self._download_xml(protocol + base_url + "/flvplayer_get_video_xml.php?v=" + display_id, display_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
medias = []
|
|
|
|
age_limit = None
|
|
|
|
|
|
|
|
is_adult = xpath_text(video, './is_adult_content', default=None)
|
|
|
|
for xml_media in xml.findall('video') + xml.findall('audio'):
|
|
|
|
if is_adult:
|
|
|
|
media_url = protocol + xpath_attr(xml_media, 'versions/version', 'video_url')
|
|
|
|
age_limit = 18 if is_adult == '1' else 0
|
|
|
|
media = {
|
|
|
|
|
|
|
|
'id': display_id,
|
|
|
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
|
|
|
'title': xpath_text(xml_media, 'title', 'title', True),
|
|
|
|
|
|
|
|
'duration': parse_duration(xpath_text(xml_media, 'duration')),
|
|
|
|
|
|
|
|
'thumbnail': protocol + xpath_text(xml_media, 'still', 'still', True),
|
|
|
|
|
|
|
|
'url': media_url,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
medias.append(media)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(medias) > 1:
|
|
|
|
return {
|
|
|
|
self._downloader.report_warning(
|
|
|
|
'id': video_id,
|
|
|
|
'found multiple medias; please '
|
|
|
|
'title': title,
|
|
|
|
'report this with the video URL to http://yt-dl.org/bug')
|
|
|
|
'thumbnail': thumbnail,
|
|
|
|
if not medias:
|
|
|
|
'duration': duration,
|
|
|
|
raise ExtractorError('No media entries found')
|
|
|
|
'age_limit': age_limit,
|
|
|
|
return medias[0]
|
|
|
|
'formats': formats,
|
|
|
|
|
|
|
|
}
|
|
|
|