You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
2.2 KiB

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