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.

56 lines
2.0 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import month_by_name
  5. class FranceInterIE(InfoExtractor):
  6. _VALID_URL = r'https?://(?:www\.)?franceinter\.fr/emissions/(?P<id>[^?#]+)'
  7. _TEST = {
  8. 'url': 'https://www.franceinter.fr/emissions/affaires-sensibles/affaires-sensibles-07-septembre-2016',
  9. 'md5': '9e54d7bdb6fdc02a841007f8a975c094',
  10. 'info_dict': {
  11. 'id': 'affaires-sensibles/affaires-sensibles-07-septembre-2016',
  12. 'ext': 'mp3',
  13. 'title': 'Affaire Cahuzac : le contentieux du compte en Suisse',
  14. 'description': 'md5:401969c5d318c061f86bda1fa359292b',
  15. 'upload_date': '20160907',
  16. },
  17. }
  18. def _real_extract(self, url):
  19. video_id = self._match_id(url)
  20. webpage = self._download_webpage(url, video_id)
  21. video_url = self._search_regex(
  22. r'(?s)<div[^>]+class=["\']page-diffusion["\'][^>]*>.*?<button[^>]+data-url=(["\'])(?P<url>(?:(?!\1).)+)\1',
  23. webpage, 'video url', group='url')
  24. title = self._og_search_title(webpage)
  25. description = self._og_search_description(webpage)
  26. upload_date_str = self._search_regex(
  27. r'class=["\']cover-emission-period["\'][^>]*>[^<]+\s+(\d{1,2}\s+[^\s]+\s+\d{4})<',
  28. webpage, 'upload date', fatal=False)
  29. if upload_date_str:
  30. upload_date_list = upload_date_str.split()
  31. upload_date_list.reverse()
  32. upload_date_list[1] = '%02d' % (month_by_name(upload_date_list[1], lang='fr') or 0)
  33. upload_date_list[2] = '%02d' % int(upload_date_list[2])
  34. upload_date = ''.join(upload_date_list)
  35. else:
  36. upload_date = None
  37. return {
  38. 'id': video_id,
  39. 'title': title,
  40. 'description': description,
  41. 'upload_date': upload_date,
  42. 'formats': [{
  43. 'url': video_url,
  44. 'vcodec': 'none',
  45. }],
  46. }