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.

163 lines
6.0 KiB

  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. NO_DEFAULT,
  10. parse_iso8601,
  11. smuggle_url,
  12. xpath_text,
  13. )
  14. class HeiseIE(InfoExtractor):
  15. _VALID_URL = r'https?://(?:www\.)?heise\.de/(?:[^/]+/)+[^/]+-(?P<id>[0-9]+)\.html'
  16. _TESTS = [{
  17. # kaltura embed
  18. 'url': 'http://www.heise.de/video/artikel/Podcast-c-t-uplink-3-3-Owncloud-Tastaturen-Peilsender-Smartphone-2404147.html',
  19. 'info_dict': {
  20. 'id': '1_kkrq94sm',
  21. 'ext': 'mp4',
  22. 'title': "Podcast: c't uplink 3.3 – Owncloud / Tastaturen / Peilsender Smartphone",
  23. 'timestamp': 1512734959,
  24. 'upload_date': '20171208',
  25. 'description': 'md5:c934cbfb326c669c2bcabcbe3d3fcd20',
  26. },
  27. 'params': {
  28. 'skip_download': True,
  29. },
  30. }, {
  31. # YouTube embed
  32. 'url': 'http://www.heise.de/newsticker/meldung/Netflix-In-20-Jahren-vom-Videoverleih-zum-TV-Revolutionaer-3814130.html',
  33. 'md5': 'e403d2b43fea8e405e88e3f8623909f1',
  34. 'info_dict': {
  35. 'id': '6kmWbXleKW4',
  36. 'ext': 'mp4',
  37. 'title': 'NEU IM SEPTEMBER | Netflix',
  38. 'description': 'md5:2131f3c7525e540d5fd841de938bd452',
  39. 'upload_date': '20170830',
  40. 'uploader': 'Netflix Deutschland, Österreich und Schweiz',
  41. 'uploader_id': 'netflixdach',
  42. },
  43. 'params': {
  44. 'skip_download': True,
  45. },
  46. }, {
  47. 'url': 'https://www.heise.de/video/artikel/nachgehakt-Wie-sichert-das-c-t-Tool-Restric-tor-Windows-10-ab-3700244.html',
  48. 'info_dict': {
  49. 'id': '1_ntrmio2s',
  50. 'ext': 'mp4',
  51. 'title': "nachgehakt: Wie sichert das c't-Tool Restric'tor Windows 10 ab?",
  52. 'description': 'md5:47e8ffb6c46d85c92c310a512d6db271',
  53. 'timestamp': 1512470717,
  54. 'upload_date': '20171205',
  55. },
  56. 'params': {
  57. 'skip_download': True,
  58. },
  59. }, {
  60. 'url': 'https://www.heise.de/ct/artikel/c-t-uplink-20-8-Staubsaugerroboter-Xiaomi-Vacuum-2-AR-Brille-Meta-2-und-Android-rooten-3959893.html',
  61. 'info_dict': {
  62. 'id': '1_59mk80sf',
  63. 'ext': 'mp4',
  64. 'title': "c't uplink 20.8: Staubsaugerroboter Xiaomi Vacuum 2, AR-Brille Meta 2 und Android rooten",
  65. 'description': 'md5:f50fe044d3371ec73a8f79fcebd74afc',
  66. 'timestamp': 1517567237,
  67. 'upload_date': '20180202',
  68. },
  69. 'params': {
  70. 'skip_download': True,
  71. },
  72. }, {
  73. 'url': 'http://www.heise.de/ct/artikel/c-t-uplink-3-3-Owncloud-Tastaturen-Peilsender-Smartphone-2403911.html',
  74. 'only_matching': True,
  75. }, {
  76. 'url': 'http://www.heise.de/newsticker/meldung/c-t-uplink-Owncloud-Tastaturen-Peilsender-Smartphone-2404251.html?wt_mc=rss.ho.beitrag.atom',
  77. 'only_matching': True,
  78. }, {
  79. 'url': 'http://www.heise.de/ct/ausgabe/2016-12-Spiele-3214137.html',
  80. 'only_matching': True,
  81. }]
  82. def _real_extract(self, url):
  83. video_id = self._match_id(url)
  84. webpage = self._download_webpage(url, video_id)
  85. def extract_title(default=NO_DEFAULT):
  86. title = self._html_search_meta(
  87. ('fulltitle', 'title'), webpage, default=None)
  88. if not title or title == "c't":
  89. title = self._search_regex(
  90. r'<div[^>]+class="videoplayerjw"[^>]+data-title="([^"]+)"',
  91. webpage, 'title', default=None)
  92. if not title:
  93. title = self._html_search_regex(
  94. r'<h1[^>]+\bclass=["\']article_page_title[^>]+>(.+?)<',
  95. webpage, 'title', default=default)
  96. return title
  97. title = extract_title(default=None)
  98. description = self._og_search_description(
  99. webpage, default=None) or self._html_search_meta(
  100. 'description', webpage)
  101. kaltura_url = KalturaIE._extract_url(webpage)
  102. if kaltura_url:
  103. return {
  104. '_type': 'url_transparent',
  105. 'url': smuggle_url(kaltura_url, {'source_url': url}),
  106. 'ie_key': KalturaIE.ie_key(),
  107. 'title': title,
  108. 'description': description,
  109. }
  110. yt_urls = YoutubeIE._extract_urls(webpage)
  111. if yt_urls:
  112. return self.playlist_from_matches(
  113. yt_urls, video_id, title, ie=YoutubeIE.ie_key())
  114. title = extract_title()
  115. container_id = self._search_regex(
  116. r'<div class="videoplayerjw"[^>]+data-container="([0-9]+)"',
  117. webpage, 'container ID')
  118. sequenz_id = self._search_regex(
  119. r'<div class="videoplayerjw"[^>]+data-sequenz="([0-9]+)"',
  120. webpage, 'sequenz ID')
  121. doc = self._download_xml(
  122. 'http://www.heise.de/videout/feed', video_id, query={
  123. 'container': container_id,
  124. 'sequenz': sequenz_id,
  125. })
  126. formats = []
  127. for source_node in doc.findall('.//{http://rss.jwpcdn.com/}source'):
  128. label = source_node.attrib['label']
  129. height = int_or_none(self._search_regex(
  130. r'^(.*?_)?([0-9]+)p$', label, 'height', default=None))
  131. video_url = source_node.attrib['file']
  132. ext = determine_ext(video_url, '')
  133. formats.append({
  134. 'url': video_url,
  135. 'format_note': label,
  136. 'format_id': '%s_%s' % (ext, label),
  137. 'height': height,
  138. })
  139. self._sort_formats(formats)
  140. return {
  141. 'id': video_id,
  142. 'title': title,
  143. 'description': description,
  144. 'thumbnail': (xpath_text(doc, './/{http://rss.jwpcdn.com/}image') or
  145. self._og_search_thumbnail(webpage)),
  146. 'timestamp': parse_iso8601(
  147. self._html_search_meta('date', webpage)),
  148. 'formats': formats,
  149. }