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.

131 lines
4.9 KiB

7 years ago
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from .kaltura import KalturaIE
  5. from .youtube import YoutubeIE
  6. from ..utils import (
  7. determine_ext,
  8. int_or_none,
  9. parse_iso8601,
  10. smuggle_url,
  11. xpath_text,
  12. )
  13. class HeiseIE(InfoExtractor):
  14. _VALID_URL = r'https?://(?:www\.)?heise\.de/(?:[^/]+/)+[^/]+-(?P<id>[0-9]+)\.html'
  15. _TESTS = [{
  16. 'url': 'http://www.heise.de/video/artikel/Podcast-c-t-uplink-3-3-Owncloud-Tastaturen-Peilsender-Smartphone-2404147.html',
  17. 'md5': 'ffed432483e922e88545ad9f2f15d30e',
  18. 'info_dict': {
  19. 'id': '2404147',
  20. 'ext': 'mp4',
  21. 'title': "Podcast: c't uplink 3.3 – Owncloud / Tastaturen / Peilsender Smartphone",
  22. 'format_id': 'mp4_720p',
  23. 'timestamp': 1411812600,
  24. 'upload_date': '20140927',
  25. 'description': 'md5:c934cbfb326c669c2bcabcbe3d3fcd20',
  26. 'thumbnail': r're:^https?://.*/gallery/$',
  27. }
  28. }, {
  29. # YouTube embed
  30. 'url': 'http://www.heise.de/newsticker/meldung/Netflix-In-20-Jahren-vom-Videoverleih-zum-TV-Revolutionaer-3814130.html',
  31. 'md5': 'e403d2b43fea8e405e88e3f8623909f1',
  32. 'info_dict': {
  33. 'id': '6kmWbXleKW4',
  34. 'ext': 'mp4',
  35. 'title': 'NEU IM SEPTEMBER | Netflix',
  36. 'description': 'md5:2131f3c7525e540d5fd841de938bd452',
  37. 'upload_date': '20170830',
  38. 'uploader': 'Netflix Deutschland, Österreich und Schweiz',
  39. 'uploader_id': 'netflixdach',
  40. },
  41. 'params': {
  42. 'skip_download': True,
  43. },
  44. }, {
  45. 'url': 'https://www.heise.de/video/artikel/nachgehakt-Wie-sichert-das-c-t-Tool-Restric-tor-Windows-10-ab-3700244.html',
  46. 'md5': '4b58058b46625bdbd841fc2804df95fc',
  47. 'info_dict': {
  48. 'id': '1_ntrmio2s',
  49. 'timestamp': 1512470717,
  50. 'upload_date': '20171205',
  51. 'ext': 'mp4',
  52. 'title': 'ct10 nachgehakt hos restrictor',
  53. },
  54. 'params': {
  55. 'skip_download': True,
  56. },
  57. }, {
  58. 'url': 'http://www.heise.de/ct/artikel/c-t-uplink-3-3-Owncloud-Tastaturen-Peilsender-Smartphone-2403911.html',
  59. 'only_matching': True,
  60. }, {
  61. 'url': 'http://www.heise.de/newsticker/meldung/c-t-uplink-Owncloud-Tastaturen-Peilsender-Smartphone-2404251.html?wt_mc=rss.ho.beitrag.atom',
  62. 'only_matching': True,
  63. }, {
  64. 'url': 'http://www.heise.de/ct/ausgabe/2016-12-Spiele-3214137.html',
  65. 'only_matching': True,
  66. }]
  67. def _real_extract(self, url):
  68. video_id = self._match_id(url)
  69. webpage = self._download_webpage(url, video_id)
  70. title = self._html_search_meta('fulltitle', webpage, default=None)
  71. if not title or title == "c't":
  72. title = self._search_regex(
  73. r'<div[^>]+class="videoplayerjw"[^>]+data-title="([^"]+)"',
  74. webpage, 'title')
  75. yt_urls = YoutubeIE._extract_urls(webpage)
  76. if yt_urls:
  77. return self.playlist_from_matches(yt_urls, video_id, title, ie=YoutubeIE.ie_key())
  78. kaltura_url = KalturaIE._extract_url(webpage)
  79. if kaltura_url:
  80. return self.url_result(smuggle_url(kaltura_url, {'source_url': url}), KalturaIE.ie_key())
  81. container_id = self._search_regex(
  82. r'<div class="videoplayerjw"[^>]+data-container="([0-9]+)"',
  83. webpage, 'container ID')
  84. sequenz_id = self._search_regex(
  85. r'<div class="videoplayerjw"[^>]+data-sequenz="([0-9]+)"',
  86. webpage, 'sequenz ID')
  87. doc = self._download_xml(
  88. 'http://www.heise.de/videout/feed', video_id, query={
  89. 'container': container_id,
  90. 'sequenz': sequenz_id,
  91. })
  92. formats = []
  93. for source_node in doc.findall('.//{http://rss.jwpcdn.com/}source'):
  94. label = source_node.attrib['label']
  95. height = int_or_none(self._search_regex(
  96. r'^(.*?_)?([0-9]+)p$', label, 'height', default=None))
  97. video_url = source_node.attrib['file']
  98. ext = determine_ext(video_url, '')
  99. formats.append({
  100. 'url': video_url,
  101. 'format_note': label,
  102. 'format_id': '%s_%s' % (ext, label),
  103. 'height': height,
  104. })
  105. self._sort_formats(formats)
  106. description = self._og_search_description(
  107. webpage, default=None) or self._html_search_meta(
  108. 'description', webpage)
  109. return {
  110. 'id': video_id,
  111. 'title': title,
  112. 'description': description,
  113. 'thumbnail': (xpath_text(doc, './/{http://rss.jwpcdn.com/}image') or
  114. self._og_search_thumbnail(webpage)),
  115. 'timestamp': parse_iso8601(
  116. self._html_search_meta('date', webpage)),
  117. 'formats': formats,
  118. }