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

Commit 6976e7f

Browse files
committed
优化酷狗接口写法
1 parent dfe3704 commit 6976e7f

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

core/music.php

+15-7
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,15 @@ function mc_song_urls($value, $type = 'query', $site = 'netease', $page = 1)
123123
],
124124
'kugou' => [
125125
'method' => 'GET',
126-
'url' => 'http://songsearch.kugou.com/song_search_v2',
127-
'referer' => 'http://www.kugou.com',
126+
'url' => MC_INTERNAL ?
127+
'http://songsearch.kugou.com/song_search_v2' :
128+
'http://mobilecdn.kugou.com/api/v3/search/song',
129+
'referer' => MC_INTERNAL ? 'http://www.kugou.com' : 'http://m.kugou.com',
128130
'proxy' => false,
129131
'body' => [
130132
'keyword' => $query,
131133
'platform' => 'WebFilter',
134+
'format' => 'json',
132135
'page' => $page,
133136
'pagesize' => 10
134137
]
@@ -537,13 +540,18 @@ function mc_get_song_by_name($query, $site = 'netease', $page = 1)
537540
break;
538541
case 'kugou':
539542
$radio_data = json_decode($radio_result, true);
540-
if (empty($radio_data['data']) || empty($radio_data['data']['lists'])) {
543+
$key = MC_INTERNAL ? 'lists' : 'info';
544+
if (empty($radio_data['data']) || empty($radio_data['data'][$key])) {
541545
return;
542546
}
543-
foreach ($radio_data['data']['lists'] as $val) {
544-
$hash = $val['SQFileHash'];
545-
if (!str_replace('0', '', $hash)) {
546-
$hash = $val['FileHash'];
547+
foreach ($radio_data['data'][$key] as $val) {
548+
if (MC_INTERNAL) {
549+
$hash = $val['SQFileHash'];
550+
if (!str_replace('0', '', $hash)) {
551+
$hash = $val['FileHash'];
552+
}
553+
} else {
554+
$hash = $val['320hash'] ?: $val['hash'];
547555
}
548556
$radio_songid[] = $hash;
549557
}

0 commit comments

Comments
 (0)