[ie/vrt] (Hopefully) fix ruff errors

This commit is contained in:
stdh 2024-08-01 21:20:46 +02:00
parent ddeec34393
commit 1433b22da5
2 changed files with 12 additions and 12 deletions

View File

@ -2377,12 +2377,12 @@
VoxMediaVolumeIE, VoxMediaVolumeIE,
) )
from .vrt import ( from .vrt import (
VRTIE,
DagelijkseKostIE, DagelijkseKostIE,
KetnetIE, KetnetIE,
Radio1BeIE, Radio1BeIE,
VrtNUIE, VRTIE,
VRTMaxRadioIE, VRTMaxRadioIE,
VrtNUIE,
) )
from .vtm import VTMIE from .vtm import VTMIE
from .vtv import ( from .vtv import (

View File

@ -492,7 +492,7 @@ def _real_extract(self, url):
class VRTMaxRadioIE(VRTBaseIE): class VRTMaxRadioIE(VRTBaseIE):
IE_DESC = 'VRT MAX (radio)' IE_DESC = 'VRT MAX (radio)'
_VALID_URL = r'https?://(?:www\.)?vrt\.be/(?:vrtmax|vrtnu)/luister/radio/(?P<show1l>[^/])/(?P<show>[^/]+)/(?P<id>[^/?#&]+)/?' _VALID_URL = r'https?://(?:www\.)?vrt\.be/(?:vrtmax|vrtnu)/luister/radio/(?P<show1l>[^/])/(?P<show>[^/]+)/(?P<episode_id>[^/?#&]+)/?'
_TESTS = [{ _TESTS = [{
'url': 'https://www.vrt.be/vrtmax/luister/radio/d/duyster~11-177/duyster~11-27934-0/', 'url': 'https://www.vrt.be/vrtmax/luister/radio/d/duyster~11-177/duyster~11-27934-0/',
'md5': '14d002b1ebd8591ae360ff54a9b51515', # ... of first Fragment. 'md5': '14d002b1ebd8591ae360ff54a9b51515', # ... of first Fragment.
@ -564,17 +564,17 @@ class VRTMaxRadioIE(VRTBaseIE):
} }
}''' }'''
def get_metadata(self, show1l, show, id): def get_metadata(self, show1l, show, episode_id):
# Rather fragile, download responds with nothing but "400: Bad Request" if any # Rather fragile, download responds with nothing but "400: Bad Request" if any
# GraphQL part or header is out of place. Best to keep them minimal. # GraphQL part or header is out of place. Best to keep them minimal.
graphqlvar = f"/vrtnu/luister/radio/{show1l}/{show}/{id}/" graphqlvar = f'/vrtnu/luister/radio/{show1l}/{show}/{episode_id}/'
postdata = json.dumps({ postdata = json.dumps({
'query': self._GRAPHQUERY, 'query': self._GRAPHQUERY,
'variables': {"pageId": graphqlvar}, 'variables': {'pageId': graphqlvar},
}).encode() }).encode()
return self._download_json( return self._download_json(
'https://www.vrt.be/vrtnu-api/graphql/public/v1', id, 'https://www.vrt.be/vrtnu-api/graphql/public/v1', episode_id,
note="Downloading GraphQL metadata", data=postdata, note='Downloading GraphQL metadata', data=postdata,
headers={ headers={
'content-type': 'application/json', 'content-type': 'application/json',
'Accept': 'application/graphql+json, application/json', 'Accept': 'application/graphql+json, application/json',
@ -583,15 +583,15 @@ def get_metadata(self, show1l, show, id):
}) })
def _real_extract(self, url): def _real_extract(self, url):
(show1l, show, id) = self._match_valid_url(url).groups() (show1l, show, episode_id) = self._match_valid_url(url).groups()
metadata = self.get_metadata(show1l, show, id)['data']['page'] metadata = self.get_metadata(show1l, show, episode_id)['data']['page']
audio_id = traverse_obj(metadata, ('player', 'listenAction', 'streamId')) audio_id = traverse_obj(metadata, ('player', 'listenAction', 'streamId'))
media_items = self._call_api(audio_id, 'vrtnu-web@PROD', version='v2') media_items = self._call_api(audio_id, 'vrtnu-web@PROD', version='v2')
formats, _ = self._extract_formats_and_subtitles(media_items, audio_id) formats, _ = self._extract_formats_and_subtitles(media_items, audio_id)
return { return {
'id': id, 'id': episode_id,
'formats': formats, 'formats': formats,
**traverse_obj(metadata, { **traverse_obj(metadata, {
'title': 'title', 'title': 'title',
@ -607,5 +607,5 @@ def _real_extract(self, url):
'channel_url': ('radioEpisode', 'actionItems', ..., 'action', all, 'channel_url': ('radioEpisode', 'actionItems', ..., 'action', all,
lambda _, act: act.get('linkType') == 'channel', any, lambda _, act: act.get('linkType') == 'channel', any,
'link', {lambda link: 'https://www.vrt.be' + link}), 'link', {lambda link: 'https://www.vrt.be' + link}),
}) }),
} }