1
0
mirror of https://github.com/l1ving/youtube-dl synced 2020-11-18 19:53:54 -08:00

removed redactie, added vrt.be fixed downloader

This commit is contained in:
Arthur Bols 2019-03-31 17:57:41 +02:00
parent 93bb6b1bae
commit 31f1691299

View File

@ -6,12 +6,14 @@ import re
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ( from ..utils import (
float_or_none, float_or_none,
int_or_none,
try_get,
) )
class VRTIE(InfoExtractor): class VRTIE(InfoExtractor):
IE_DESC = 'deredactie.be, sporza.be, cobra.be and cobra.canvas.be' IE_DESC = 'vrt.be, sporza.be, cobra.be and cobra.canvas.be'
_VALID_URL = r'https?://(?:deredactie|sporza|cobra(?:\.canvas)?)\.be/cm/(?:[^/]+/)+(?P<id>[^/]+)/*' _VALID_URL = r'https?://(?:www\.)?(?:vrt|sporza|cobra(?:\.canvas)?)\.be/(?:[^/]+/)+(?P<id>[^/]+)/*'
_TESTS = [ _TESTS = [
# deredactie.be # deredactie.be
{ {
@ -96,39 +98,39 @@ class VRTIE(InfoExtractor):
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
video_id = self._search_regex( video_id = self._search_regex(
r'data-video-id="([^"]+)_[^"]+"', webpage, 'video id', fatal=False) r'data-videoid="([^"]+)"', webpage, 'video id')
src = self._search_regex( publication_id = self._search_regex(
r'data-video-src="([^"]+)"', webpage, 'video src', default=None) r'data-publicationid="([^"]+)"', webpage, 'publication id')
video_type = self._search_regex( media_url = self._search_regex(
r'data-video-type="([^"]+)"', webpage, 'video type', default=None) r'data-mediaapiurl="([^"]+)"', webpage, 'media url')
if video_type == 'YouTubeVideo': client = self._search_regex(
return self.url_result(src, 'Youtube') r'data-client="([^"]+)"', webpage, 'client')
headers = {'Content-Type': 'application/json'}
result = self._download_json(
'%s/tokens' % (media_url), video_id,
'Downloading player token',
headers=headers, data={})
vrtPlayerToken = result['vrtPlayerToken']
print(vrtPlayerToken)
formats = [] formats = []
mobj = re.search( targetUrls = self._download_json(
r'data-video-iphone-server="(?P<server>[^"]+)"\s+data-video-iphone-path="(?P<path>[^"]+)"', '%s/videos/%s$%s?vrtPlayerToken=%s&client=%s' % (media_url, publication_id, video_id, vrtPlayerToken, client),
webpage) video_id,
if mobj: 'Downloading target url data',
formats.extend(self._extract_m3u8_formats( headers=headers)
'%s/%s' % (mobj.group('server'), mobj.group('path')),
video_id, 'mp4', m3u8_id='hls', fatal=False))
if src: for t in targetUrls['targetUrls']:
formats = self._extract_wowza_formats(src, video_id) if t['url'].endswith('m3u8'):
if 'data-video-geoblocking="true"' not in webpage: formats.extend(self._extract_m3u8_formats(t['url'], video_id))
for f in formats: elif t['url'].endswith('mpd'):
if f['url'].startswith('rtsp://'): formats.extend(self._extract_mpd_formats(t['url'], video_id))
http_format = f.copy()
http_format.update({
'url': f['url'].replace('rtsp://', 'http://').replace('vod.', 'download.').replace('/_definst_/', '/').replace('mp4:', ''),
'format_id': f['format_id'].replace('rtsp', 'http'),
'protocol': 'http',
})
formats.append(http_format)
if not formats and 'data-video-geoblocking="true"' in webpage: if not formats and 'data-video-geoblocking="true"' in webpage:
self.raise_geo_restricted('This video is only available in Belgium') self.raise_geo_restricted('This video is only available in Belgium')
@ -141,8 +143,8 @@ class VRTIE(InfoExtractor):
timestamp = float_or_none(self._search_regex( timestamp = float_or_none(self._search_regex(
r'data-video-sitestat-pubdate="(\d+)"', webpage, 'timestamp', fatal=False), 1000) r'data-video-sitestat-pubdate="(\d+)"', webpage, 'timestamp', fatal=False), 1000)
duration = float_or_none(self._search_regex( duration = float_or_none(self._search_regex(
r'data-video-duration="(\d+)"', webpage, 'duration', fatal=False), 1000) r'data-duration="(\d+)"', webpage, 'duration', fatal=False), 1000)
return { return {
'id': video_id, 'id': video_id,
'title': title, 'title': title,