mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-07-03 02:35:28 +02:00
Merge ed82d270d7
into f3411af12e
This commit is contained in:
commit
f82613b329
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
class NetEaseMusicBaseIE(InfoExtractor):
|
class NetEaseMusicBaseIE(InfoExtractor):
|
||||||
_FORMATS = ['bMusic', 'mMusic', 'hMusic']
|
_LEVELS = ['standard', 'exhigh', 'lossless', 'hires', 'jyeffect', 'sky', 'jymaster']
|
||||||
_API_BASE = 'http://music.163.com/api/'
|
_API_BASE = 'http://music.163.com/api/'
|
||||||
_GEO_BYPASS = False
|
_GEO_BYPASS = False
|
||||||
|
|
||||||
|
@ -66,27 +66,23 @@ def _download_eapi_json(self, path, video_id, query_body, headers={}, **kwargs):
|
||||||
**headers,
|
**headers,
|
||||||
}, **kwargs)
|
}, **kwargs)
|
||||||
|
|
||||||
def _call_player_api(self, song_id, bitrate):
|
def _call_player_api(self, song_id, level):
|
||||||
return self._download_eapi_json(
|
return self._download_eapi_json(
|
||||||
'/song/enhance/player/url', song_id, {'ids': f'[{song_id}]', 'br': bitrate},
|
'/song/enhance/player/url/v1', song_id, {'ids': f'[{song_id}]', 'level': level, 'encodeType': 'flac'},
|
||||||
note=f'Downloading song URL info: bitrate {bitrate}')
|
note=f'Downloading song URL info: level {level}')
|
||||||
|
|
||||||
def extract_formats(self, info):
|
def extract_formats(self, info):
|
||||||
err = 0
|
err = 0
|
||||||
formats = []
|
formats = []
|
||||||
song_id = info['id']
|
song_id = info['id']
|
||||||
for song_format in self._FORMATS:
|
for song_level in self._LEVELS:
|
||||||
details = info.get(song_format)
|
for song in traverse_obj(self._call_player_api(song_id, song_level), ('data', lambda _, v: url_or_none(v['url']))):
|
||||||
if not details:
|
|
||||||
continue
|
|
||||||
bitrate = int_or_none(details.get('bitrate')) or 999000
|
|
||||||
for song in traverse_obj(self._call_player_api(song_id, bitrate), ('data', lambda _, v: url_or_none(v['url']))):
|
|
||||||
song_url = song['url']
|
song_url = song['url']
|
||||||
if self._is_valid_url(song_url, info['id'], 'song'):
|
if self._is_valid_url(song_url, info['id'], 'song'):
|
||||||
formats.append({
|
formats.append({
|
||||||
'url': song_url,
|
'url': song_url,
|
||||||
'format_id': song_format,
|
'format_id': song_level,
|
||||||
'asr': traverse_obj(details, ('sr', {int_or_none})),
|
'vcodec': 'none',
|
||||||
**traverse_obj(song, {
|
**traverse_obj(song, {
|
||||||
'ext': ('type', {str}),
|
'ext': ('type', {str}),
|
||||||
'abr': ('br', {self.kilo_or_none}),
|
'abr': ('br', {self.kilo_or_none}),
|
||||||
|
@ -146,8 +142,8 @@ class NetEaseMusicIE(NetEaseMusicBaseIE):
|
||||||
'average_rating': int,
|
'average_rating': int,
|
||||||
'album_artist': '偶像练习生',
|
'album_artist': '偶像练习生',
|
||||||
},
|
},
|
||||||
|
'skip': 'No longer available',
|
||||||
}, {
|
}, {
|
||||||
'note': 'No lyrics.',
|
|
||||||
'url': 'http://music.163.com/song?id=17241424',
|
'url': 'http://music.163.com/song?id=17241424',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '17241424',
|
'id': '17241424',
|
||||||
|
@ -161,10 +157,14 @@ class NetEaseMusicIE(NetEaseMusicBaseIE):
|
||||||
'album': 'Piano Solos Vol. 2',
|
'album': 'Piano Solos Vol. 2',
|
||||||
'album_artist': 'Dustin O\'Halloran',
|
'album_artist': 'Dustin O\'Halloran',
|
||||||
'average_rating': int,
|
'average_rating': int,
|
||||||
|
'description': '[00:05.00]纯音乐,请欣赏\n',
|
||||||
|
'album_artists': ['Dustin O\'Halloran'],
|
||||||
|
'creators': ['Dustin O\'Halloran'],
|
||||||
|
'subtitles': {'lyrics': [{'ext': 'lrc'}]},
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://y.music.163.com/m/song?app_version=8.8.45&id=95670&uct2=sKnvS4+0YStsWkqsPhFijw%3D%3D&dlt=0846',
|
'url': 'https://y.music.163.com/m/song?app_version=8.8.45&id=95670&uct2=sKnvS4+0YStsWkqsPhFijw%3D%3D&dlt=0846',
|
||||||
'md5': '95826c73ea50b1c288b22180ec9e754d',
|
'md5': 'b896be78d8d34bd7bb665b26710913ff',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '95670',
|
'id': '95670',
|
||||||
'ext': 'mp3',
|
'ext': 'mp3',
|
||||||
|
@ -180,6 +180,8 @@ class NetEaseMusicIE(NetEaseMusicBaseIE):
|
||||||
'average_rating': int,
|
'average_rating': int,
|
||||||
'album': '红色摇滚',
|
'album': '红色摇滚',
|
||||||
'album_artist': '侯牧人',
|
'album_artist': '侯牧人',
|
||||||
|
'creators': ['马备'],
|
||||||
|
'album_artists': ['侯牧人'],
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
'url': 'http://music.163.com/#/song?id=32102397',
|
'url': 'http://music.163.com/#/song?id=32102397',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user