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.

63 lines
2.4 KiB

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