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.

63 lines
2.4 KiB

  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import parse_duration
  6. class RadioBremenIE(InfoExtractor):
  7. _VALID_URL = r'http?://(?:www\.)?radiobremen\.de/mediathek/(?:index\.html)?\?id=(?P<id>[0-9]+)'
  8. IE_NAME = 'radiobremen'
  9. _TEST = {
  10. 'url': 'http://www.radiobremen.de/mediathek/index.html?id=114720',
  11. 'info_dict': {
  12. 'id': '114720',
  13. 'ext': 'mp4',
  14. 'duration': 1685,
  15. 'width': 512,
  16. 'title': 'buten un binnen vom 22. Dezember',
  17. 'thumbnail': 're:https?://.*\.jpg$',
  18. 'description': 'Unter anderem mit diesen Themen: 45 Flüchtlinge sind in Worpswede angekommen +++ Freies Internet für alle: Bremer arbeiten an einem flächendeckenden W-Lan-Netzwerk +++ Aktivisten kämpfen für das Unibad +++ So war das Wetter 2014 +++',
  19. },
  20. }
  21. def _real_extract(self, url):
  22. video_id = self._match_id(url)
  23. meta_url = "http://www.radiobremen.de/apps/php/mediathek/metadaten.php?id=%s" % video_id
  24. meta_doc = self._download_webpage(
  25. meta_url, video_id, 'Downloading metadata')
  26. title = self._html_search_regex(
  27. r"<h1.*>(?P<title>.+)</h1>", meta_doc, "title")
  28. description = self._html_search_regex(
  29. r"<p>(?P<description>.*)</p>", meta_doc, "description", fatal=False)
  30. duration = parse_duration(self._html_search_regex(
  31. r"L&auml;nge:</td>\s+<td>(?P<duration>[0-9]+:[0-9]+)</td>",
  32. meta_doc, "duration", fatal=False))
  33. page_doc = self._download_webpage(
  34. url, video_id, 'Downloading video information')
  35. mobj = re.search(
  36. r"ardformatplayerclassic\(\'playerbereich\',\'(?P<width>[0-9]+)\',\'.*\',\'(?P<video_id>[0-9]+)\',\'(?P<secret>[0-9]+)\',\'(?P<thumbnail>.+)\',\'\'\)",
  37. page_doc)
  38. video_url = (
  39. "http://dl-ondemand.radiobremen.de/mediabase/%s/%s_%s_%s.mp4" %
  40. (video_id, video_id, mobj.group("secret"), mobj.group('width')))
  41. formats = [{
  42. 'url': video_url,
  43. 'ext': 'mp4',
  44. 'width': int(mobj.group("width")),
  45. }]
  46. return {
  47. 'id': video_id,
  48. 'title': title,
  49. 'description': description,
  50. 'duration': duration,
  51. 'formats': formats,
  52. 'thumbnail': mobj.group('thumbnail'),
  53. }