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

Commit

Permalink
v1.4.5 修复网易云音乐音频数据不对应问题
Browse files Browse the repository at this point in the history
  • Loading branch information
maicong committed Dec 5, 2017
1 parent ce04b16 commit b24b746
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 24 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -40,6 +40,7 @@

## Changelog / 更新日志

- 2017.12.05 `v1.4.5` 修复网易云音乐音频数据不对应问题
- 2017.12.05 `v1.4.4` 优化网易云音乐、虾米音乐、百度音乐接口
- 2017.12.05 `v1.4.3` 优化酷狗音乐接口,支持 320k 音频
- 2017.12.04 `v1.4.2` 优化代码
Expand Down
46 changes: 24 additions & 22 deletions core/music.php
Expand Up @@ -5,7 +5,7 @@
*
* @author MaiCong <i@maicong.me>
* @link https://github.com/maicong/music
* @since 1.4.4
* @since 1.4.5
*
*/

Expand Down Expand Up @@ -888,43 +888,45 @@ function mc_get_song_by_id($songid, $site = 'netease', $multi = false)
break;
case 'netease':
default:
$radio_streams = array(
'method' => 'POST',
'url' => 'http://music.163.com/api/linux/forward',
'referer' => 'http://music.163.com/',
'proxy' => false,
'body' => encode_netease_data(array(
'method' => 'POST',
'url' => 'http://music.163.com/api/song/enhance/player/url',
'params' => array(
'ids' => $songid,
'br' => 320000,
)
))
);
$radio_info = json_decode(mc_curl($radio_streams), true);
$radio_urls = array();
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'];
if (!empty($radio_data)) {
$radio_streams = array(
'method' => 'POST',
'url' => 'http://music.163.com/api/linux/forward',
'referer' => 'http://music.163.com/',
'proxy' => false,
'body' => encode_netease_data(array(
'method' => 'POST',
'url' => 'http://music.163.com/api/song/enhance/player/url',
'params' => array(
'ids' => $songid,
'br' => 320000,
)
))
);
$radio_info = json_decode(mc_curl($radio_streams), true);
foreach ($radio_data as $key => $value) {
foreach ($radio_data as $value) {
$radio_song_id = $value['id'];
$radio_authors = array();
foreach ($value['artists'] as $key => $val) {
$radio_authors[] = $val['name'];
}
$radio_author = implode('/', $radio_authors);
$radio_music_url = $value['mp3Url'];
if (!$radio_music_url && !empty($radio_info['data'])) {
$radio_music_url = $radio_info['data'][$key]['url'];
}
$radio_songs[] = array(
'type' => 'netease',
'link' => 'http://music.163.com/#/song?id=' . $radio_song_id,
'songid' => $radio_song_id,
'name' => urldecode($value['name']),
'author' => urldecode($radio_author),
'music' => $radio_music_url,
'music' => $radio_urls[$radio_song_id],
'pic' => $value['album']['picUrl'] . '?param=300x300'
);
}
Expand Down
4 changes: 2 additions & 2 deletions index.php
Expand Up @@ -5,15 +5,15 @@
*
* @author MaiCong <i@maicong.me>
* @link https://github.com/maicong/music
* @since 1.4.4
* @since 1.4.5
*
*/

// 定义核心
define('MC_CORE', true);

// 定义版本
define('MC_VERSION', '1.4.4');
define('MC_VERSION', '1.4.5');

// 核心文件目录
define('MC_CORE_DIR', __DIR__ . '/core');
Expand Down

0 comments on commit b24b746

Please sign in to comment.