AXCWG 3 сар өмнө
parent
commit
21a6eb635d
1 өөрчлөгдсөн 5 нэмэгдсэн , 5 устгасан
  1. 5 5
      main.js

+ 5 - 5
main.js

@@ -26,8 +26,8 @@ const Kind = {
 }
 
 const db = mysql.createConnection({
-    host: 'localhost',
-    user: 'root',
+    host: 'andyxie.cn',
+    user: 'external',
     password: 'moyingren2015',
     database: "instrunet_data",
     pool: pool,
@@ -478,7 +478,7 @@ app.post("/ncm/url", function (req, res) {
         return
     }
 
-    if (!req.body.id && !req.body.kind) {
+    if (req.body.id && (req.body.kind || req.body.kind === 0)) {
         try {
             let id = req.body.id
             fetch(ncmAPIUrl + "/song/download/url/v1?id=" + id + "&level=hires", {
@@ -487,13 +487,13 @@ app.post("/ncm/url", function (req, res) {
                 }
             }).then(async result => {
                 if (result.status === 200 || result.status === 304) {
+                    let result_json = null;
                     try{
-                        await result.json()
+                       result_json =  await result.json()
                     }catch (e){
                         res.status(500).header("Access-Control-Allow-Origin", "*").end("格式错误");
                         return
                     }
-                    let result_json = await result.json()
                     if (result_json.data.url !== null) {
                         let infos = await (await fetch(ncmAPIUrl + "/song/detail?ids=" + id)).json();
                         req.body.file = "data:audio/flac;base64," + Buffer.from(await (await fetch(result_json.data.url)).arrayBuffer()).toString("base64")