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.

228 lines
7.6 KiB

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