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.

46 lines
1.3 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. class EchoMskIE(InfoExtractor):
  6. _VALID_URL = r'http://(?:www\.)?echo\.msk\.ru/sounds/(?P<id>\d+)'
  7. _TEST = {
  8. 'url': 'http://www.echo.msk.ru/sounds/1464134.html',
  9. 'md5': '2e44b3b78daff5b458e4dbc37f191f7c',
  10. 'info_dict': {
  11. 'id': '1464134',
  12. 'ext': 'mp3',
  13. 'title': 'Особое мнение - 29 декабря 2014, 19:08',
  14. },
  15. }
  16. def _real_extract(self, url):
  17. video_id = self._match_id(url)
  18. webpage = self._download_webpage(url, video_id)
  19. audio_url = self._search_regex(
  20. r'<a rel="mp3" href="([^"]+)">', webpage, 'audio URL')
  21. title = self._html_search_regex(
  22. r'<a href="/programs/[^"]+" target="_blank">([^<]+)</a>',
  23. webpage, 'title')
  24. air_date = self._html_search_regex(
  25. r'(?s)<div class="date">(.+?)</div>',
  26. webpage, 'date', fatal=False, default=None)
  27. if air_date:
  28. air_date = re.sub(r'(\s)\1+', r'\1', air_date)
  29. if air_date:
  30. title = '%s - %s' % (title, air_date)
  31. return {
  32. 'id': video_id,
  33. 'url': audio_url,
  34. 'title': title,
  35. }