Skip to content
This repository has been archived by the owner on Jun 25, 2019. It is now read-only.

Commit

Permalink
优化网易云音乐接口
Browse files Browse the repository at this point in the history
  • Loading branch information
maicong committed May 24, 2018
1 parent ae55fa3 commit 31dd330
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion core/music.php
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,29 @@ function mc_get_song_by_id($songid, $site = 'netease', $multi = false)
break;
case 'netease':
default:
if (MC_INTERNAL) {
$radio_streams = [
'method' => 'POST',
'url' => 'http://music.163.com/api/linux/forward',
'referer' => 'http://music.163.com/',
'proxy' => false,
'body' => encode_netease_data([
'method' => 'POST',
'url' => 'http://music.163.com/api/song/enhance/player/url',
'params' => [
'ids' => is_array($songid) ? $songid : [$songid],
'br' => 320000,
]
])
];
$radio_info = json_decode(mc_curl($radio_streams), true);
$radio_urls = [];
if (!empty($radio_info['data'])) {
foreach ($radio_info['data'] as $val) {
$radio_urls[$val['id']] = $val['url'];
}
}
}
foreach ($radio_result as $val) {
$radio_json = json_decode($val, true);
$radio_data = $radio_json['songs'];
Expand All @@ -1081,7 +1104,7 @@ function mc_get_song_by_id($songid, $site = 'netease', $multi = false)
'title' => $value['name'],
'author' => $radio_author,
'lrc' => !empty($radio_lrc['lrc']) ? $radio_lrc['lrc']['lyric'] : '',
'url' => 'http://music.163.com/song/media/outer/url?id=' . $radio_song_id . '.mp3',
'url' => MC_INTERNAL ? $radio_urls[$radio_song_id] : 'http://music.163.com/song/media/outer/url?id=' . $radio_song_id . '.mp3',
'pic' => $value['album']['picUrl'] . '?param=300x300'
];
}
Expand Down

0 comments on commit 31dd330

Please sign in to comment.