2023年4月22日18:19:21
parent
bbf87a33ad
commit
492ef987b1
|
|
@ -35,6 +35,7 @@ import org.springframework.http.HttpMethod;
|
|||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import javax.script.ScriptEngineManager;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
|
@ -150,8 +151,8 @@ public class MusicDownloadController {
|
|||
}
|
||||
|
||||
public ObservableList<SongInfo> get_ku_gou_info(String title){
|
||||
ScriptEngineManager manager = new ScriptEngineManager();
|
||||
|
||||
URL.createObjectURL(new Blob());
|
||||
|
||||
String api = "https://songsearch.kugou.com/song_search_v2";
|
||||
ObservableList<SongInfo> list = FXCollections.observableArrayList();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,137 @@
|
|||
/* eslint-disable consistent-return */
|
||||
/* eslint-disable no-unused-vars */
|
||||
/* eslint-disable no-use-before-define */
|
||||
/* global getParameterByName cookieRemove async forge */
|
||||
class migu {
|
||||
|
||||
static search(url) {
|
||||
const keyword = getParameterByName('keywords', url);
|
||||
const curpage = getParameterByName('curpage', url);
|
||||
const searchType = getParameterByName('type', url);
|
||||
const sid = (this.uuid() + this.uuid()).replace(/-/g, '');
|
||||
// let type ='';
|
||||
let searchSwitch = '';
|
||||
let target_url =
|
||||
'https://jadeite.migu.cn/music_search/v2/search/searchAll?';
|
||||
switch (searchType) {
|
||||
case '0':
|
||||
searchSwitch = '{"song":1}'; // {"song":1,"album":0,"singer":0,"tagSong":1,"mvSong":0,"bestShow":1,"songlist":0,"lyricSong":0}
|
||||
// type = 2;
|
||||
target_url =
|
||||
`${target_url}sid=${sid}&isCorrect=1&isCopyright=1` +
|
||||
`&searchSwitch=${encodeURIComponent(searchSwitch)}&pageSize=20` +
|
||||
`&text=${encodeURIComponent(keyword)}&pageNo=${curpage}` +
|
||||
'&feature=1000000000&sort=1';
|
||||
break;
|
||||
case '1':
|
||||
searchSwitch = '{"songlist":1}';
|
||||
// type = 6;
|
||||
target_url =
|
||||
`${target_url}sid=${sid}&isCorrect=1&isCopyright=1` +
|
||||
`&searchSwitch=${encodeURIComponent(searchSwitch)}` +
|
||||
'&userFilter=%7B%22songlisttag%22%3A%5B%5D%7D&pageSize=20' +
|
||||
`&text=${encodeURIComponent(keyword)}&pageNo=${curpage}` +
|
||||
// + `&sort=1&userSort=%7B%22songlist%22%3A%22default%22%7D`;
|
||||
'&feature=0000000010&sort=1';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// const target_url = `https://pd.musicapp.migu.cn/MIGUM3.0/v1.0/content/search_all.do?&isCopyright=0&isCorrect=0&text=${keyword}&pageNo=${curpage}&searchSwitch=${searchSwitch}`;
|
||||
// const target_url = `https://m.music.migu.cn/migu/remoting/scr_search_tag?rows=20&type=${type}&keyword=${keyword}'&pgc=${curpage}`;
|
||||
|
||||
const deviceId = forge.md5
|
||||
.create()
|
||||
.update(this.uuid().replace(/-/g, ''))
|
||||
.digest()
|
||||
.toHex()
|
||||
.toLocaleUpperCase(); // 璁惧鐨刄UID
|
||||
const timestamp = new Date().getTime();
|
||||
const signature_md5 = '6cdc72a439cef99a3418d2a78aa28c73'; // app绛惧悕璇佷功鐨刴d5
|
||||
const text = `${
|
||||
keyword + signature_md5
|
||||
}yyapp2d16148780a1dcc7408e06336b98cfd50${deviceId}${timestamp}`;
|
||||
const sign = forge.md5
|
||||
.create(text)
|
||||
.update(forge.util.encodeUtf8(text))
|
||||
.digest()
|
||||
.toHex();
|
||||
const headers = {
|
||||
// android_id: 'db2cd8c4cdc1345f',
|
||||
appId: 'yyapp2',
|
||||
// brand: 'google',
|
||||
// channel: '0147151',
|
||||
deviceId,
|
||||
// HWID: '',
|
||||
// IMEI: '',
|
||||
// IMSI: '',
|
||||
// ip: '192.168.1.101',
|
||||
// mac: '02:00:00:00:00:00',
|
||||
// 'mgm-Network-standard': '01',
|
||||
// 'mgm-Network-type': '04',
|
||||
// mode: 'android',
|
||||
// msisdn: '',
|
||||
// OAID: '',
|
||||
// os: 'android 7.0',
|
||||
// osVersion: 'android 7.0',
|
||||
// platform: 'G011C',
|
||||
sign,
|
||||
timestamp,
|
||||
// ua: 'Android_migu',
|
||||
// uid: '',
|
||||
uiVersion: 'A_music_3.3.0',
|
||||
version: '7.0.4',
|
||||
};
|
||||
return {
|
||||
success: (fn) => {
|
||||
axios
|
||||
.get(target_url, {
|
||||
headers,
|
||||
})
|
||||
.then((response) => {
|
||||
const { data } = response;
|
||||
let result = [];
|
||||
let total = 0;
|
||||
if (searchType === '0') {
|
||||
if (data.songResultData.result) {
|
||||
result = data.songResultData.result.map((item) =>
|
||||
this.mg_convert_song(item)
|
||||
);
|
||||
total = data.songResultData.totalCount;
|
||||
}
|
||||
} else if (searchType === '1') {
|
||||
if (data.songListResultData.result) {
|
||||
result = data.songListResultData.result.map((item) => ({
|
||||
// result = data.songLists.map(item => ({
|
||||
id: `mgplaylist_${item.id}`,
|
||||
title: item.name,
|
||||
source: 'migu',
|
||||
source_url: `https://music.migu.cn/v3/music/playlist/${item.id}`,
|
||||
// img_url: item.img,
|
||||
img_url: item.musicListPicUrl,
|
||||
url: `mgplaylist_${item.id}`,
|
||||
author: item.userName,
|
||||
count: item.musicNum,
|
||||
}));
|
||||
total = data.songListResultData.totalCount;
|
||||
}
|
||||
}
|
||||
return fn({
|
||||
result,
|
||||
total,
|
||||
type: searchType,
|
||||
});
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// https://abhishekdutta.org/blog/standalone_uuid_generator_in_javascript.html
|
||||
static uuid() {
|
||||
const temp_url = URL.createObjectURL(new Blob());
|
||||
const strTemp = temp_url.toString();
|
||||
URL.revokeObjectURL(temp_url);
|
||||
return strTemp.substr(strTemp.lastIndexOf('/') + 1); // remove prefix (e.g. blob:null/, blob:www.test.com/, ...)
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue