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