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