logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

franceinter.py (2215B)


  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. 'thumbnail': r're:^https?://.*\.jpg',
  16. 'upload_date': '20160907',
  17. },
  18. }
  19. def _real_extract(self, url):
  20. video_id = self._match_id(url)
  21. webpage = self._download_webpage(url, video_id)
  22. video_url = self._search_regex(
  23. r'(?s)<div[^>]+class=["\']page-diffusion["\'][^>]*>.*?<button[^>]+data-url=(["\'])(?P<url>(?:(?!\1).)+)\1',
  24. webpage, 'video url', group='url')
  25. title = self._og_search_title(webpage)
  26. description = self._og_search_description(webpage)
  27. thumbnail = self._html_search_meta(['og:image', 'twitter:image'], webpage)
  28. upload_date_str = self._search_regex(
  29. r'class=["\']\s*cover-emission-period\s*["\'][^>]*>[^<]+\s+(\d{1,2}\s+[^\s]+\s+\d{4})<',
  30. webpage, 'upload date', fatal=False)
  31. if upload_date_str:
  32. upload_date_list = upload_date_str.split()
  33. upload_date_list.reverse()
  34. upload_date_list[1] = '%02d' % (month_by_name(upload_date_list[1], lang='fr') or 0)
  35. upload_date_list[2] = '%02d' % int(upload_date_list[2])
  36. upload_date = ''.join(upload_date_list)
  37. else:
  38. upload_date = None
  39. return {
  40. 'id': video_id,
  41. 'title': title,
  42. 'description': description,
  43. 'thumbnail': thumbnail,
  44. 'upload_date': upload_date,
  45. 'formats': [{
  46. 'url': video_url,
  47. 'vcodec': 'none',
  48. }],
  49. }