Skip to content

Commit

Permalink
fix: kugou play problem
Browse files Browse the repository at this point in the history
  • Loading branch information
listen1 committed Apr 1, 2024
1 parent 73f7580 commit 5e46676
Showing 1 changed file with 41 additions and 44 deletions.
85 changes: 41 additions & 44 deletions js/provider/kugou.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,38 +66,40 @@ class kugou {
return {
success: (fn) => {
const target_url = `${'http://mobilecdnbj.kugou.com/api/v3/search/special?keyword='}${keyword}&pagesize=20&filter=0&page=${curpage}`;
axios.get(target_url)
.then((response) => {
const result = response.data.data.info.map((item) => ({
id: `kgplaylist_${item.specialid}`,
title: item.specialname,
source: 'kugou',
source_url: 'https://www.kugou.com/yy/special/single/{size}.html'.replace(
'{size}',
item.specialid
axios
.get(target_url)
.then((response) => {
const result = response.data.data.info.map((item) => ({
id: `kgplaylist_${item.specialid}`,
title: item.specialname,
source: 'kugou',
source_url:
'https://www.kugou.com/yy/special/single/{size}.html'.replace(
'{size}',
item.specialid
),
img_url: item.imgurl
? item.imgurl.replace('{size}', '400')
: '',
url: `kgplaylist_${item.specialid}`,
author: item.nickname,
count: item.songcount,
}));
const { total } = response.data.data;
return fn({
result,
total,
type: searchType,
});
}).catch(() => {
fn({
result: [],
total: 0,
type: searchType,
});
img_url: item.imgurl
? item.imgurl.replace('{size}', '400')
: '',
url: `kgplaylist_${item.specialid}`,
author: item.nickname,
count: item.songcount,
}));
const { total } = response.data.data;
return fn({
result,
total,
type: searchType,
});
})
}

.catch(() => {
fn({
result: [],
total: 0,
type: searchType,
});
});
},
};
}
return {
Expand Down Expand Up @@ -305,26 +307,21 @@ class kugou {

static bootstrap_track(track, success, failure) {
const track_id = track.id.slice('kgtrack_'.length);
const album_id = track.album_id.slice('kgalbum_'.length);
let target_url = `https://wwwapi.kugou.com/yy/index.php?r=play/getdata&callback=jQuery&mid=1&hash=${track_id}&platid=4`;
if (album_id !== '') {
target_url += `&album_id=${album_id}`;
}
const timstamp = +new Date();
target_url += `&_=${timstamp}`;

const target_url = `https://m.kugou.com/app/i/getSongInfo.php?cmd=playInfo&hash=${track_id}`;

axios.get(target_url).then((response) => {
const { data } = response;
const jsonString = data.slice('jQuery('.length, data.length - 1 - 1);
const info = JSON.parse(jsonString);
const { play_url } = info.data;
const { data: info } = response;

const { url } = info;

if (play_url === '') {
if (url === '') {
return failure({});
}

return success({
url: play_url,
bitrate: `${info.data.bitrate}kbps`,
url,
bitrate: `${info.bitRate}kbps`,
platform: 'kugou',
});
});
Expand Down

0 comments on commit 5e46676

Please sign in to comment.