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.

61 lines
2.2 KiB

  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. sanitized_Request,
  7. xpath_with_ns,
  8. )
  9. class RegioTVIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?regio-tv\.de/video/(?P<id>[0-9]+).html'
  11. _TESTS = [
  12. {
  13. 'url': 'http://www.regio-tv.de/video/395808.html',
  14. 'info_dict': {
  15. 'id': '395808',
  16. 'ext': 'mp4',
  17. 'title': u'Wir in Ludwigsburg',
  18. 'description': u'Mit unseren zuckers\xfc\xdfen Adventskindern, au\xdferdem besuchen wir die Abendsterne!',
  19. }
  20. },
  21. ]
  22. def _real_extract(self, url):
  23. mobj = re.match(self._VALID_URL, url)
  24. video_id = mobj.group('id')
  25. webpage = self._download_webpage(url, video_id)
  26. key = self._html_search_regex(r''',key: "(.*?)"''', webpage, 'key')
  27. title = self._html_search_regex(
  28. r'<meta property="og:title" content="\s*(.*?)\s*"\s*/?\s*>',
  29. webpage, 'title')
  30. 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
  31. request = sanitized_Request('http://v.telvi.de/?wsdl', soapxml)
  32. request.add_header('Origin', 'http://www.regio-tv.de')
  33. request.add_header('Referer', url)
  34. video_data = self._download_xml(request, video_id, 'video data')
  35. NS_MAP = {
  36. 'xsi': 'http://www.w3.org/2001/XMLSchema-instance',
  37. 'soap': 'http://schemas.xmlsoap.org/soap/envelope/',
  38. }
  39. url = video_data.find(xpath_with_ns('.//video', NS_MAP)).text
  40. thumbnail = video_data.find(xpath_with_ns('.//image', NS_MAP)).text
  41. description = self._html_search_meta('description', webpage)
  42. return {
  43. 'id': video_id,
  44. 'title': title,
  45. 'url': url,
  46. 'thumbnail': thumbnail,
  47. 'description': description,
  48. }