From 873ffa2aca1585448010a330a1c2cc12d3ff3c38 Mon Sep 17 00:00:00 2001 From: HMXHKAKA <97349507+Dreamkaka@users.noreply.github.com> Date: Fri, 2 Feb 2024 22:09:48 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E5=AE=9A=E5=90=91=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=B0=9D=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 因为nodejs版本太高本地无法测试 --- module/song_url_redit.js | 51 ++++++++++++++++++++++++++++++++++++++++ package-lock.json | 4 ++-- 2 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 module/song_url_redit.js 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",