mirror of
https://github.com/NeteaseCloudMusicApiEnhanced/api-enhanced.git
synced 2026-10-20 22:51:23 +08:00
fix: 听歌识曲接口和 demo 页面问题修复和更新
This commit is contained in:
+16
-24
@@ -1,26 +1,18 @@
|
||||
function createRandomString(len) {
|
||||
const str = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
let result = ''
|
||||
for (let i = len; i > 0; --i)
|
||||
result += str[Math.floor(Math.random() * str.length)]
|
||||
return result
|
||||
}
|
||||
module.exports = (query, request) => {
|
||||
query.cookie.os = 'pc'
|
||||
const data = {
|
||||
algorithmCode: 'shazam_v2',
|
||||
times: 1,
|
||||
sessionId: createRandomString(16),
|
||||
duration: Number(query.duration),
|
||||
from: 'recognize-song',
|
||||
decrypt: '1',
|
||||
rawdata: query.audioFP,
|
||||
}
|
||||
return request('POST', `https://music.163.com/api/music/audio/match`, data, {
|
||||
crypto: 'weapi',
|
||||
cookie: query.cookie,
|
||||
ua: query.ua || '',
|
||||
proxy: query.proxy,
|
||||
realIP: query.realIP,
|
||||
const { default: axios } = require('axios')
|
||||
|
||||
module.exports = async (query, request) => {
|
||||
const res = await axios({
|
||||
method: 'get',
|
||||
url: `https://interface.music.163.com/api/music/audio/match?sessionId=0123456789abcdef&algorithmCode=shazam_v2&duration=${
|
||||
query.duration
|
||||
}&rawdata=${encodeURIComponent(query.audioFP)}×=1&decrypt=1`,
|
||||
data: null,
|
||||
})
|
||||
return {
|
||||
status: 200,
|
||||
body: {
|
||||
code: 200,
|
||||
data: res.data.data,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user