diff --git a/utils/encrypt.js b/utils/encrypt.js index 93d529b..ea34dc8 100644 --- a/utils/encrypt.js +++ b/utils/encrypt.js @@ -27,11 +27,7 @@ async function store2ha1(passstore) { const parts = passstore.split("."); if (parts.length === 2) { // 新的加密方式 with IV: IV.E - const c = crypto.createDecipheriv( - "aes-256-cbc", - key, - Buffer.from(parts[0], "hex") - ); + const c = crypto.createDecipheriv("aes-256-cbc", key, Buffer.from(parts[0], "hex")); let d = c.update(parts[1], "hex", "binary"); d += c.final("binary"); return d; @@ -45,12 +41,9 @@ async function store2ha1(passstore) { } catch (e) { console.error( "在[default]部分设置的passwordSecret无法解密信息。请确保所有节点的passwordSecret相同。如果您更改了密码保密信息,可能需要重新添加用户。", - e + e, ); } } -export { - ha12store, - store2ha1 -} \ No newline at end of file +export { ha12store, store2ha1 }; diff --git a/utils/netease.js b/utils/netease.js index fb41e68..f1e91c5 100644 --- a/utils/netease.js +++ b/utils/netease.js @@ -2,7 +2,7 @@ import fetch from "node-fetch"; import axios from "axios"; -const BASE_URL = "http://cloud-music.pl-fe.cn" +const BASE_URL = "http://cloud-music.pl-fe.cn"; /** * 获取cookie @@ -11,7 +11,7 @@ const BASE_URL = "http://cloud-music.pl-fe.cn" */ async function getCookies(key) { const cookieUrl = `${BASE_URL}/login/qr/check?key=${key}×tamp=${Date.now()}`; - return fetch(cookieUrl).then(async (resp) => { + return fetch(cookieUrl).then(async resp => { return await resp.json(); }); } @@ -24,14 +24,13 @@ async function getCookies(key) { async function getLoginStatus(cookie) { return axios({ url: `${BASE_URL}/login/status?timestamp=${Date.now()}`, - method: 'post', + method: "post", data: { cookie, }, - }) - .then(resp => { - return resp.data.data - }); + }).then(resp => { + return resp.data.data; + }); } /** @@ -42,14 +41,13 @@ async function getLoginStatus(cookie) { async function getDailyRecommend(cookie) { return axios({ url: `${BASE_URL}/recommend/songs?timestamp=${Date.now()}`, - method: 'get', + method: "get", data: { cookie, }, - }) - .then(resp => { - return resp.data.data - }); + }).then(resp => { + return resp.data.data; + }); } /** @@ -58,7 +56,7 @@ async function getDailyRecommend(cookie) { */ async function getKey() { const keyUrl = `${BASE_URL}/login/qr/key?timestamp=${Date.now()}`; - return await fetch(keyUrl).then(async (resp) => { + return await fetch(keyUrl).then(async resp => { const respJson = await resp.json(); return respJson.data.unikey; }); @@ -71,7 +69,7 @@ async function getKey() { */ async function getQrCode(key) { const qrPicUrl = `${BASE_URL}/login/qr/create?key=${key}&qrimg=true×tamp=${Date.now()}`; - return await fetch(qrPicUrl).then(async (resp) => { + return await fetch(qrPicUrl).then(async resp => { const respJson = await resp.json(); return respJson.data.qrimg; }); @@ -85,11 +83,10 @@ async function getQrCode(key) { async function getUserRecord(uid) { return axios({ url: `${BASE_URL}/user/record?uid=${uid}&type=1×tamp=${Date.now()}`, - method: 'get', - }) - .then(resp => { - return resp.data - }); + method: "get", + }).then(resp => { + return resp.data; + }); } /** @@ -100,24 +97,22 @@ async function getUserRecord(uid) { async function checkMusic(id) { return axios({ url: `${BASE_URL}/check/music?id=${id}×tamp=${Date.now()}`, - method: 'get', - }) - .then(resp => { - return resp.data - }); + method: "get", + }).then(resp => { + return resp.data; + }); } async function getSong(id, cookie) { return axios({ url: `${BASE_URL}/song/url/v1?id=${id}&level=standard×tamp=${Date.now()}`, - method: 'post', + method: "post", data: { cookie, }, - }) - .then(resp => { - return resp.data.data - }); + }).then(resp => { + return resp.data.data; + }); } export { @@ -128,5 +123,5 @@ export { getQrCode, getUserRecord, checkMusic, - getSong -} \ No newline at end of file + getSong, +};