From 76d8e662f76b1fc1af1453a10ec6cd237a98e113 Mon Sep 17 00:00:00 2001 From: IamFurina Date: Fri, 4 Jul 2025 19:06:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81GD=E5=8F=B0=E9=9F=B3?= =?UTF-8?q?=E4=B9=90=E7=9A=84=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 3 +++ README.MD | 2 +- module/song_url_match.js | 30 +++++++++++++++++++++ module/song_url_ncmget.js | 57 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 module/song_url_match.js create mode 100644 module/song_url_ncmget.js diff --git a/.env b/.env index fa3ec75..ad23f2b 100644 --- a/.env +++ b/.env @@ -1,3 +1,6 @@ +# CORS资源共享设置 +CORS_ALLOW_ORIGIN = "*" + ### UnblockNeteaseMusic 设置项 ## 歌曲启用无损音质 ENABLE_FLAC = true diff --git a/README.MD b/README.MD index 79c6bdd..fd81096 100644 --- a/README.MD +++ b/README.MD @@ -35,7 +35,7 @@ set PORT=4000 && node app.js # Windows ### 重要提示 - 调用前请务必阅读文档的“调用前须知”部分。 -- 推荐将敏感信息(如 cookie)通过环境变量或 .env 文件配置。 +- 推荐将敏感信息(如 cookie)通过部署平台的环境变量进行配置。 ## 在线体验与文档 diff --git a/module/song_url_match.js b/module/song_url_match.js new file mode 100644 index 0000000..6ef964f --- /dev/null +++ b/module/song_url_match.js @@ -0,0 +1,30 @@ +// 网易云歌曲解灰(适配SPlayer的UNM-Server) +// 支持qq音乐、酷狗音乐、酷我音乐、咪咕音乐、第三方网易云API等等(来自GD音乐台) + +const createOption = require('../util/option.js') + + +module.exports = async (query, request) => { + try { + const match = require("@unblockneteasemusic/server") + const source = ['pyncmd', 'kuwo', 'qq', 'migu', 'kugou'] + const result = await match(query.id, source) + console.log("[OK] 开始解灰", query.id, result) + return { + status: 200, + body: { + code: 200, + data: Array.isArray(result) ? result : [result], + }, + } + } catch (e) { + return { + status: 500, + body: { + code: 500, + msg: e.message || 'unblock error', + data: [], + }, + } + } +} \ No newline at end of file diff --git a/module/song_url_ncmget.js b/module/song_url_ncmget.js new file mode 100644 index 0000000..df39605 --- /dev/null +++ b/module/song_url_ncmget.js @@ -0,0 +1,57 @@ +// GD音乐台get(适配SPlayer的UNM-Server) +// 感谢来自GD Studio的开发API +// https://music.gdstudio.xyz/ + +const createOption = require('../util/option.js') + +module.exports = async (query, request) => { + try { + const { id, br } = query + if (!id) { + return { + status: 400, + body: { + code: 400, + msg: 'Missing song ID', + data: [], + }, + } + } + const vaildbr = ["128", "192", "320", "740", "999"] + if (br && !vaildbr.includes(br)) { + return { + status: 400, + body: { + code: 400, + msg: 'Invalid bitrate', + data: [], + }, + } + } + const apiUrl = new URL("https://music.gdstudio.xyz/api.php") + apiUrl.searchParams.append("types", "url"); + apiUrl.searchParams.append("id", id); + apiUrl.searchParams.append("br", br || "320"); + + const response = await fetch(apiUrl.toString()); + if (!response.ok) throw new Error(`API 响应状态: ${response.status}`); + const result = await response.json(); + return { + status: 200, + body: { + code: 200, + msg: 'Success', + data: result.data || [], + }, + } + } catch (err) { + return { + status: 500, + body: { + code: 500, + msg: err.message || 'Internal Server Error', + data: [], + }, + } + } +}