From: Philipp Hagemeister Date: Thu, 3 Apr 2014 06:55:38 +0000 (+0200) Subject: [franceculture] Add extractor (Fixes #2669) X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=cce929eaac781c03cecfd06dd9f764077c0104e1;p=youtube-dl [franceculture] Add extractor (Fixes #2669) --- diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 6646fe348..84acaa5dc 100644 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -743,7 +743,7 @@ class YoutubeDL(object): ) # Automatically determine file extension if missing if 'ext' not in format: - format['ext'] = determine_ext(format['url']) + format['ext'] = determine_ext(format['url']).lower() format_limit = self.params.get('format_limit', None) if format_limit: diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index e2e66c526..7c3587e47 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -83,6 +83,7 @@ from .fktv import ( ) from .flickr import FlickrIE from .fourtube import FourTubeIE +from .franceculture import FranceCultureIE from .franceinter import FranceInterIE from .francetv import ( PluzzIE, diff --git a/youtube_dl/extractor/franceculture.py b/youtube_dl/extractor/franceculture.py new file mode 100644 index 000000000..898e0dda7 --- /dev/null +++ b/youtube_dl/extractor/franceculture.py @@ -0,0 +1,77 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import json +import re + +from .common import InfoExtractor +from ..utils import ( + compat_parse_qs, + compat_urlparse, +) + + +class FranceCultureIE(InfoExtractor): + _VALID_URL = r'(?Phttp://(?:www\.)?franceculture\.fr/)player/reecouter\?play=(?P[0-9]+)' + _TEST = { + 'url': 'http://www.franceculture.fr/player/reecouter?play=4795174', + 'info_dict': { + 'id': '4795174', + 'ext': 'mp3', + 'title': 'Rendez-vous au pays des geeks', + 'vcodec': 'none', + 'uploader': 'Colette Fellous', + '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 ...', + } + } + + def _real_extract(self, url): + mobj = re.match(self._VALID_URL, url) + video_id = mobj.group('id') + baseurl = mobj.group('baseurl') + + 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._html_search_regex( + r'

(.+?)

', webpage, 'title') + 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) + + return { + 'id': video_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, + }