Update neteasemusic.py

This commit is contained in:
c-basalt 2024-09-19 19:21:43 -04:00 committed by GitHub
parent e9905f92ec
commit ceac9f669d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -79,7 +79,8 @@ def _download_eapi_json(self, path, video_id, query_body, headers={}, **kwargs):
def _call_player_api(self, song_id, level, headers={}): def _call_player_api(self, song_id, level, headers={}):
return self._download_eapi_json( return self._download_eapi_json(
'/song/enhance/player/url/v1', song_id, '/song/enhance/player/url/v1', song_id,
{'ids': f'[{song_id}]', 'level': level, 'encodeType': 'flac'}, headers=headers, note=f'Downloading song URL info: level {level}') {'ids': f'[{song_id}]', 'level': level, 'encodeType': 'flac'},
headers=headers, note=f'Downloading song URL info: level {level}')
def _extract_formats(self, info, try_geo_bypass=False): def _extract_formats(self, info, try_geo_bypass=False):
formats = [] formats = []
@ -88,10 +89,10 @@ def _extract_formats(self, info, try_geo_bypass=False):
for level in self._LEVELS: for level in self._LEVELS:
song = traverse_obj( song = traverse_obj(
self._call_player_api(song_id, level, headers=headers), ('data', lambda _, v: url_or_none(v['url']), any)) self._call_player_api(song_id, level, headers=headers), ('data', lambda _, v: url_or_none(v['url']), any))
if not song: if not song: # Media is not available due to removal or geo-restriction
if not try_geo_bypass: if not try_geo_bypass:
return self._extract_formats(info, try_geo_bypass=True) return self._extract_formats(info, try_geo_bypass=True)
break # Media is not available due to removal or geo-restriction break
actual_level = song.get('level') actual_level = song.get('level')
if actual_level and actual_level != level: if actual_level and actual_level != level:
if level in ('lossless', 'jymaster'): if level in ('lossless', 'jymaster'):