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.

69 lines
2.5 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'''(?sx)
  29. (?:
  30. </h1>|
  31. <div[^>]+class="[^"]*?(?:title-zone-diffusion|heading-zone-(?:wrapper|player-button))[^"]*?"[^>]*>
  32. ).*?
  33. (<button[^>]+data-asset-source="[^"]+"[^>]+>)
  34. ''',
  35. webpage, 'video data'))
  36. video_url = video_data['data-asset-source']
  37. title = video_data.get('data-asset-title') or self._og_search_title(webpage)
  38. description = self._html_search_regex(
  39. r'(?s)<div[^>]+class="intro"[^>]*>.*?<h2>(.+?)</h2>',
  40. webpage, 'description', default=None)
  41. thumbnail = self._search_regex(
  42. r'(?s)<figure[^>]+itemtype="https://schema.org/ImageObject"[^>]*>.*?<img[^>]+(?:data-dejavu-)?src="([^"]+)"',
  43. webpage, 'thumbnail', fatal=False)
  44. uploader = self._html_search_regex(
  45. r'(?s)<span class="author">(.*?)</span>',
  46. webpage, 'uploader', default=None)
  47. ext = determine_ext(video_url.lower())
  48. return {
  49. 'id': display_id,
  50. 'display_id': display_id,
  51. 'url': video_url,
  52. 'title': title,
  53. 'description': description,
  54. 'thumbnail': thumbnail,
  55. 'ext': ext,
  56. 'vcodec': 'none' if ext == 'mp3' else None,
  57. 'uploader': uploader,
  58. 'timestamp': int_or_none(video_data.get('data-asset-created-date')),
  59. 'duration': int_or_none(video_data.get('data-duration')),
  60. }