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.

90 lines
3.4 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. xpath_text,
  9. )
  10. class HeiseIE(InfoExtractor):
  11. _VALID_URL = r'https?://(?:www\.)?heise\.de/(?:[^/]+/)+[^/]+-(?P<id>[0-9]+)\.html'
  12. _TESTS = [{
  13. 'url': 'http://www.heise.de/video/artikel/Podcast-c-t-uplink-3-3-Owncloud-Tastaturen-Peilsender-Smartphone-2404147.html',
  14. 'md5': 'ffed432483e922e88545ad9f2f15d30e',
  15. 'info_dict': {
  16. 'id': '2404147',
  17. 'ext': 'mp4',
  18. 'title': "Podcast: c't uplink 3.3 – Owncloud / Tastaturen / Peilsender Smartphone",
  19. 'format_id': 'mp4_720p',
  20. 'timestamp': 1411812600,
  21. 'upload_date': '20140927',
  22. 'description': 'md5:c934cbfb326c669c2bcabcbe3d3fcd20',
  23. 'thumbnail': r're:^https?://.*/gallery/$',
  24. }
  25. }, {
  26. 'url': 'http://www.heise.de/ct/artikel/c-t-uplink-3-3-Owncloud-Tastaturen-Peilsender-Smartphone-2403911.html',
  27. 'only_matching': True,
  28. }, {
  29. 'url': 'http://www.heise.de/newsticker/meldung/c-t-uplink-Owncloud-Tastaturen-Peilsender-Smartphone-2404251.html?wt_mc=rss.ho.beitrag.atom',
  30. 'only_matching': True,
  31. }, {
  32. 'url': 'http://www.heise.de/ct/ausgabe/2016-12-Spiele-3214137.html',
  33. 'only_matching': True,
  34. }]
  35. def _real_extract(self, url):
  36. video_id = self._match_id(url)
  37. webpage = self._download_webpage(url, video_id)
  38. container_id = self._search_regex(
  39. r'<div class="videoplayerjw"[^>]+data-container="([0-9]+)"',
  40. webpage, 'container ID')
  41. sequenz_id = self._search_regex(
  42. r'<div class="videoplayerjw"[^>]+data-sequenz="([0-9]+)"',
  43. webpage, 'sequenz ID')
  44. title = self._html_search_meta('fulltitle', webpage, default=None)
  45. if not title or title == "c't":
  46. title = self._search_regex(
  47. r'<div[^>]+class="videoplayerjw"[^>]+data-title="([^"]+)"',
  48. webpage, 'title')
  49. doc = self._download_xml(
  50. 'http://www.heise.de/videout/feed', video_id, query={
  51. 'container': container_id,
  52. 'sequenz': sequenz_id,
  53. })
  54. formats = []
  55. for source_node in doc.findall('.//{http://rss.jwpcdn.com/}source'):
  56. label = source_node.attrib['label']
  57. height = int_or_none(self._search_regex(
  58. r'^(.*?_)?([0-9]+)p$', label, 'height', default=None))
  59. video_url = source_node.attrib['file']
  60. ext = determine_ext(video_url, '')
  61. formats.append({
  62. 'url': video_url,
  63. 'format_note': label,
  64. 'format_id': '%s_%s' % (ext, label),
  65. 'height': height,
  66. })
  67. self._sort_formats(formats)
  68. description = self._og_search_description(
  69. webpage, default=None) or self._html_search_meta(
  70. 'description', webpage)
  71. return {
  72. 'id': video_id,
  73. 'title': title,
  74. 'description': description,
  75. 'thumbnail': (xpath_text(doc, './/{http://rss.jwpcdn.com/}image') or
  76. self._og_search_thumbnail(webpage)),
  77. 'timestamp': parse_iso8601(
  78. self._html_search_meta('date', webpage)),
  79. 'formats': formats,
  80. }