Compare commits

..

2 Commits

Author SHA1 Message Date
Nicolas Dato
b01da2335c fix flake8 2023-12-12 11:47:58 -03:00
Nicolas Dato
66582ba423 [rudovideo] improving the access_token. now it's fatal if the token API response doesn't contain the data.authToken value 2023-12-12 11:47:10 -03:00

View File

@ -1,5 +1,11 @@
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ExtractorError, js_to_json, traverse_obj, update_url_query from ..utils import (
ExtractorError,
js_to_json,
traverse_obj,
update_url_query,
url_or_none,
)
class RudoVideoIE(InfoExtractor): class RudoVideoIE(InfoExtractor):
@ -86,12 +92,12 @@ class RudoVideoIE(InfoExtractor):
r'<script>var\s+_\$_[a-zA-Z0-9]+\s*=', webpage, 'access token array', video_id, r'<script>var\s+_\$_[a-zA-Z0-9]+\s*=', webpage, 'access token array', video_id,
contains_pattern=r'\[(?s:.+)\]', default=None, transform_source=js_to_json) contains_pattern=r'\[(?s:.+)\]', default=None, transform_source=js_to_json)
if token_array: if token_array:
if len(token_array) != 9: token_url = traverse_obj(token_array, (..., {url_or_none}), get_all=False)
if not token_url:
raise ExtractorError('Invalid access token array') raise ExtractorError('Invalid access token array')
access_token = self._download_json(token_array[0], video_id, note='Downloading access token') access_token = self._download_json(
m3u8_url = update_url_query(m3u8_url, { token_url, video_id, note='Downloading access token')['data']['authToken']
'auth-token': traverse_obj(access_token, ('data', 'authToken')) m3u8_url = update_url_query(m3u8_url, {'auth-token': access_token})
})
return { return {
'id': video_id, 'id': video_id,