mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-23 09:01:43 +00:00
parent
d9190e4467
commit
aeec0e44e2
@ -1,4 +1,5 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
@ -41,9 +42,9 @@ class CanvasIE(InfoExtractor):
|
|||||||
_GEO_BYPASS = False
|
_GEO_BYPASS = False
|
||||||
_HLS_ENTRY_PROTOCOLS_MAP = {
|
_HLS_ENTRY_PROTOCOLS_MAP = {
|
||||||
'HLS': 'm3u8_native',
|
'HLS': 'm3u8_native',
|
||||||
'HLS_AES': 'm3u8',
|
'HLS_AES': 'm3u8_native',
|
||||||
}
|
}
|
||||||
_REST_API_BASE = 'https://media-services-public.vrt.be/vualto-video-aggregator-web/rest/external/v1'
|
_REST_API_BASE = 'https://media-services-public.vrt.be/vualto-video-aggregator-web/rest/external/v2'
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = self._match_valid_url(url)
|
mobj = self._match_valid_url(url)
|
||||||
@ -59,16 +60,21 @@ def _real_extract(self, url):
|
|||||||
|
|
||||||
# New API endpoint
|
# New API endpoint
|
||||||
if not data:
|
if not data:
|
||||||
|
vrtnutoken = self._download_json('https://token.vrt.be/refreshtoken',
|
||||||
|
video_id, note='refreshtoken: Retrieve vrtnutoken',
|
||||||
|
errnote='refreshtoken failed')['vrtnutoken']
|
||||||
headers = self.geo_verification_headers()
|
headers = self.geo_verification_headers()
|
||||||
headers.update({'Content-Type': 'application/json'})
|
headers.update({'Content-Type': 'application/json; charset=utf-8'})
|
||||||
token = self._download_json(
|
vrtPlayerToken = self._download_json(
|
||||||
'%s/tokens' % self._REST_API_BASE, video_id,
|
'%s/tokens' % self._REST_API_BASE, video_id,
|
||||||
'Downloading token', data=b'', headers=headers)['vrtPlayerToken']
|
'Downloading token', headers=headers, data=json.dumps({
|
||||||
|
'identityToken': vrtnutoken
|
||||||
|
}).encode('utf-8'))['vrtPlayerToken']
|
||||||
data = self._download_json(
|
data = self._download_json(
|
||||||
'%s/videos/%s' % (self._REST_API_BASE, video_id),
|
'%s/videos/%s' % (self._REST_API_BASE, video_id),
|
||||||
video_id, 'Downloading video JSON', query={
|
video_id, 'Downloading video JSON', query={
|
||||||
'vrtPlayerToken': token,
|
'vrtPlayerToken': vrtPlayerToken,
|
||||||
'client': '%s@PROD' % site_id,
|
'client': 'null',
|
||||||
}, expected_status=400)
|
}, expected_status=400)
|
||||||
if not data.get('title'):
|
if not data.get('title'):
|
||||||
code = data.get('code')
|
code = data.get('code')
|
||||||
@ -264,7 +270,7 @@ class VrtNUIE(GigyaBaseIE):
|
|||||||
'expected_warnings': ['Unable to download asset JSON', 'is not a supported codec', 'Unknown MIME type'],
|
'expected_warnings': ['Unable to download asset JSON', 'is not a supported codec', 'Unknown MIME type'],
|
||||||
}]
|
}]
|
||||||
_NETRC_MACHINE = 'vrtnu'
|
_NETRC_MACHINE = 'vrtnu'
|
||||||
_APIKEY = '3_qhEcPa5JGFROVwu5SWKqJ4mVOIkwlFNMSKwzPDAh8QZOtHqu6L4nD5Q7lk0eXOOG'
|
_APIKEY = '3_0Z2HujMtiWq_pkAjgnS2Md2E11a1AwZjYiBETtwNE-EoEHDINgtnvcAOpNgmrVGy'
|
||||||
_CONTEXT_ID = 'R3595707040'
|
_CONTEXT_ID = 'R3595707040'
|
||||||
|
|
||||||
def _real_initialize(self):
|
def _real_initialize(self):
|
||||||
@ -275,16 +281,13 @@ def _login(self):
|
|||||||
if username is None:
|
if username is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
auth_info = self._download_json(
|
auth_info = self._gigya_login({
|
||||||
'https://accounts.vrt.be/accounts.login', None,
|
'APIKey': self._APIKEY,
|
||||||
note='Login data', errnote='Could not get Login data',
|
'targetEnv': 'jssdk',
|
||||||
headers={}, data=urlencode_postdata({
|
'loginID': username,
|
||||||
'loginID': username,
|
'password': password,
|
||||||
'password': password,
|
'authMode': 'cookie',
|
||||||
'sessionExpiration': '-2',
|
})
|
||||||
'APIKey': self._APIKEY,
|
|
||||||
'targetEnv': 'jssdk',
|
|
||||||
}))
|
|
||||||
|
|
||||||
if auth_info.get('errorDetails'):
|
if auth_info.get('errorDetails'):
|
||||||
raise ExtractorError('Unable to login: VrtNU said: ' + auth_info.get('errorDetails'), expected=True)
|
raise ExtractorError('Unable to login: VrtNU said: ' + auth_info.get('errorDetails'), expected=True)
|
||||||
@ -301,14 +304,15 @@ def _login(self):
|
|||||||
'UID': auth_info['UID'],
|
'UID': auth_info['UID'],
|
||||||
'UIDSignature': auth_info['UIDSignature'],
|
'UIDSignature': auth_info['UIDSignature'],
|
||||||
'signatureTimestamp': auth_info['signatureTimestamp'],
|
'signatureTimestamp': auth_info['signatureTimestamp'],
|
||||||
'client_id': 'vrtnu-site',
|
|
||||||
'_csrf': self._get_cookies('https://login.vrt.be').get('OIDCXSRF').value,
|
'_csrf': self._get_cookies('https://login.vrt.be').get('OIDCXSRF').value,
|
||||||
}
|
}
|
||||||
|
|
||||||
self._request_webpage(
|
self._request_webpage(
|
||||||
'https://login.vrt.be/perform_login',
|
'https://login.vrt.be/perform_login',
|
||||||
None, note='Requesting a token', errnote='Could not get a token',
|
None, note='Performing login', errnote='perform login failed',
|
||||||
headers={}, data=urlencode_postdata(post_data))
|
headers={}, query={
|
||||||
|
'client_id': 'vrtnu-site'
|
||||||
|
}, data=urlencode_postdata(post_data))
|
||||||
|
|
||||||
except ExtractorError as e:
|
except ExtractorError as e:
|
||||||
if isinstance(e.cause, compat_HTTPError) and e.cause.code == 401:
|
if isinstance(e.cause, compat_HTTPError) and e.cause.code == 401:
|
||||||
|
Loading…
Reference in New Issue
Block a user