mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-05 15:01:24 +01:00
Compare commits
8 Commits
224ded4761
...
5f58b86d12
Author | SHA1 | Date | |
---|---|---|---|
|
5f58b86d12 | ||
|
0ee2b939b0 | ||
|
273cad0550 | ||
|
5f80cef80e | ||
|
70eb9b2b76 | ||
|
e521322c1c | ||
|
fd8daaf7fc | ||
|
80ec052c3e |
|
@ -239,6 +239,7 @@ class ARDBetaMediathekIE(InfoExtractor):
|
|||
(?P<id>[a-zA-Z0-9]+)
|
||||
/?(?:[?#]|$)'''
|
||||
_GEO_COUNTRIES = ['DE']
|
||||
_TOKEN_URL = 'https://sso.ardmediathek.de/sso/token'
|
||||
|
||||
_TESTS = [{
|
||||
'url': 'https://www.ardmediathek.de/video/filme-im-mdr/liebe-auf-vier-pfoten/mdr-fernsehen/Y3JpZDovL21kci5kZS9zZW5kdW5nLzI4MjA0MC80MjIwOTEtNDAyNTM0',
|
||||
|
@ -367,21 +368,23 @@ class ARDBetaMediathekIE(InfoExtractor):
|
|||
}
|
||||
headers = {}
|
||||
|
||||
ams_cookie = self._get_cookies("https://sso.ardmediathek.de/sso/token").get("ams")
|
||||
if ams_cookie:
|
||||
token = self._download_json('https://sso.ardmediathek.de/sso/token', display_id,
|
||||
fatal=False, note='Getting token for age verification')
|
||||
id_token = traverse_obj(token, 'idToken')
|
||||
if not id_token:
|
||||
self.report_warning('Unable to find id token, continuing without authentication')
|
||||
|
||||
if self._get_cookies(self._TOKEN_URL).get('ams'):
|
||||
token = self._download_json(
|
||||
self._TOKEN_URL, display_id, 'Fetching token for age verification',
|
||||
'Unable to fetch age verification token', fatal=False)
|
||||
id_token = traverse_obj(token, ('idToken', {str}))
|
||||
user_id = traverse_obj(id_token, ({jwt_decode_hs256}, ('user_id', 'sub'), {str}), get_all=False)
|
||||
if not id_token or not user_id:
|
||||
self.report_warning('Unable to extract token, continuing without authentication')
|
||||
else:
|
||||
jwt_token_decoded = jwt_decode_hs256(id_token)
|
||||
user_id = traverse_obj(jwt_token_decoded, 'user_id', 'sub')
|
||||
|
||||
headers['x-authorization'] = f'Bearer {id_token}'
|
||||
query['userId'] = user_id
|
||||
|
||||
age_rating = traverse_obj(id_token, ({jwt_decode_hs256}, 'age_rating'), get_all=False)
|
||||
if age_rating != 18:
|
||||
self.report_warning(f'Authenticated age_rating is not 18, but "{age_rating}", '
|
||||
'video might still be blocked')
|
||||
|
||||
page_data = self._download_json(
|
||||
f'https://api.ardmediathek.de/page-gateway/pages/ard/item/{display_id}',
|
||||
display_id, query=query, headers=headers)
|
||||
|
@ -403,9 +406,9 @@ class ARDBetaMediathekIE(InfoExtractor):
|
|||
media_data = traverse_obj(player_data, ('mediaCollection', 'embedded', {dict}))
|
||||
|
||||
if player_data.get('blockedByFsk'):
|
||||
self.raise_no_formats(
|
||||
self.raise_login_required(
|
||||
'This video is only available after 22:00, '
|
||||
'try passing cookies to enable age verification ', expected=True)
|
||||
'try passing cookies a verified account session to enable age verification ')
|
||||
|
||||
formats = []
|
||||
subtitles = {}
|
||||
|
|
Loading…
Reference in New Issue
Block a user