1
0
Fork 0
mirror of https://github.com/blackjack4494/yt-dlc.git synced 2024-12-23 00:07:49 +00:00

[rtbf] Fix extraction (Closes #5803)

This commit is contained in:
Sergey M․ 2015-05-24 21:09:08 +06:00
parent 8cdf03a7a2
commit 63f3cab4ae

View file

@ -1,10 +1,11 @@
# coding: utf-8 # coding: utf-8
from __future__ import unicode_literals from __future__ import unicode_literals
import re
import json
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import (
int_or_none,
unescapeHTML,
)
class RTBFIE(InfoExtractor): class RTBFIE(InfoExtractor):
@ -16,25 +17,24 @@ class RTBFIE(InfoExtractor):
'id': '1921274', 'id': '1921274',
'ext': 'mp4', 'ext': 'mp4',
'title': 'Les Diables au coeur (épisode 2)', 'title': 'Les Diables au coeur (épisode 2)',
'description': 'Football - Diables Rouges',
'duration': 3099, 'duration': 3099,
'timestamp': 1398456336,
'upload_date': '20140425',
} }
} }
def _real_extract(self, url): def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url) video_id = self._match_id(url)
video_id = mobj.group('id')
page = self._download_webpage('https://www.rtbf.be/video/embed?id=%s' % video_id, video_id) webpage = self._download_webpage(
'http://www.rtbf.be/video/embed?id=%s' % video_id, video_id)
data = json.loads(self._html_search_regex( data = self._parse_json(
r'<div class="js-player-embed(?: player-embed)?" data-video="([^"]+)"', page, 'data video'))['data'] unescapeHTML(self._search_regex(
r'data-video="([^"]+)"', webpage, 'data video')),
video_id)
video_url = data.get('downloadUrl') or data.get('url') video_url = data.get('downloadUrl') or data.get('url')
if data['provider'].lower() == 'youtube': if data.get('provider').lower() == 'youtube':
return self.url_result(video_url, 'Youtube') return self.url_result(video_url, 'Youtube')
return { return {
@ -42,8 +42,8 @@ class RTBFIE(InfoExtractor):
'url': video_url, 'url': video_url,
'title': data['title'], 'title': data['title'],
'description': data.get('description') or data.get('subtitle'), 'description': data.get('description') or data.get('subtitle'),
'thumbnail': data['thumbnail']['large'], 'thumbnail': data.get('thumbnail'),
'duration': data.get('duration') or data.get('realDuration'), 'duration': data.get('duration') or data.get('realDuration'),
'timestamp': data['created'], 'timestamp': int_or_none(data.get('created')),
'view_count': data['viewCount'], 'view_count': int_or_none(data.get('viewCount')),
} }