mirror of
https://github.com/NeteaseCloudMusicApiEnhanced/api-enhanced.git
synced 2026-10-20 22:51:23 +08:00
fix: 修正NMTID来源
This commit is contained in:
+20
-5
@@ -68,6 +68,8 @@ const WNMCID = (function () {
|
|||||||
return `${randomString}.${now().toString()}.01.0`
|
return `${randomString}.${now().toString()}.01.0`
|
||||||
})()
|
})()
|
||||||
|
|
||||||
|
let NMTID = ''
|
||||||
|
|
||||||
// 预先定义osMap
|
// 预先定义osMap
|
||||||
const osMap = {
|
const osMap = {
|
||||||
pc: {
|
pc: {
|
||||||
@@ -155,8 +157,8 @@ const processCookieObject = (cookie, uri) => {
|
|||||||
appver: cookie.appver || os.appver,
|
appver: cookie.appver || os.appver,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uri.indexOf('login') === -1) {
|
if (NMTID) {
|
||||||
processedCookie['NMTID'] = CryptoJS.lib.WordArray.random(16).toString()
|
processedCookie['NMTID'] = NMTID
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!processedCookie.MUSIC_U) {
|
if (!processedCookie.MUSIC_U) {
|
||||||
@@ -420,9 +422,22 @@ const createRequest = async (uri, data, options) => {
|
|||||||
axios(settings)
|
axios(settings)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const body = res.data
|
const body = res.data
|
||||||
answer.cookie = (res.headers['set-cookie'] || []).map((x) =>
|
const setCookies = res.headers['set-cookie'] || []
|
||||||
x.replace(/\s*Domain=[^(;|$)]+;*/, ''),
|
|
||||||
)
|
const cleanCookie = (x) => x.replace(/\s*Domain=[^(;|$)]+;*/, '')
|
||||||
|
|
||||||
|
if (crypto == 'eapi' && !NMTID) {
|
||||||
|
answer.cookie = setCookies.map((x) => {
|
||||||
|
const cleaned = cleanCookie(x)
|
||||||
|
const match = x.match(/NMTID=([^;]+)/)
|
||||||
|
if (match) {
|
||||||
|
NMTID = match[1]
|
||||||
|
}
|
||||||
|
return cleaned
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
answer.cookie = setCookies.map(cleanCookie)
|
||||||
|
}
|
||||||
|
|
||||||
// debug: 统一注释块,需要时取消注释查看请求/返回的原始密文
|
// debug: 统一注释块,需要时取消注释查看请求/返回的原始密文
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user