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.

113 lines
3.9 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. unified_strdate,
  6. compat_urlparse,
  7. determine_ext,
  8. )
  9. class WDRIE(InfoExtractor):
  10. _PLAYER_REGEX = '-(?:video|audio)player(?:_size-[LMS])?'
  11. _VALID_URL = r'(?P<url>https?://www\d?\.(?:wdr\d?|funkhauseuropa)\.de/)(?P<id>.+?)(?P<player>%s)?\.html' % _PLAYER_REGEX
  12. _TESTS = [
  13. {
  14. 'url': 'http://www1.wdr.de/mediathek/video/sendungen/servicezeit/videoservicezeit560-videoplayer_size-L.html',
  15. 'info_dict': {
  16. 'id': 'mdb-362427',
  17. 'ext': 'flv',
  18. 'title': 'Servicezeit',
  19. 'description': 'md5:c8f43e5e815eeb54d0b96df2fba906cb',
  20. 'upload_date': '20140310',
  21. },
  22. 'params': {
  23. 'skip_download': True,
  24. },
  25. },
  26. {
  27. 'url': 'http://www1.wdr.de/themen/av/videomargaspiegelisttot101-videoplayer.html',
  28. 'info_dict': {
  29. 'id': 'mdb-363194',
  30. 'ext': 'flv',
  31. 'title': 'Marga Spiegel ist tot',
  32. 'description': 'md5:2309992a6716c347891c045be50992e4',
  33. 'upload_date': '20140311',
  34. },
  35. 'params': {
  36. 'skip_download': True,
  37. },
  38. },
  39. {
  40. 'url': 'http://www1.wdr.de/themen/kultur/audioerlebtegeschichtenmargaspiegel100-audioplayer.html',
  41. 'md5': '83e9e8fefad36f357278759870805898',
  42. 'info_dict': {
  43. 'id': 'mdb-194332',
  44. 'ext': 'mp3',
  45. 'title': 'Erlebte Geschichten: Marga Spiegel (29.11.2009)',
  46. 'description': 'md5:2309992a6716c347891c045be50992e4',
  47. 'upload_date': '20091129',
  48. },
  49. },
  50. {
  51. 'url': 'http://www.funkhauseuropa.de/av/audiogrenzenlosleckerbaklava101-audioplayer.html',
  52. 'md5': 'cfff440d4ee64114083ac44676df5d15',
  53. 'info_dict': {
  54. 'id': 'mdb-363068',
  55. 'ext': 'mp3',
  56. 'title': 'Grenzenlos lecker - Baklava',
  57. 'description': 'md5:7b29e97e10dfb6e265238b32fa35b23a',
  58. 'upload_date': '20140311',
  59. },
  60. },
  61. ]
  62. def _real_extract(self, url):
  63. mobj = re.match(self._VALID_URL, url)
  64. page_url = mobj.group('url')
  65. page_id = mobj.group('id')
  66. webpage = self._download_webpage(url, page_id)
  67. if mobj.group('player') is None:
  68. entries = [
  69. self.url_result(page_url + href, 'WDR')
  70. for href in re.findall(r'<a href="/?(.+?%s\.html)" rel="nofollow"' % self._PLAYER_REGEX, webpage)
  71. ]
  72. return self.playlist_result(entries, page_id)
  73. flashvars = compat_urlparse.parse_qs(
  74. self._html_search_regex(r'<param name="flashvars" value="([^"]+)"', webpage, 'flashvars'))
  75. page_id = flashvars['trackerClipId'][0]
  76. video_url = flashvars['dslSrc'][0]
  77. title = flashvars['trackerClipTitle'][0]
  78. thumbnail = flashvars['startPicture'][0] if 'startPicture' in flashvars else None
  79. if 'trackerClipAirTime' in flashvars:
  80. upload_date = flashvars['trackerClipAirTime'][0]
  81. else:
  82. upload_date = self._html_search_meta('DC.Date', webpage, 'upload date')
  83. if upload_date:
  84. upload_date = unified_strdate(upload_date)
  85. if video_url.endswith('.f4m'):
  86. video_url += '?hdcore=3.2.0&plugin=aasp-3.2.0.77.18'
  87. ext = 'flv'
  88. else:
  89. ext = determine_ext(video_url)
  90. description = self._html_search_meta('Description', webpage, 'description')
  91. return {
  92. 'id': page_id,
  93. 'url': video_url,
  94. 'ext': ext,
  95. 'title': title,
  96. 'description': description,
  97. 'thumbnail': thumbnail,
  98. 'upload_date': upload_date,
  99. }