diff options
author | Nicolas Évrard <nicoe@openhex.org> | 2014-04-28 20:32:13 +0200 |
---|---|---|
committer | Nicolas Évrard <nicoe@openhex.org> | 2014-04-28 20:32:13 +0200 |
commit | 201e3c99b9f02afbee47512ce4ea2474d22f81d6 (patch) | |
tree | 953d5a0ebe23150c4a138c73333799da5e8c01c7 /youtube_dl | |
parent | 8a7a4a979683a6a48af0eea039ed392934f89b0a (diff) |
[RTBFVideo] Add new extractor
Diffstat (limited to 'youtube_dl')
-rw-r--r-- | youtube_dl/extractor/__init__.py | 1 | ||||
-rw-r--r-- | youtube_dl/extractor/rtbf.py | 49 |
2 files changed, 50 insertions, 0 deletions
diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index e389acc6a..a8fef2703 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -210,6 +210,7 @@ from .ringtv import RingTVIE from .ro220 import Ro220IE from .rottentomatoes import RottenTomatoesIE from .roxwel import RoxwelIE +from .rtbf import RTBFVideoIE from .rtlnow import RTLnowIE from .rts import RTSIE from .rtve import RTVEALaCartaIE diff --git a/youtube_dl/extractor/rtbf.py b/youtube_dl/extractor/rtbf.py new file mode 100644 index 000000000..b70c36eaa --- /dev/null +++ b/youtube_dl/extractor/rtbf.py @@ -0,0 +1,49 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import re +import json + +from .common import InfoExtractor +from ..utils import clean_html + +class RTBFVideoIE(InfoExtractor): + _VALID_URL = r'https?://www.rtbf.be/video/(?P<title>[^?]+)\?.*id=(?P<id>[0-9]+)' + _TEST = { + 'url': 'https://www.rtbf.be/video/detail_les-diables-au-coeur-episode-2?id=1921274', + 'md5': '799f334ddf2c0a582ba80c44655be570', + 'info_dict': { + 'id': '1921274', + 'ext': 'mp4', + 'title': 'Les Diables au coeur (épisode 2)', + 'duration': 3099, + } + } + + def _real_extract(self, url): + mobj = re.match(self._VALID_URL, url) + video_id = mobj.group('id') + + # TODO more code goes here, for example ... + webpage = self._download_webpage(url, video_id) + title = self._html_search_regex( + r'<meta property="og:description" content="([^"]*)"', + webpage, 'title', mobj.group('title')) + print title + + iframe_url = self._html_search_regex(r'<iframe [^>]*src="([^"]+)"', + webpage, 'iframe') + iframe = self._download_webpage(iframe_url, video_id) + + data_video_idx = iframe.find('data-video') + next_data_idx = iframe.find('data-', data_video_idx + 1) + json_data_start = data_video_idx + len('data-video=') + 1 + json_data_end = next_data_idx - 2 + video_data = json.loads(clean_html(iframe[json_data_start:json_data_end])) + + return { + 'id': video_id, + 'title': title, + 'url': video_data['data']['downloadUrl'], + 'duration': video_data['data']['duration'], + } |