]>
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, | |
ecf17d16 | 11 | ExtractorError, |
23d9ded6 | 12 | ) |
cce929ea PH |
13 | |
14 | ||
15 | class FranceCultureIE(InfoExtractor): | |
23d9ded6 | 16 | _VALID_URL = r'https?://(?:www\.)?franceculture\.fr/player/reecouter\?play=(?P<id>[0-9]+)' |
cce929ea PH |
17 | _TEST = { |
18 | 'url': 'http://www.franceculture.fr/player/reecouter?play=4795174', | |
19 | 'info_dict': { | |
20 | 'id': '4795174', | |
21 | 'ext': 'mp3', | |
22 | 'title': 'Rendez-vous au pays des geeks', | |
23d9ded6 | 23 | 'alt_title': 'Carnet nomade | 13-14', |
cce929ea | 24 | 'vcodec': 'none', |
cce929ea | 25 | 'upload_date': '20140301', |
7447661e JMF |
26 | 'thumbnail': r're:^http://static\.franceculture\.fr/.*/images/player/Carnet-nomade\.jpg$', |
27 | 'description': 'startswith:Avec :Jean-Baptiste Péretié pour son documentaire sur Arte "La revanche', | |
23d9ded6 | 28 | 'timestamp': 1393700400, |
cce929ea PH |
29 | } |
30 | } | |
31 | ||
ecf17d16 | 32 | def _extract_from_player(self, url, video_id): |
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 | 44 | |
ecf17d16 | 45 | display_id = self._search_regex( |
46 | r'<span class="path-diffusion">emission-(.*?)</span>', webpage, 'display_id') | |
47 | ||
cce929ea | 48 | title = self._html_search_regex( |
23d9ded6 PH |
49 | r'<span class="title-diffusion">(.*?)</span>', webpage, 'title') |
50 | alt_title = self._html_search_regex( | |
51 | r'<span class="title">(.*?)</span>', | |
52 | webpage, 'alt_title', fatal=False) | |
cce929ea | 53 | description = self._html_search_regex( |
23d9ded6 PH |
54 | r'<span class="description">(.*?)</span>', |
55 | webpage, 'description', fatal=False) | |
cce929ea | 56 | |
23d9ded6 PH |
57 | uploader = self._html_search_regex( |
58 | r'(?s)<div id="emission".*?<span class="author">(.*?)</span>', | |
59 | webpage, 'uploader', default=None) | |
60 | vcodec = 'none' if determine_ext(video_url.lower()) == 'mp3' else None | |
cce929ea PH |
61 | |
62 | return { | |
63 | 'id': video_id, | |
64 | 'url': video_url, | |
23d9ded6 | 65 | 'vcodec': vcodec, |
cce929ea | 66 | 'uploader': uploader, |
23d9ded6 | 67 | 'timestamp': timestamp, |
cce929ea | 68 | 'title': title, |
23d9ded6 | 69 | 'alt_title': alt_title, |
cce929ea PH |
70 | 'thumbnail': thumbnail, |
71 | 'description': description, | |
ecf17d16 | 72 | 'display_id': display_id, |
cce929ea | 73 | } |
ecf17d16 | 74 | |
75 | def _real_extract(self, url): | |
76 | video_id = self._match_id(url) | |
77 | return self._extract_from_player(url, video_id) | |
78 | ||
79 | ||
80 | class FranceCultureEmissionIE(FranceCultureIE): | |
81 | _VALID_URL = r'https?://(?:www\.)?franceculture\.fr/emission-(?P<id>[^?#]+)' | |
82 | _TEST = { | |
83 | 'url': 'http://www.franceculture.fr/emission-les-carnets-de-la-creation-jean-gabriel-periot-cineaste-2015-10-13', | |
84 | 'info_dict': { | |
85 | 'title': 'Jean-Gabriel Périot, cinéaste', | |
86 | 'alt_title': 'Les Carnets de la création', | |
87 | 'id': '5093239', | |
88 | 'display_id': 'les-carnets-de-la-creation-jean-gabriel-periot-cineaste-2015-10-13', | |
89 | 'ext': 'mp3', | |
90 | 'timestamp': 1444762500, | |
91 | 'upload_date': '20151013', | |
92 | 'description': 'startswith:Aujourd\'hui dans "Les carnets de la création", le cinéaste', | |
93 | }, | |
94 | } | |
95 | ||
96 | def _real_extract(self, url): | |
97 | video_id = self._match_id(url) | |
98 | webpage = self._download_webpage(url, video_id) | |
99 | video_path = self._html_search_regex( | |
100 | r'<a class="rf-player-open".*?href="([^"]+)"', webpage, 'video path', 'no_path_player') | |
101 | if video_path == 'no_path_player': | |
102 | raise ExtractorError('no player : no sound in this page.', expected=True) | |
103 | new_id = self._search_regex('play=(?P<id>[0-9]+)', video_path, 'new_id', group='id') | |
104 | video_url = compat_urlparse.urljoin(url, video_path) | |
105 | return self._extract_from_player(video_url, new_id) |