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/?id=141876',
  11. 'info_dict': {
  12. 'id': '141876',
  13. 'ext': 'mp4',
  14. 'duration': 178,
  15. 'width': 512,
  16. 'title': 'Druck auf Patrick Öztürk',
  17. 'thumbnail': 're:https?://.*\.jpg$',
  18. 'description': 'Gegen den SPD-Bürgerschaftsabgeordneten Patrick Öztürk wird wegen Beihilfe zum gewerbsmäßigen Betrug ermittelt. Am Donnerstagabend sollte er dem Vorstand des SPD-Unterbezirks Bremerhaven dazu Rede und Antwort stehen.',
  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. }