]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/franceculture.py
Fix "invalid escape sequences" error on Python 3.6
[yt-dlp.git] / youtube_dl / extractor / franceculture.py
CommitLineData
cce929ea
PH
1# coding: utf-8
2from __future__ import unicode_literals
3
cce929ea 4from .common import InfoExtractor
23d9ded6
PH
5from ..utils import (
6 determine_ext,
82997dad 7 unified_strdate,
23d9ded6 8)
cce929ea
PH
9
10
11class FranceCultureIE(InfoExtractor):
82997dad 12 _VALID_URL = r'https?://(?:www\.)?franceculture\.fr/emissions/(?:[^/]+/)*(?P<id>[^/?#&]+)'
cce929ea 13 _TEST = {
82997dad 14 'url': 'http://www.franceculture.fr/emissions/carnet-nomade/rendez-vous-au-pays-des-geeks',
cce929ea 15 'info_dict': {
82997dad
S
16 'id': 'rendez-vous-au-pays-des-geeks',
17 'display_id': 'rendez-vous-au-pays-des-geeks',
cce929ea
PH
18 'ext': 'mp3',
19 'title': 'Rendez-vous au pays des geeks',
ec85ded8 20 'thumbnail': r're:^https?://.*\.jpg$',
cce929ea 21 'upload_date': '20140301',
82997dad 22 'vcodec': 'none',
cce929ea
PH
23 }
24 }
25
82997dad
S
26 def _real_extract(self, url):
27 display_id = self._match_id(url)
23d9ded6 28
82997dad 29 webpage = self._download_webpage(url, display_id)
cce929ea 30
82997dad 31 video_url = self._search_regex(
9946aa5c 32 r'(?s)<div[^>]+class="[^"]*?title-zone-diffusion[^"]*?"[^>]*>.*?<button[^>]+data-asset-source="([^"]+)"',
82997dad 33 webpage, 'video path')
ecf17d16 34
82997dad 35 title = self._og_search_title(webpage)
cce929ea 36
82997dad
S
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(
9946aa5c 41 r'(?s)<figure[^>]+itemtype="https://schema.org/ImageObject"[^>]*>.*?<img[^>]+data-dejavu-src="([^"]+)"',
82997dad 42 webpage, 'thumbnail', fatal=False)
23d9ded6
PH
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
cce929ea
PH
47
48 return {
82997dad
S
49 'id': display_id,
50 'display_id': display_id,
cce929ea 51 'url': video_url,
cce929ea
PH
52 'title': title,
53 'thumbnail': thumbnail,
82997dad
S
54 'vcodec': vcodec,
55 'uploader': uploader,
56 'upload_date': upload_date,
cce929ea 57 }