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.

223 lines
7.6 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 WDRMobileIE(InfoExtractor):
  102. _VALID_URL = r'''(?x)
  103. https?://mobile-ondemand\.wdr\.de/
  104. .*?/fsk(?P<age_limit>[0-9]+)
  105. /[0-9]+/[0-9]+/
  106. (?P<id>[0-9]+)_(?P<title>[0-9]+)'''
  107. IE_NAME = 'wdr:mobile'
  108. _TEST = {
  109. 'url': 'http://mobile-ondemand.wdr.de/CMS2010/mdb/ondemand/weltweit/fsk0/42/421735/421735_4283021.mp4',
  110. 'info_dict': {
  111. 'title': '4283021',
  112. 'id': '421735',
  113. 'age_limit': 0,
  114. },
  115. '_skip': 'Will be depublicized shortly'
  116. }
  117. def _real_extract(self, url):
  118. mobj = re.match(self._VALID_URL, url)
  119. return {
  120. 'id': mobj.group('id'),
  121. 'title': mobj.group('title'),
  122. 'age_limit': int(mobj.group('age_limit')),
  123. 'url': url,
  124. 'user_agent': 'mobile',
  125. }
  126. class WDRMausIE(InfoExtractor):
  127. _VALID_URL = 'http://(?:www\.)?wdrmaus\.de/(?:[^/]+/){,2}(?P<id>[^/?#]+)(?:/index\.php5|(?<!index)\.php5|/(?:$|[?#]))'
  128. IE_DESC = 'Sendung mit der Maus'
  129. _TESTS = [{
  130. 'url': 'http://www.wdrmaus.de/aktuelle-sendung/index.php5',
  131. 'info_dict': {
  132. 'id': 'aktuelle-sendung',
  133. 'ext': 'mp4',
  134. 'thumbnail': 're:^http://.+\.jpg',
  135. 'upload_date': 're:^[0-9]{8}$',
  136. 'title': 're:^[0-9.]{10} - Aktuelle Sendung$',
  137. }
  138. }, {
  139. 'url': 'http://www.wdrmaus.de/sachgeschichten/sachgeschichten/40_jahre_maus.php5',
  140. 'md5': '3b1227ca3ed28d73ec5737c65743b2a3',
  141. 'info_dict': {
  142. 'id': '40_jahre_maus',
  143. 'ext': 'mp4',
  144. 'thumbnail': 're:^http://.+\.jpg',
  145. 'upload_date': '20131007',
  146. 'title': '12.03.2011 - 40 Jahre Maus',
  147. }
  148. }]
  149. def _real_extract(self, url):
  150. mobj = re.match(self._VALID_URL, url)
  151. video_id = mobj.group('id')
  152. webpage = self._download_webpage(url, video_id)
  153. param_code = self._html_search_regex(
  154. r'<a href="\?startVideo=1&amp;([^"]+)"', webpage, 'parameters')
  155. title_date = self._search_regex(
  156. r'<div class="sendedatum"><p>Sendedatum:\s*([0-9\.]+)</p>',
  157. webpage, 'air date')
  158. title_str = self._html_search_regex(
  159. r'<h1>(.*?)</h1>', webpage, 'title')
  160. title = '%s - %s' % (title_date, title_str)
  161. upload_date = unified_strdate(
  162. self._html_search_meta('dc.date', webpage))
  163. fields = compat_parse_qs(param_code)
  164. video_url = fields['firstVideo'][0]
  165. thumbnail = compat_urlparse.urljoin(url, fields['startPicture'][0])
  166. formats = [{
  167. 'format_id': 'rtmp',
  168. 'url': video_url,
  169. }]
  170. jscode = self._download_webpage(
  171. 'http://www.wdrmaus.de/codebase/js/extended-medien.min.js',
  172. video_id, fatal=False,
  173. note='Downloading URL translation table',
  174. errnote='Could not download URL translation table')
  175. if jscode:
  176. for m in re.finditer(
  177. r"stream:\s*'dslSrc=(?P<stream>[^']+)',\s*download:\s*'(?P<dl>[^']+)'\s*\}",
  178. jscode):
  179. if video_url.startswith(m.group('stream')):
  180. http_url = video_url.replace(
  181. m.group('stream'), m.group('dl'))
  182. formats.append({
  183. 'format_id': 'http',
  184. 'url': http_url,
  185. })
  186. break
  187. self._sort_formats(formats)
  188. return {
  189. 'id': video_id,
  190. 'title': title,
  191. 'formats': formats,
  192. 'thumbnail': thumbnail,
  193. 'upload_date': upload_date,
  194. }
  195. # TODO test _1