X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Ffranceinter.py;h=05806895c0a3300dd9db8e68efb15fcb70bb8006;hb=HEAD;hp=932a1f161794a8b89487e2d7483f651c0c3b1551;hpb=c8650f7ecd4fd253b37103c5581d39ddc37b6337;p=youtube-dl diff --git a/youtube_dl/extractor/franceinter.py b/youtube_dl/extractor/franceinter.py index 932a1f161..05806895c 100644 --- a/youtube_dl/extractor/franceinter.py +++ b/youtube_dl/extractor/franceinter.py @@ -1,31 +1,56 @@ +# coding: utf-8 from __future__ import unicode_literals -import re - from .common import InfoExtractor +from ..utils import month_by_name + + class FranceInterIE(InfoExtractor): - - _VALID_URL=r'http://(?:www\.)?franceinter\.fr/player/reecouter\?play=(?P[0-9]{6})' - _TEST={ - u'url':u'http://www.franceinter.fr/player/reecouter?play=793962', - u'file':u'793962.mp3' - - } - - - - - def _real_extract(self,url): - - mobj = re.match(self._VALID_URL, url) - video_id = mobj.group('id') - - webpage=self._download_webpage(url,video_id) - - title=self._search_regex(u'(?<=)(.*)(?=)', webpage, u'title') - - video_url='http://www.franceinter.fr/'+self._search_regex(u'(?<=&urlAOD=)(.*)(?=&startTime)', webpage, u'video url') - - return{'id': video_id,u'url': video_url,u'title': title} - - \ No newline at end of file + _VALID_URL = r'https?://(?:www\.)?franceinter\.fr/emissions/(?P[^?#]+)' + + _TEST = { + 'url': 'https://www.franceinter.fr/emissions/affaires-sensibles/affaires-sensibles-07-septembre-2016', + 'md5': '9e54d7bdb6fdc02a841007f8a975c094', + 'info_dict': { + 'id': 'affaires-sensibles/affaires-sensibles-07-septembre-2016', + 'ext': 'mp3', + 'title': 'Affaire Cahuzac : le contentieux du compte en Suisse', + 'description': 'md5:401969c5d318c061f86bda1fa359292b', + 'upload_date': '20160907', + }, + } + + def _real_extract(self, url): + video_id = self._match_id(url) + + webpage = self._download_webpage(url, video_id) + + video_url = self._search_regex( + r'(?s)]+class=["\']page-diffusion["\'][^>]*>.*?]+data-url=(["\'])(?P(?:(?!\1).)+)\1', + webpage, 'video url', group='url') + + title = self._og_search_title(webpage) + description = self._og_search_description(webpage) + + upload_date_str = self._search_regex( + r'class=["\']\s*cover-emission-period\s*["\'][^>]*>[^<]+\s+(\d{1,2}\s+[^\s]+\s+\d{4})<', + webpage, 'upload date', fatal=False) + if upload_date_str: + upload_date_list = upload_date_str.split() + upload_date_list.reverse() + upload_date_list[1] = '%02d' % (month_by_name(upload_date_list[1], lang='fr') or 0) + upload_date_list[2] = '%02d' % int(upload_date_list[2]) + upload_date = ''.join(upload_date_list) + else: + upload_date = None + + return { + 'id': video_id, + 'title': title, + 'description': description, + 'upload_date': upload_date, + 'formats': [{ + 'url': video_url, + 'vcodec': 'none', + }], + }