From 137f07c27a88b07df57df5b2cdebebe3c7722bac Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 5 Aug 2024 11:06:10 +0200 Subject: Merging upstream version 2024.07.01. Signed-off-by: Daniel Baumann --- yt_dlp/extractor/wimtv.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'yt_dlp/extractor/wimtv.py') diff --git a/yt_dlp/extractor/wimtv.py b/yt_dlp/extractor/wimtv.py index d7d77c0..000d143 100644 --- a/yt_dlp/extractor/wimtv.py +++ b/yt_dlp/extractor/wimtv.py @@ -10,14 +10,14 @@ from ..utils import ( class WimTVIE(InfoExtractor): _player = None _UUID_RE = r'[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}' - _VALID_URL = r'''(?x: + _VALID_URL = rf'''(?x: https?://platform\.wim\.tv/ (?: (?:embed/)?\? |\#/webtv/.+?/ ) (?Pvod|live|cast)[=/] - (?P%s).*?)''' % _UUID_RE + (?P{_UUID_RE}).*?)''' _EMBED_REGEX = [rf']+src=["\'](?P{_VALID_URL})'] _TESTS = [{ # vod stream @@ -28,7 +28,7 @@ class WimTVIE(InfoExtractor): 'ext': 'mp4', 'title': 'AMA SUPERCROSS 2020 - R2 ST. LOUIS', 'duration': 6481, - 'thumbnail': r're:https?://.+?/thumbnail/.+?/720$' + 'thumbnail': r're:https?://.+?/thumbnail/.+?/720$', }, 'params': { 'skip_download': True, @@ -66,7 +66,7 @@ class WimTVIE(InfoExtractor): 'vars': [{ 'regex': r'appAuth = "(.+?)"', 'variable': 'app_auth', - }] + }], }, { 'url': 'https://platform.wim.tv/common/config/endpointconfig.js', 'vars': [{ @@ -75,7 +75,7 @@ class WimTVIE(InfoExtractor): }, { 'regex': r'PRODUCTION_HOSTNAME_THUMB\s*\+\s*"(.+?)"', 'variable': 'thumb_server_path', - }] + }], }] for data in datas: @@ -83,13 +83,13 @@ class WimTVIE(InfoExtractor): for var in data['vars']: val = self._search_regex(var['regex'], temp, msg_id) if not val: - raise ExtractorError('%s not found' % var['variable']) + raise ExtractorError('{} not found'.format(var['variable'])) self._player[var['variable']] = val def _generate_token(self): json = self._download_json( 'https://platform.wim.tv/wimtv-server/oauth/token', 'Token generation', - headers={'Authorization': 'Basic %s' % self._player['app_auth']}, + headers={'Authorization': 'Basic {}'.format(self._player['app_auth'])}, data=urlencode_postdata({'grant_type': 'client_credentials'})) token = json.get('access_token') if not token: @@ -101,7 +101,7 @@ class WimTVIE(InfoExtractor): return None if not self._player.get('thumb_server_path'): self._player['thumb_server_path'] = '' - return '%s%s/asset/thumbnail/%s/%s' % ( + return '{}{}/asset/thumbnail/{}/{}'.format( self._player['thumb_server'], self._player['thumb_server_path'], thumb_id, width) @@ -118,11 +118,11 @@ class WimTVIE(InfoExtractor): is_live = False token = self._generate_token() json = self._download_json( - 'https://platform.wim.tv/wimtv-server/api/public/%s/%s/play' % ( - stream_type, video_id), video_id, - headers={'Authorization': 'Bearer %s' % token, - 'Content-Type': 'application/json'}, - data=bytes('{}', 'utf-8')) + f'https://platform.wim.tv/wimtv-server/api/public/{stream_type}/{video_id}/play', + video_id, headers={ + 'Authorization': f'Bearer {token}', + 'Content-Type': 'application/json', + }, data=b'{}') formats = [] for src in json.get('srcs') or []: -- cgit v1.2.3