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.

110 lines
3.7 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. 'upload_date': '20140311',
  33. },
  34. 'params': {
  35. 'skip_download': True,
  36. },
  37. },
  38. {
  39. 'url': 'http://www1.wdr.de/themen/kultur/audioerlebtegeschichtenmargaspiegel100-audioplayer.html',
  40. 'md5': '83e9e8fefad36f357278759870805898',
  41. 'info_dict': {
  42. 'id': 'mdb-194332',
  43. 'ext': 'mp3',
  44. 'title': 'Erlebte Geschichten: Marga Spiegel (29.11.2009)',
  45. 'upload_date': '20091129',
  46. },
  47. },
  48. {
  49. 'url': 'http://www.funkhauseuropa.de/av/audiogrenzenlosleckerbaklava101-audioplayer.html',
  50. 'md5': 'cfff440d4ee64114083ac44676df5d15',
  51. 'info_dict': {
  52. 'id': 'mdb-363068',
  53. 'ext': 'mp3',
  54. 'title': 'Grenzenlos lecker - Baklava',
  55. 'upload_date': '20140311',
  56. },
  57. },
  58. ]
  59. def _real_extract(self, url):
  60. mobj = re.match(self._VALID_URL, url)
  61. page_url = mobj.group('url')
  62. page_id = mobj.group('id')
  63. webpage = self._download_webpage(url, page_id)
  64. if mobj.group('player') is None:
  65. entries = [
  66. self.url_result(page_url + href, 'WDR')
  67. for href in re.findall(r'<a href="/?(.+?%s\.html)" rel="nofollow"' % self._PLAYER_REGEX, webpage)
  68. ]
  69. return self.playlist_result(entries, page_id)
  70. flashvars = compat_urlparse.parse_qs(
  71. self._html_search_regex(r'<param name="flashvars" value="([^"]+)"', webpage, 'flashvars'))
  72. page_id = flashvars['trackerClipId'][0]
  73. video_url = flashvars['dslSrc'][0]
  74. title = flashvars['trackerClipTitle'][0]
  75. thumbnail = flashvars['startPicture'][0] if 'startPicture' in flashvars else None
  76. if 'trackerClipAirTime' in flashvars:
  77. upload_date = flashvars['trackerClipAirTime'][0]
  78. else:
  79. upload_date = self._html_search_meta('DC.Date', webpage, 'upload date')
  80. if upload_date:
  81. upload_date = unified_strdate(upload_date)
  82. if video_url.endswith('.f4m'):
  83. video_url += '?hdcore=3.2.0&plugin=aasp-3.2.0.77.18'
  84. ext = 'flv'
  85. else:
  86. ext = determine_ext(video_url)
  87. description = self._html_search_meta('Description', webpage, 'description')
  88. return {
  89. 'id': page_id,
  90. 'url': video_url,
  91. 'ext': ext,
  92. 'title': title,
  93. 'description': description,
  94. 'thumbnail': thumbnail,
  95. 'upload_date': upload_date,
  96. }