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.

195 lines
6.8 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. compat_parse_qs,
  6. compat_urlparse,
  7. determine_ext,
  8. unified_strdate,
  9. )
  10. class WDRIE(InfoExtractor):
  11. _PLAYER_REGEX = '-(?:video|audio)player(?:_size-[LMS])?'
  12. _VALID_URL = r'(?P<url>https?://www\d?\.(?:wdr\d?|funkhauseuropa)\.de/)(?P<id>.+?)(?P<player>%s)?\.html' % _PLAYER_REGEX
  13. _TESTS = [
  14. {
  15. 'url': 'http://www1.wdr.de/mediathek/video/sendungen/servicezeit/videoservicezeit560-videoplayer_size-L.html',
  16. 'info_dict': {
  17. 'id': 'mdb-362427',
  18. 'ext': 'flv',
  19. 'title': 'Servicezeit',
  20. 'description': 'md5:c8f43e5e815eeb54d0b96df2fba906cb',
  21. 'upload_date': '20140310',
  22. },
  23. 'params': {
  24. 'skip_download': True,
  25. },
  26. },
  27. {
  28. 'url': 'http://www1.wdr.de/themen/av/videomargaspiegelisttot101-videoplayer.html',
  29. 'info_dict': {
  30. 'id': 'mdb-363194',
  31. 'ext': 'flv',
  32. 'title': 'Marga Spiegel ist tot',
  33. 'description': 'md5:2309992a6716c347891c045be50992e4',
  34. 'upload_date': '20140311',
  35. },
  36. 'params': {
  37. 'skip_download': True,
  38. },
  39. },
  40. {
  41. 'url': 'http://www1.wdr.de/themen/kultur/audioerlebtegeschichtenmargaspiegel100-audioplayer.html',
  42. 'md5': '83e9e8fefad36f357278759870805898',
  43. 'info_dict': {
  44. 'id': 'mdb-194332',
  45. 'ext': 'mp3',
  46. 'title': 'Erlebte Geschichten: Marga Spiegel (29.11.2009)',
  47. 'description': 'md5:2309992a6716c347891c045be50992e4',
  48. 'upload_date': '20091129',
  49. },
  50. },
  51. {
  52. 'url': 'http://www.funkhauseuropa.de/av/audiogrenzenlosleckerbaklava101-audioplayer.html',
  53. 'md5': 'cfff440d4ee64114083ac44676df5d15',
  54. 'info_dict': {
  55. 'id': 'mdb-363068',
  56. 'ext': 'mp3',
  57. 'title': 'Grenzenlos lecker - Baklava',
  58. 'description': 'md5:7b29e97e10dfb6e265238b32fa35b23a',
  59. 'upload_date': '20140311',
  60. },
  61. },
  62. ]
  63. def _real_extract(self, url):
  64. mobj = re.match(self._VALID_URL, url)
  65. page_url = mobj.group('url')
  66. page_id = mobj.group('id')
  67. webpage = self._download_webpage(url, page_id)
  68. if mobj.group('player') is None:
  69. entries = [
  70. self.url_result(page_url + href, 'WDR')
  71. for href in re.findall(r'<a href="/?(.+?%s\.html)" rel="nofollow"' % self._PLAYER_REGEX, webpage)
  72. ]
  73. return self.playlist_result(entries, page_id)
  74. flashvars = compat_urlparse.parse_qs(
  75. self._html_search_regex(r'<param name="flashvars" value="([^"]+)"', webpage, 'flashvars'))
  76. page_id = flashvars['trackerClipId'][0]
  77. video_url = flashvars['dslSrc'][0]
  78. title = flashvars['trackerClipTitle'][0]
  79. thumbnail = flashvars['startPicture'][0] if 'startPicture' in flashvars else None
  80. if 'trackerClipAirTime' in flashvars:
  81. upload_date = flashvars['trackerClipAirTime'][0]
  82. else:
  83. upload_date = self._html_search_meta('DC.Date', webpage, 'upload date')
  84. if upload_date:
  85. upload_date = unified_strdate(upload_date)
  86. if video_url.endswith('.f4m'):
  87. video_url += '?hdcore=3.2.0&plugin=aasp-3.2.0.77.18'
  88. ext = 'flv'
  89. else:
  90. ext = determine_ext(video_url)
  91. description = self._html_search_meta('Description', webpage, 'description')
  92. return {
  93. 'id': page_id,
  94. 'url': video_url,
  95. 'ext': ext,
  96. 'title': title,
  97. 'description': description,
  98. 'thumbnail': thumbnail,
  99. 'upload_date': upload_date,
  100. }
  101. class WDRMausIE(InfoExtractor):
  102. _VALID_URL = 'http://(?:www\.)?wdrmaus\.de/(?:[^/]+/){,2}(?P<id>[^/?#]+)(?:/index\.php5|(?<!index)\.php5|/(?:$|[?#]))'
  103. IE_DESC = 'Sendung mit der Maus'
  104. _TESTS = [{
  105. 'url': 'http://www.wdrmaus.de/aktuelle-sendung/index.php5',
  106. 'info_dict': {
  107. 'id': 'aktuelle-sendung',
  108. 'ext': 'mp4',
  109. 'thumbnail': 're:^http://.+\.jpg',
  110. 'upload_date': 're:^[0-9]{8}$',
  111. 'title': 're:^[0-9.]{10} - Aktuelle Sendung$',
  112. }
  113. }, {
  114. 'url': 'http://www.wdrmaus.de/sachgeschichten/sachgeschichten/40_jahre_maus.php5',
  115. 'md5': '3b1227ca3ed28d73ec5737c65743b2a3',
  116. 'info_dict': {
  117. 'id': '40_jahre_maus',
  118. 'ext': 'mp4',
  119. 'thumbnail': 're:^http://.+\.jpg',
  120. 'upload_date': '20131007',
  121. 'title': '12.03.2011 - 40 Jahre Maus',
  122. }
  123. }]
  124. def _real_extract(self, url):
  125. mobj = re.match(self._VALID_URL, url)
  126. video_id = mobj.group('id')
  127. webpage = self._download_webpage(url, video_id)
  128. param_code = self._html_search_regex(
  129. r'<a href="\?startVideo=1&amp;([^"]+)"', webpage, 'parameters')
  130. title_date = self._search_regex(
  131. r'<div class="sendedatum"><p>Sendedatum:\s*([0-9\.]+)</p>',
  132. webpage, 'air date')
  133. title_str = self._html_search_regex(
  134. r'<h1>(.*?)</h1>', webpage, 'title')
  135. title = '%s - %s' % (title_date, title_str)
  136. upload_date = unified_strdate(
  137. self._html_search_meta('dc.date', webpage))
  138. fields = compat_parse_qs(param_code)
  139. video_url = fields['firstVideo'][0]
  140. thumbnail = compat_urlparse.urljoin(url, fields['startPicture'][0])
  141. formats = [{
  142. 'format_id': 'rtmp',
  143. 'url': video_url,
  144. }]
  145. jscode = self._download_webpage(
  146. 'http://www.wdrmaus.de/codebase/js/extended-medien.min.js',
  147. video_id, fatal=False,
  148. note='Downloading URL translation table',
  149. errnote='Could not download URL translation table')
  150. if jscode:
  151. for m in re.finditer(
  152. r"stream:\s*'dslSrc=(?P<stream>[^']+)',\s*download:\s*'(?P<dl>[^']+)'\s*\}",
  153. jscode):
  154. if video_url.startswith(m.group('stream')):
  155. http_url = video_url.replace(
  156. m.group('stream'), m.group('dl'))
  157. formats.append({
  158. 'format_id': 'http',
  159. 'url': http_url,
  160. })
  161. break
  162. self._sort_formats(formats)
  163. return {
  164. 'id': video_id,
  165. 'title': title,
  166. 'formats': formats,
  167. 'thumbnail': thumbnail,
  168. 'upload_date': upload_date,
  169. }
  170. # TODO test _1