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.

57 lines
2.0 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. determine_ext,
  6. unified_strdate,
  7. )
  8. class FranceCultureIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:www\.)?franceculture\.fr/emissions/(?:[^/]+/)*(?P<id>[^/?#&]+)'
  10. _TEST = {
  11. 'url': 'http://www.franceculture.fr/emissions/carnet-nomade/rendez-vous-au-pays-des-geeks',
  12. 'info_dict': {
  13. 'id': 'rendez-vous-au-pays-des-geeks',
  14. 'display_id': 'rendez-vous-au-pays-des-geeks',
  15. 'ext': 'mp3',
  16. 'title': 'Rendez-vous au pays des geeks',
  17. 'thumbnail': r're:^https?://.*\.jpg$',
  18. 'upload_date': '20140301',
  19. 'vcodec': 'none',
  20. }
  21. }
  22. def _real_extract(self, url):
  23. display_id = self._match_id(url)
  24. webpage = self._download_webpage(url, display_id)
  25. video_url = self._search_regex(
  26. r'(?s)<div[^>]+class="[^"]*?title-zone-diffusion[^"]*?"[^>]*>.*?<button[^>]+data-asset-source="([^"]+)"',
  27. webpage, 'video path')
  28. title = self._og_search_title(webpage)
  29. upload_date = unified_strdate(self._search_regex(
  30. '(?s)<div[^>]+class="date"[^>]*>.*?<span[^>]+class="inner"[^>]*>([^<]+)<',
  31. webpage, 'upload date', fatal=False))
  32. thumbnail = self._search_regex(
  33. r'(?s)<figure[^>]+itemtype="https://schema.org/ImageObject"[^>]*>.*?<img[^>]+data-dejavu-src="([^"]+)"',
  34. webpage, 'thumbnail', fatal=False)
  35. uploader = self._html_search_regex(
  36. r'(?s)<div id="emission".*?<span class="author">(.*?)</span>',
  37. webpage, 'uploader', default=None)
  38. vcodec = 'none' if determine_ext(video_url.lower()) == 'mp3' else None
  39. return {
  40. 'id': display_id,
  41. 'display_id': display_id,
  42. 'url': video_url,
  43. 'title': title,
  44. 'thumbnail': thumbnail,
  45. 'vcodec': vcodec,
  46. 'uploader': uploader,
  47. 'upload_date': upload_date,
  48. }