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.

69 lines
2.6 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..compat import compat_urllib_parse_unquote
  5. from ..utils import (
  6. int_or_none,
  7. xpath_text,
  8. )
  9. class NozIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?noz\.de/video/(?P<id>[0-9]+)/'
  11. _TESTS = [{
  12. 'url': 'http://www.noz.de/video/25151/32-Deutschland-gewinnt-Badminton-Lnderspiel-in-Melle',
  13. 'info_dict': {
  14. 'id': '25151',
  15. 'ext': 'mp4',
  16. 'duration': 215,
  17. 'title': '3:2 - Deutschland gewinnt Badminton-Länderspiel in Melle',
  18. 'description': 'Vor rund 370 Zuschauern gewinnt die deutsche Badminton-Nationalmannschaft am Donnerstag ein EM-Vorbereitungsspiel gegen Frankreich in Melle. Video Moritz Frankenberg.',
  19. 'thumbnail': 're:^http://.*\.jpg',
  20. },
  21. }]
  22. def _real_extract(self, url):
  23. video_id = self._match_id(url)
  24. webpage = self._download_webpage(url, video_id)
  25. description = self._og_search_description(webpage)
  26. edge_url = self._html_search_regex(
  27. r'<script\s+(?:type="text/javascript"\s+)?src="(.*?/videojs_.*?)"',
  28. webpage, 'edge URL')
  29. edge_content = self._download_webpage(edge_url, 'meta configuration')
  30. config_url_encoded = self._search_regex(
  31. r'so\.addVariable\("config_url","[^,]*,(.*?)"',
  32. edge_content, 'config URL'
  33. )
  34. config_url = compat_urllib_parse_unquote(config_url_encoded)
  35. doc = self._download_xml(config_url, 'video configuration')
  36. title = xpath_text(doc, './/title')
  37. thumbnail = xpath_text(doc, './/article/thumbnail/url')
  38. duration = int_or_none(xpath_text(
  39. doc, './/article/movie/file/duration'))
  40. formats = []
  41. for qnode in doc.findall('.//article/movie/file/qualities/qual'):
  42. video_node = qnode.find('./html_urls/video_url[@format="video/mp4"]')
  43. if video_node is None:
  44. continue # auto
  45. formats.append({
  46. 'url': video_node.text,
  47. 'format_name': xpath_text(qnode, './name'),
  48. 'format_id': xpath_text(qnode, './id'),
  49. 'height': int_or_none(xpath_text(qnode, './height')),
  50. 'width': int_or_none(xpath_text(qnode, './width')),
  51. 'tbr': int_or_none(xpath_text(qnode, './bitrate'), scale=1000),
  52. })
  53. self._sort_formats(formats)
  54. return {
  55. 'id': video_id,
  56. 'formats': formats,
  57. 'title': title,
  58. 'duration': duration,
  59. 'description': description,
  60. 'thumbnail': thumbnail,
  61. }