Compare commits

...

2 Commits

Author SHA1 Message Date
bashonly
68c8d0bb72
cosmetic 2024-01-19 07:17:02 +00:00
bashonly
d64f7c88df
Apply suggestions from code review 2024-01-19 07:16:21 +00:00
2 changed files with 8 additions and 4 deletions

View File

@ -1889,7 +1889,7 @@ The following extractors use this feature:
* `type`: Type(s) of game replays to extract. Valid types are: `full_game`, `full_game_spanish`, `condensed_game` and `all_22`. You can use `all` to extract all available replay types, which is the default * `type`: Type(s) of game replays to extract. Valid types are: `full_game`, `full_game_spanish`, `condensed_game` and `all_22`. You can use `all` to extract all available replay types, which is the default
#### jiosaavn #### jiosaavn
* `bitrate`: Which bitrates to request. Valid options are `16`, `32`, `64`, `128`, and `320` or a comma-separated list of these values. Defaults to `128,320`. * `bitrate`: Audio bitrates to request. One or more of `16`, `32`, `64`, `128`, `320`. Default is `128,320`
**Note**: These options may be changed/removed in the future without concern for backward compatibility **Note**: These options may be changed/removed in the future without concern for backward compatibility

View File

@ -37,12 +37,15 @@ class JioSaavnSongIE(JioSaavnBaseIE):
'only_matching': True, 'only_matching': True,
}] }]
_VALID_BITRATES = ('16', '32', '64', '128', '320')
def _real_extract(self, url): def _real_extract(self, url):
audio_id = self._match_id(url) audio_id = self._match_id(url)
extract_bitrates = self._configuration_arg('bitrate', ['128', '320'], ie_key='JioSaavn') extract_bitrates = self._configuration_arg('bitrate', ['128', '320'], ie_key='JioSaavn')
if not all(bitrate in ('16', '32', '64', '128', '320') for bitrate in extract_bitrates): if invalid_bitrates := [br for br in extract_bitrates if br not in self._VALID_BITRATES]:
raise ValueError(f'Invalid bitrate(s) {extract_bitrates}') raise ValueError(
f'Invalid bitrate(s): {", ".join(invalid_bitrates)}. '
+ f'Valid bitrates are: {", ".join(self._VALID_BITRATES)}')
song_data = self._extract_initial_data(url, audio_id)['song']['song'] song_data = self._extract_initial_data(url, audio_id)['song']['song']
formats = [] formats = []
@ -65,6 +68,7 @@ class JioSaavnSongIE(JioSaavnBaseIE):
'abr': int(bitrate), 'abr': int(bitrate),
'vcodec': 'none', 'vcodec': 'none',
}) })
return { return {
'id': audio_id, 'id': audio_id,
'formats': formats, 'formats': formats,