]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/franceculture.py
Update changelog.
[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 unified_strdate,
8 )
9
10
11 class FranceCultureIE(InfoExtractor):
12 _VALID_URL = r'https?://(?:www\.)?franceculture\.fr/emissions/(?:[^/]+/)*(?P<id>[^/?#&]+)'
13 _TEST = {
14 'url': 'http://www.franceculture.fr/emissions/carnet-nomade/rendez-vous-au-pays-des-geeks',
15 'info_dict': {
16 'id': 'rendez-vous-au-pays-des-geeks',
17 'display_id': 'rendez-vous-au-pays-des-geeks',
18 'ext': 'mp3',
19 'title': 'Rendez-vous au pays des geeks',
20 'thumbnail': 're:^https?://.*\\.jpg$',
21 'upload_date': '20140301',
22 'vcodec': 'none',
23 }
24 }
25
26 def _real_extract(self, url):
27 display_id = self._match_id(url)
28
29 webpage = self._download_webpage(url, display_id)
30
31 video_url = self._search_regex(
32 r'(?s)<div[^>]+class="[^"]*?title-zone-diffusion[^"]*?"[^>]*>.*?<a[^>]+href="([^"]+)"',
33 webpage, 'video path')
34
35 title = self._og_search_title(webpage)
36
37 upload_date = unified_strdate(self._search_regex(
38 '(?s)<div[^>]+class="date"[^>]*>.*?<span[^>]+class="inner"[^>]*>([^<]+)<',
39 webpage, 'upload date', fatal=False))
40 thumbnail = self._search_regex(
41 r'(?s)<figure[^>]+itemtype="https://schema.org/ImageObject"[^>]*>.*?<img[^>]+data-pagespeed-(?:lazy|high-res)-src="([^"]+)"',
42 webpage, 'thumbnail', fatal=False)
43 uploader = self._html_search_regex(
44 r'(?s)<div id="emission".*?<span class="author">(.*?)</span>',
45 webpage, 'uploader', default=None)
46 vcodec = 'none' if determine_ext(video_url.lower()) == 'mp3' else None
47
48 return {
49 'id': display_id,
50 'display_id': display_id,
51 'url': video_url,
52 'title': title,
53 'thumbnail': thumbnail,
54 'vcodec': vcodec,
55 'uploader': uploader,
56 'upload_date': upload_date,
57 }