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.

52 lines
1.6 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import int_or_none
  6. class FranceInterIE(InfoExtractor):
  7. _VALID_URL = r'http://(?:www\.)?franceinter\.fr/player/reecouter\?play=(?P<id>[0-9]+)'
  8. _TEST = {
  9. 'url': 'http://www.franceinter.fr/player/reecouter?play=793962',
  10. 'md5': '4764932e466e6f6c79c317d2e74f6884',
  11. "info_dict": {
  12. 'id': '793962',
  13. 'ext': 'mp3',
  14. 'title': 'L’Histoire dans les jeux vidéo',
  15. 'description': 'md5:7e93ddb4451e7530022792240a3049c7',
  16. 'timestamp': 1387369800,
  17. 'upload_date': '20131218',
  18. },
  19. }
  20. def _real_extract(self, url):
  21. mobj = re.match(self._VALID_URL, url)
  22. video_id = mobj.group('id')
  23. webpage = self._download_webpage(url, video_id)
  24. path = self._search_regex(
  25. r'<a id="player".+?href="([^"]+)"', webpage, 'video url')
  26. video_url = 'http://www.franceinter.fr/' + path
  27. title = self._html_search_regex(
  28. r'<span class="title">(.+?)</span>', webpage, 'title')
  29. description = self._html_search_regex(
  30. r'<span class="description">(.*?)</span>',
  31. webpage, 'description', fatal=False)
  32. timestamp = int_or_none(self._search_regex(
  33. r'data-date="(\d+)"', webpage, 'upload date', fatal=False))
  34. return {
  35. 'id': video_id,
  36. 'title': title,
  37. 'description': description,
  38. 'timestamp': timestamp,
  39. 'formats': [{
  40. 'url': video_url,
  41. 'vcodec': 'none',
  42. }],
  43. }