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 ..compat import (
  5. compat_urlparse,
  6. )
  7. from ..utils import (
  8. determine_ext,
  9. int_or_none,
  10. )
  11. class FranceCultureIE(InfoExtractor):
  12. _VALID_URL = r'https?://(?:www\.)?franceculture\.fr/player/reecouter\?play=(?P<id>[0-9]+)'
  13. _TEST = {
  14. 'url': 'http://www.franceculture.fr/player/reecouter?play=4795174',
  15. 'info_dict': {
  16. 'id': '4795174',
  17. 'ext': 'mp3',
  18. 'title': 'Rendez-vous au pays des geeks',
  19. 'alt_title': 'Carnet nomade | 13-14',
  20. 'vcodec': 'none',
  21. 'upload_date': '20140301',
  22. 'thumbnail': r're:^http://www\.franceculture\.fr/.*/images/player/Carnet-nomade\.jpg$',
  23. 'description': 'startswith:Avec :Jean-Baptiste Péretié pour son documentaire sur Arte "La revanche des « geeks », une enquête menée aux Etats',
  24. 'timestamp': 1393700400,
  25. }
  26. }
  27. def _real_extract(self, url):
  28. video_id = self._match_id(url)
  29. webpage = self._download_webpage(url, video_id)
  30. video_path = self._search_regex(
  31. r'<a id="player".*?href="([^"]+)"', webpage, 'video path')
  32. video_url = compat_urlparse.urljoin(url, video_path)
  33. timestamp = int_or_none(self._search_regex(
  34. r'<a id="player".*?data-date="([0-9]+)"',
  35. webpage, 'upload date', fatal=False))
  36. thumbnail = self._search_regex(
  37. r'<a id="player".*?>\s+<img src="([^"]+)"',
  38. webpage, 'thumbnail', fatal=False)
  39. title = self._html_search_regex(
  40. r'<span class="title-diffusion">(.*?)</span>', webpage, 'title')
  41. alt_title = self._html_search_regex(
  42. r'<span class="title">(.*?)</span>',
  43. webpage, 'alt_title', fatal=False)
  44. description = self._html_search_regex(
  45. r'<span class="description">(.*?)</span>',
  46. webpage, 'description', fatal=False)
  47. uploader = self._html_search_regex(
  48. r'(?s)<div id="emission".*?<span class="author">(.*?)</span>',
  49. webpage, 'uploader', default=None)
  50. vcodec = 'none' if determine_ext(video_url.lower()) == 'mp3' else None
  51. return {
  52. 'id': video_id,
  53. 'url': video_url,
  54. 'vcodec': vcodec,
  55. 'uploader': uploader,
  56. 'timestamp': timestamp,
  57. 'title': title,
  58. 'alt_title': alt_title,
  59. 'thumbnail': thumbnail,
  60. 'description': description,
  61. }