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.

79 lines
2.8 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. determine_ext,
  6. int_or_none,
  7. parse_iso8601,
  8. )
  9. class HeiseIE(InfoExtractor):
  10. _VALID_URL = r'''(?x)
  11. https?://(?:www\.)?heise\.de/video/artikel/
  12. .+?(?P<id>[0-9]+)\.html(?:$|[?#])
  13. '''
  14. _TEST = {
  15. 'url': (
  16. 'http://www.heise.de/video/artikel/Podcast-c-t-uplink-3-3-Owncloud-Tastaturen-Peilsender-Smartphone-2404147.html'
  17. ),
  18. 'md5': 'ffed432483e922e88545ad9f2f15d30e',
  19. 'info_dict': {
  20. 'id': '2404147',
  21. 'ext': 'mp4',
  22. 'title': (
  23. "Podcast: c't uplink 3.3 – Owncloud / Tastaturen / Peilsender Smartphone"
  24. ),
  25. 'format_id': 'mp4_720p',
  26. 'timestamp': 1411812600,
  27. 'upload_date': '20140927',
  28. 'description': 'In uplink-Episode 3.3 geht es darum, wie man sich von Cloud-Anbietern emanzipieren kann, worauf man beim Kauf einer Tastatur achten sollte und was Smartphones über uns verraten.',
  29. 'thumbnail': 're:^https?://.*\.jpe?g$',
  30. }
  31. }
  32. def _real_extract(self, url):
  33. video_id = self._match_id(url)
  34. webpage = self._download_webpage(url, video_id)
  35. container_id = self._search_regex(
  36. r'<div class="videoplayerjw".*?data-container="([0-9]+)"',
  37. webpage, 'container ID')
  38. sequenz_id = self._search_regex(
  39. r'<div class="videoplayerjw".*?data-sequenz="([0-9]+)"',
  40. webpage, 'sequenz ID')
  41. data_url = 'http://www.heise.de/videout/feed?container=%s&sequenz=%s' % (container_id, sequenz_id)
  42. doc = self._download_xml(data_url, video_id)
  43. info = {
  44. 'id': video_id,
  45. 'thumbnail': self._og_search_thumbnail(webpage),
  46. 'timestamp': parse_iso8601(
  47. self._html_search_meta('date', webpage)),
  48. 'description': self._og_search_description(webpage),
  49. }
  50. title = self._html_search_meta('fulltitle', webpage)
  51. if title:
  52. info['title'] = title
  53. else:
  54. info['title'] = self._og_search_title(webpage)
  55. formats = []
  56. for source_node in doc.findall('.//{http://rss.jwpcdn.com/}source'):
  57. label = source_node.attrib['label']
  58. height = int_or_none(self._search_regex(
  59. r'^(.*?_)?([0-9]+)p$', label, 'height', default=None))
  60. video_url = source_node.attrib['file']
  61. ext = determine_ext(video_url, '')
  62. formats.append({
  63. 'url': video_url,
  64. 'format_note': label,
  65. 'format_id': '%s_%s' % (ext, label),
  66. 'height': height,
  67. })
  68. self._sort_formats(formats)
  69. info['formats'] = formats
  70. return info