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