X-Git-Url: https://git.rapsys.eu/youtubedl/blobdiff_plain/a070911bf98c751e4425008f1335cc57c86d30fc..0ae75ad42cc6f25af12b54201dcbadfc116f923f:/youtube_dl/extractor/franceculture.py?ds=sidebyside diff --git a/youtube_dl/extractor/franceculture.py b/youtube_dl/extractor/franceculture.py index 0c29721..186da0d 100644 --- a/youtube_dl/extractor/franceculture.py +++ b/youtube_dl/extractor/franceculture.py @@ -1,77 +1,57 @@ # coding: utf-8 from __future__ import unicode_literals -import json -import re - from .common import InfoExtractor -from ..compat import ( - compat_parse_qs, - compat_urlparse, +from ..utils import ( + determine_ext, + unified_strdate, ) class FranceCultureIE(InfoExtractor): - _VALID_URL = r'(?Phttp://(?:www\.)?franceculture\.fr/)player/reecouter\?play=(?P[0-9]+)' + _VALID_URL = r'https?://(?:www\.)?franceculture\.fr/emissions/(?:[^/]+/)*(?P[^/?#&]+)' _TEST = { - 'url': 'http://www.franceculture.fr/player/reecouter?play=4795174', + 'url': 'http://www.franceculture.fr/emissions/carnet-nomade/rendez-vous-au-pays-des-geeks', 'info_dict': { - 'id': '4795174', + 'id': 'rendez-vous-au-pays-des-geeks', + 'display_id': 'rendez-vous-au-pays-des-geeks', 'ext': 'mp3', 'title': 'Rendez-vous au pays des geeks', - 'vcodec': 'none', - 'uploader': 'Colette Fellous', + 'thumbnail': 're:^https?://.*\\.jpg$', 'upload_date': '20140301', - 'duration': 3601, - 'thumbnail': r're:^http://www\.franceculture\.fr/.*/images/player/Carnet-nomade\.jpg$', - 'description': 'Avec :Jean-Baptiste Péretié pour son documentaire sur Arte "La revanche des « geeks », une enquête menée aux Etats-Unis dans la S ...', + 'vcodec': 'none', } } def _real_extract(self, url): - mobj = re.match(self._VALID_URL, url) - video_id = mobj.group('id') - baseurl = mobj.group('baseurl') + display_id = self._match_id(url) + + webpage = self._download_webpage(url, display_id) + + video_url = self._search_regex( + r'(?s)]+class="[^"]*?title-zone-diffusion[^"]*?"[^>]*>.*?]+href="([^"]+)"', + webpage, 'video path') - webpage = self._download_webpage(url, video_id) - params_code = self._search_regex( - r"", - webpage, 'parameter code') - params = compat_parse_qs(params_code) - video_url = compat_urlparse.urljoin(baseurl, params['urlAOD'][0]) + title = self._og_search_title(webpage) - title = self._html_search_regex( - r'

(.+?)

', webpage, 'title') + upload_date = unified_strdate(self._search_regex( + '(?s)]+class="date"[^>]*>.*?]+class="inner"[^>]*>([^<]+)<', + webpage, 'upload date', fatal=False)) + thumbnail = self._search_regex( + r'(?s)]+itemtype="https://schema.org/ImageObject"[^>]*>.*?]+data-pagespeed-(?:lazy|high-res)-src="([^"]+)"', + webpage, 'thumbnail', fatal=False) uploader = self._html_search_regex( r'(?s)
(.*?)', - webpage, 'uploader', fatal=False) - thumbnail_part = self._html_search_regex( - r'(?s)
(.*?)

', webpage, 'description') - - info = json.loads(params['infoData'][0])[0] - duration = info.get('media_length') - upload_date_candidate = info.get('media_section5') - upload_date = ( - upload_date_candidate - if (upload_date_candidate is not None and - re.match(r'[0-9]{8}$', upload_date_candidate)) - else None) + webpage, 'uploader', default=None) + vcodec = 'none' if determine_ext(video_url.lower()) == 'mp3' else None return { - 'id': video_id, + 'id': display_id, + 'display_id': display_id, 'url': video_url, - 'vcodec': 'none' if video_url.lower().endswith('.mp3') else None, - 'duration': duration, - 'uploader': uploader, - 'upload_date': upload_date, 'title': title, 'thumbnail': thumbnail, - 'description': description, + 'vcodec': vcodec, + 'uploader': uploader, + 'upload_date': upload_date, }