diff options
author | Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com> | 2013-07-05 21:31:50 +0200 |
---|---|---|
committer | Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com> | 2013-07-05 21:31:50 +0200 |
commit | fbaaad49d7d6683b620929233ae661de64df1101 (patch) | |
tree | a6a67fe304ca62ed135bfe7fdca81cae4003ddea /youtube_dl/extractor | |
parent | b29f3b250d78340fe6ba64b4f2f3c940d112bd6a (diff) |
Add BrightcoveIE (closes #832)
It only accepts the urls that are use for embedding the video, it doesn't search in generic webpages to find Brightcove videos
Diffstat (limited to 'youtube_dl/extractor')
-rw-r--r-- | youtube_dl/extractor/__init__.py | 1 | ||||
-rw-r--r-- | youtube_dl/extractor/brightcove.py | 32 |
2 files changed, 33 insertions, 0 deletions
diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index 41efc57d4..ff5cbf4c9 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -5,6 +5,7 @@ from .auengine import AUEngineIE from .bandcamp import BandcampIE from .bliptv import BlipTVIE, BlipTVUserIE from .breakcom import BreakIE +from .brightcove import BrightcoveIE from .collegehumor import CollegeHumorIE from .comedycentral import ComedyCentralIE from .cspan import CSpanIE diff --git a/youtube_dl/extractor/brightcove.py b/youtube_dl/extractor/brightcove.py new file mode 100644 index 000000000..f85acbb5d --- /dev/null +++ b/youtube_dl/extractor/brightcove.py @@ -0,0 +1,32 @@ +import re +import json + +from .common import InfoExtractor + +class BrightcoveIE(InfoExtractor): + _VALID_URL = r'http://.*brightcove\.com/.*\?(?P<query>.*videoPlayer=(?P<id>\d*).*)' + + def _real_extract(self, url): + mobj = re.match(self._VALID_URL, url) + query = mobj.group('query') + video_id = mobj.group('id') + + request_url = 'http://c.brightcove.com/services/viewer/htmlFederated?%s' % query + webpage = self._download_webpage(request_url, video_id) + + self.report_extraction(video_id) + info = self._search_regex(r'var experienceJSON = ({.*?});', webpage, 'json') + info = json.loads(info)['data'] + video_info = info['programmedContent']['videoPlayer']['mediaDTO'] + renditions = video_info['renditions'] + renditions = sorted(renditions, key=lambda r: r['size']) + best_format = renditions[-1] + + return {'id': video_id, + 'title': video_info['displayName'], + 'url': best_format['defaultURL'], + 'ext': 'mp4', + 'description': video_info.get('shortDescription'), + 'thumbnail': video_info.get('videoStillURL') or video_info.get('thumbnailURL'), + 'uploader': video_info.get('publisherName'), + } |