mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2025-01-04 15:02:13 +00:00
Compare commits
No commits in common. "ce5d36486ea95b8961c639d118bad262c8d7a067" and "502cefa41f1d24057b6158748b2072dc911af682" have entirely different histories.
ce5d36486e
...
502cefa41f
@ -20,7 +20,6 @@ from ..compat import (
|
|||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
bytes_to_intlist,
|
bytes_to_intlist,
|
||||||
error_to_compat_str,
|
|
||||||
float_or_none,
|
float_or_none,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
intlist_to_bytes,
|
intlist_to_bytes,
|
||||||
@ -95,23 +94,17 @@ class NetEaseMusicBaseIE(InfoExtractor):
|
|||||||
url = 'https://interface3.music.163.com/eapi/song/enhance/player/url'
|
url = 'https://interface3.music.163.com/eapi/song/enhance/player/url'
|
||||||
data, headers = self.make_player_api_request_data_and_headers(song_id, bitrate)
|
data, headers = self.make_player_api_request_data_and_headers(song_id, bitrate)
|
||||||
try:
|
try:
|
||||||
msg = 'empty result'
|
return self._download_json(
|
||||||
result = self._download_json(
|
|
||||||
url, song_id, data=data.encode('ascii'), headers=headers)
|
url, song_id, data=data.encode('ascii'), headers=headers)
|
||||||
if result:
|
|
||||||
return result
|
|
||||||
except ExtractorError as e:
|
except ExtractorError as e:
|
||||||
if type(e.cause) in (ValueError, TypeError):
|
if type(e.cause) in (ValueError, TypeError):
|
||||||
# JSON load failure
|
# JSON load failure
|
||||||
raise
|
raise
|
||||||
except Exception as e:
|
except Exception:
|
||||||
msg = error_to_compat_str(e)
|
pass
|
||||||
self.report_warning('%s API call (%s) failed: %s' % (
|
|
||||||
song_id, bitrate, msg))
|
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
def extract_formats(self, info):
|
def extract_formats(self, info):
|
||||||
err = 0
|
|
||||||
formats = []
|
formats = []
|
||||||
song_id = info['id']
|
song_id = info['id']
|
||||||
for song_format in self._FORMATS:
|
for song_format in self._FORMATS:
|
||||||
@ -123,8 +116,6 @@ class NetEaseMusicBaseIE(InfoExtractor):
|
|||||||
data = self._call_player_api(song_id, bitrate)
|
data = self._call_player_api(song_id, bitrate)
|
||||||
for song in try_get(data, lambda x: x['data'], list) or []:
|
for song in try_get(data, lambda x: x['data'], list) or []:
|
||||||
song_url = try_get(song, lambda x: x['url'])
|
song_url = try_get(song, lambda x: x['url'])
|
||||||
if not song_url:
|
|
||||||
continue
|
|
||||||
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,
|
||||||
@ -134,19 +125,6 @@ class NetEaseMusicBaseIE(InfoExtractor):
|
|||||||
'filesize': int_or_none(song.get('size')),
|
'filesize': int_or_none(song.get('size')),
|
||||||
'asr': int_or_none(details.get('sr')),
|
'asr': int_or_none(details.get('sr')),
|
||||||
})
|
})
|
||||||
elif err == 0:
|
|
||||||
err = try_get(song, lambda x: x['code'], int)
|
|
||||||
|
|
||||||
if not formats:
|
|
||||||
msg = 'No media links found'
|
|
||||||
if err != 0 and (err < 200 or err >= 400):
|
|
||||||
raise ExtractorError(
|
|
||||||
'%s (site code %d)' % (msg, err, ), expected=True)
|
|
||||||
else:
|
|
||||||
self.raise_geo_restricted(
|
|
||||||
msg + ': probably this video is not available from your location due to geo restriction.',
|
|
||||||
countries=['CN'])
|
|
||||||
|
|
||||||
return formats
|
return formats
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -162,7 +140,7 @@ class NetEaseMusicBaseIE(InfoExtractor):
|
|||||||
class NetEaseMusicIE(NetEaseMusicBaseIE):
|
class NetEaseMusicIE(NetEaseMusicBaseIE):
|
||||||
IE_NAME = 'netease:song'
|
IE_NAME = 'netease:song'
|
||||||
IE_DESC = '网易云音乐'
|
IE_DESC = '网易云音乐'
|
||||||
_VALID_URL = r'https?://(y\.)?music\.163\.com/(?:[#m]/)?song\?.*?\bid=(?P<id>[0-9]+)'
|
_VALID_URL = r'https?://music\.163\.com/(#/)?song\?id=(?P<id>[0-9]+)'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'http://music.163.com/#/song?id=32102397',
|
'url': 'http://music.163.com/#/song?id=32102397',
|
||||||
'md5': '3e909614ce09b1ccef4a3eb205441190',
|
'md5': '3e909614ce09b1ccef4a3eb205441190',
|
||||||
@ -200,18 +178,6 @@ class NetEaseMusicIE(NetEaseMusicBaseIE):
|
|||||||
'timestamp': 1264608000,
|
'timestamp': 1264608000,
|
||||||
'alt_title': '说出愿望吧(Genie)',
|
'alt_title': '说出愿望吧(Genie)',
|
||||||
},
|
},
|
||||||
}, {
|
|
||||||
'url': 'https://y.music.163.com/m/song?app_version=8.8.45&id=95670&uct2=sKnvS4+0YStsWkqsPhFijw%3D%3D&dlt=0846',
|
|
||||||
'md5': '95826c73ea50b1c288b22180ec9e754d',
|
|
||||||
'info_dict': {
|
|
||||||
'id': '95670',
|
|
||||||
'ext': 'mp3',
|
|
||||||
'title': '国际歌',
|
|
||||||
'creator': '马备',
|
|
||||||
'upload_date': '19911130',
|
|
||||||
'timestamp': 691516800,
|
|
||||||
'description': 'md5:1ba2f911a2b0aa398479f595224f2141',
|
|
||||||
},
|
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _process_lyrics(self, lyrics_info):
|
def _process_lyrics(self, lyrics_info):
|
||||||
|
Loading…
Reference in New Issue
Block a user