franceinter.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. from .common import InfoExtractor
  2. from ..utils import month_by_name
  3. class FranceInterIE(InfoExtractor):
  4. _VALID_URL = r'https?://(?:www\.)?franceinter\.fr/emissions/(?P<id>[^?#]+)'
  5. _TEST = {
  6. 'url': 'https://www.franceinter.fr/emissions/affaires-sensibles/affaires-sensibles-07-septembre-2016',
  7. 'md5': '9e54d7bdb6fdc02a841007f8a975c094',
  8. 'info_dict': {
  9. 'id': 'affaires-sensibles/affaires-sensibles-07-septembre-2016',
  10. 'ext': 'mp3',
  11. 'title': 'Affaire Cahuzac : le contentieux du compte en Suisse',
  12. 'description': 'md5:401969c5d318c061f86bda1fa359292b',
  13. 'thumbnail': r're:^https?://.*\.jpg',
  14. 'upload_date': '20160907',
  15. },
  16. }
  17. def _real_extract(self, url):
  18. video_id = self._match_id(url)
  19. webpage = self._download_webpage(url, video_id)
  20. video_url = self._search_regex(
  21. r'(?s)<div[^>]+class=["\']page-diffusion["\'][^>]*>.*?<button[^>]+data-url=(["\'])(?P<url>(?:(?!\1).)+)\1',
  22. webpage, 'video url', group='url')
  23. title = self._og_search_title(webpage)
  24. description = self._og_search_description(webpage)
  25. thumbnail = self._html_search_meta(['og:image', 'twitter:image'], webpage)
  26. upload_date_str = self._search_regex(
  27. r'class=["\']\s*cover-emission-period\s*["\'][^>]*>[^<]+\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. 'thumbnail': thumbnail,
  42. 'upload_date': upload_date,
  43. 'formats': [{
  44. 'url': video_url,
  45. 'vcodec': 'none',
  46. }],
  47. }