diff --git a/module/song_url_redit.js b/module/song_url_redit.js new file mode 100644 index 00000000000..b8ac5269614 --- /dev/null +++ b/module/song_url_redit.js @@ -0,0 +1,51 @@ +const request = require('request') // 或者 const axios = require('axios') + +module.exports = async (query, request) => { + query.cookie.os = 'android' + query.cookie.appver = '8.10.05' + const data = { + ids: '[' + query.id + ']', + level: query.level, + encodeType: 'flac', + } + if (data.level == 'sky') { + data.immerseType = 'c51' + } + + // 发送POST请求 + const response = await request( + 'POST', + `https://interface.music.163.com/eapi/song/enhance/player/url/v1`, + data, + { + crypto: 'eapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + url: '/api/song/enhance/player/url/v1', + }, + ) + + // 从响应中获取URL + const url = response.data[0].url + + // 使用request库进行重定向 + const redirectResponse = await new Promise((resolve, reject) => { + request(url, (error, redirectResponse) => { + if (error) { + reject(error) + } else { + resolve(redirectResponse) + } + }) + }) + + // 获取最终重定向后的URL + const redirectedUrl = redirectResponse.request.uri.href + + // 将重定向后的URL添加到原始数据中 + response.data[0].redirectedUrl = redirectedUrl + + // 返回修改后的响应数据 + return response +} diff --git a/package-lock.json b/package-lock.json index d41d181ceea..a0abca5d924 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "NeteaseCloudMusicApi", - "version": "4.13.8", + "version": "4.14.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "NeteaseCloudMusicApi", - "version": "4.13.8", + "version": "4.14.0", "license": "MIT", "dependencies": { "axios": "^1.2.2",