Compare commits

..

8 Commits

Author SHA1 Message Date
Stefan Lobbenmeier
5f58b86d12 improved on awkward wording 2024-01-21 13:01:59 +01:00
Stefan Lobbenmeier
0ee2b939b0 Remove {str}, because it turned {int} 18 into None 2024-01-21 12:59:42 +01:00
Stefan Lobbenmeier
273cad0550 Change to raise_login_required 2024-01-21 12:45:18 +01:00
Stefan Lobbenmeier
5f80cef80e Clarify blockedByFsk message 2024-01-21 12:43:12 +01:00
Stefan Lobbenmeier
70eb9b2b76 Add warning when age_rating is not 18 2024-01-21 12:40:50 +01:00
Stefan Lobbenmeier
e521322c1c
Update yt_dlp/extractor/ard.py
Co-authored-by: bashonly <88596187+bashonly@users.noreply.github.com>
2024-01-21 12:05:14 +01:00
Stefan Lobbenmeier
fd8daaf7fc Add constant for _TOKEN_URL 2024-01-21 12:04:51 +01:00
Stefan Lobbenmeier
80ec052c3e
Update yt_dlp/extractor/ard.py
Co-authored-by: bashonly <88596187+bashonly@users.noreply.github.com>
2024-01-21 12:03:20 +01:00

View File

@ -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 = {}