]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/franceculture.py
debian/gbp.conf: Change to new git-buildpackage syntax.
[youtubedl] / youtube_dl / extractor / franceculture.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..compat import (
6 compat_urlparse,
7 )
8 from ..utils import (
9 determine_ext,
10 int_or_none,
11 )
12
13
14 class FranceCultureIE(InfoExtractor):
15 _VALID_URL = r'https?://(?:www\.)?franceculture\.fr/player/reecouter\?play=(?P<id>[0-9]+)'
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',
22 'alt_title': 'Carnet nomade | 13-14',
23 'vcodec': 'none',
24 'upload_date': '20140301',
25 'thumbnail': r're:^http://www\.franceculture\.fr/.*/images/player/Carnet-nomade\.jpg$',
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,
28 }
29 }
30
31 def _real_extract(self, url):
32 video_id = self._match_id(url)
33 webpage = self._download_webpage(url, video_id)
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)
44
45 title = self._html_search_regex(
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)
50 description = self._html_search_regex(
51 r'<span class="description">(.*?)</span>',
52 webpage, 'description', fatal=False)
53
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
58
59 return {
60 'id': video_id,
61 'url': video_url,
62 'vcodec': vcodec,
63 'uploader': uploader,
64 'timestamp': timestamp,
65 'title': title,
66 'alt_title': alt_title,
67 'thumbnail': thumbnail,
68 'description': description,
69 }