mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-27 14:15:37 +01:00
[regiotv] Improve extraction (Closes #7915)
This commit is contained in:
parent
c43fda4c1a
commit
34a9da136f
|
@ -1,61 +1,62 @@
|
||||||
# -*- 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 (
|
||||||
sanitized_Request,
|
sanitized_Request,
|
||||||
|
xpath_text,
|
||||||
xpath_with_ns,
|
xpath_with_ns,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class RegioTVIE(InfoExtractor):
|
class RegioTVIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www\.)?regio-tv\.de/video/(?P<id>[0-9]+).html'
|
_VALID_URL = r'https?://(?:www\.)?regio-tv\.de/video/(?P<id>[0-9]+)'
|
||||||
_TESTS = [
|
_TESTS = [{
|
||||||
{
|
|
||||||
'url': 'http://www.regio-tv.de/video/395808.html',
|
'url': 'http://www.regio-tv.de/video/395808.html',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '395808',
|
'id': '395808',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': u'Wir in Ludwigsburg',
|
'title': 'Wir in Ludwigsburg',
|
||||||
'description': u'Mit unseren zuckers\xfc\xdfen Adventskindern, au\xdferdem besuchen wir die Abendsterne!',
|
'description': 'Mit unseren zuckersüßen Adventskindern, außerdem besuchen wir die Abendsterne!',
|
||||||
}
|
}
|
||||||
},
|
}, {
|
||||||
]
|
'url': 'http://www.regio-tv.de/video/395808',
|
||||||
|
'only_matching': True,
|
||||||
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
video_id = self._match_id(url)
|
||||||
video_id = mobj.group('id')
|
|
||||||
|
|
||||||
webpage = self._download_webpage(url, video_id)
|
webpage = self._download_webpage(url, video_id)
|
||||||
key = self._html_search_regex(r''',key: "(.*?)"''', webpage, 'key')
|
|
||||||
|
|
||||||
title = self._html_search_regex(
|
key = self._search_regex(
|
||||||
r'<meta property="og:title" content="\s*(.*?)\s*"\s*/?\s*>',
|
r'key\s*:\s*(["\'])(?P<key>.+?)\1', webpage, 'key', group='key')
|
||||||
webpage, 'title')
|
title = self._og_search_title(webpage)
|
||||||
|
|
||||||
soapxml = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><getHTML5VideoData xmlns="http://v.telvi.de/"><key xsi:type="xsd:string">%s</key></getHTML5VideoData></soap:Body></soap:Envelope>' % key
|
SOAP_TEMPLATE = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><{0} xmlns="http://v.telvi.de/"><key xsi:type="xsd:string">{1}</key></{0}></soap:Body></soap:Envelope>'
|
||||||
request = sanitized_Request('http://v.telvi.de/?wsdl', soapxml)
|
|
||||||
request.add_header('Origin', 'http://www.regio-tv.de')
|
request = sanitized_Request(
|
||||||
request.add_header('Referer', url)
|
'http://v.telvi.de/',
|
||||||
video_data = self._download_xml(request, video_id, 'video data')
|
SOAP_TEMPLATE.format('GetHTML5VideoData', key).encode('utf-8'))
|
||||||
|
video_data = self._download_xml(request, video_id, 'Downloading video XML')
|
||||||
|
|
||||||
NS_MAP = {
|
NS_MAP = {
|
||||||
'xsi': 'http://www.w3.org/2001/XMLSchema-instance',
|
'xsi': 'http://www.w3.org/2001/XMLSchema-instance',
|
||||||
'soap': 'http://schemas.xmlsoap.org/soap/envelope/',
|
'soap': 'http://schemas.xmlsoap.org/soap/envelope/',
|
||||||
}
|
}
|
||||||
|
|
||||||
url = video_data.find(xpath_with_ns('.//video', NS_MAP)).text
|
video_url = xpath_text(
|
||||||
thumbnail = video_data.find(xpath_with_ns('.//image', NS_MAP)).text
|
video_data, xpath_with_ns('.//video', NS_MAP), 'video url', fatal=True)
|
||||||
|
thumbnail = xpath_text(
|
||||||
description = self._html_search_meta('description', webpage)
|
video_data, xpath_with_ns('.//image', NS_MAP), 'thumbnail')
|
||||||
|
description = self._og_search_description(
|
||||||
|
webpage) or self._html_search_meta('description', webpage)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
|
'url': video_url,
|
||||||
'title': title,
|
'title': title,
|
||||||
'url': url,
|
|
||||||
'thumbnail': thumbnail,
|
|
||||||
'description': description,
|
'description': description,
|
||||||
|
'thumbnail': thumbnail,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user