]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/regiotv.py
[ie/PrankCastPost] Add extractor (#8933)
[yt-dlp.git] / yt_dlp / extractor / regiotv.py
CommitLineData
c43fda4c 1from .common import InfoExtractor
3d2623a8 2from ..networking import Request
3from ..utils import xpath_text, xpath_with_ns
c43fda4c 4
5
6class RegioTVIE(InfoExtractor):
34a9da13
S
7 _VALID_URL = r'https?://(?:www\.)?regio-tv\.de/video/(?P<id>[0-9]+)'
8 _TESTS = [{
9 'url': 'http://www.regio-tv.de/video/395808.html',
10 'info_dict': {
11 'id': '395808',
12 'ext': 'mp4',
13 'title': 'Wir in Ludwigsburg',
14 'description': 'Mit unseren zuckersüßen Adventskindern, außerdem besuchen wir die Abendsterne!',
15 }
16 }, {
17 'url': 'http://www.regio-tv.de/video/395808',
18 'only_matching': True,
19 }]
c43fda4c 20
21 def _real_extract(self, url):
34a9da13 22 video_id = self._match_id(url)
c43fda4c 23
24 webpage = self._download_webpage(url, video_id)
c43fda4c 25
34a9da13
S
26 key = self._search_regex(
27 r'key\s*:\s*(["\'])(?P<key>.+?)\1', webpage, 'key', group='key')
28 title = self._og_search_title(webpage)
29
30 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>'
c43fda4c 31
3d2623a8 32 request = Request(
34a9da13
S
33 'http://v.telvi.de/',
34 SOAP_TEMPLATE.format('GetHTML5VideoData', key).encode('utf-8'))
35 video_data = self._download_xml(request, video_id, 'Downloading video XML')
c43fda4c 36
37 NS_MAP = {
38 'xsi': 'http://www.w3.org/2001/XMLSchema-instance',
39 'soap': 'http://schemas.xmlsoap.org/soap/envelope/',
40 }
41
34a9da13
S
42 video_url = xpath_text(
43 video_data, xpath_with_ns('.//video', NS_MAP), 'video url', fatal=True)
44 thumbnail = xpath_text(
45 video_data, xpath_with_ns('.//image', NS_MAP), 'thumbnail')
46 description = self._og_search_description(
47 webpage) or self._html_search_meta('description', webpage)
c43fda4c 48
49 return {
50 'id': video_id,
34a9da13 51 'url': video_url,
c43fda4c 52 'title': title,
c43fda4c 53 'description': description,
34a9da13 54 'thumbnail': thumbnail,
c43fda4c 55 }