Browse Source

Merge branch 'master' into user

AXCWG 3 months ago
parent
commit
45fb373db8
1 changed files with 9 additions and 3 deletions
  1. 9 3
      main.js

+ 9 - 3
main.js

@@ -305,7 +305,7 @@ async function SubmitWrapper(req, res) {
 
                                 res.header("Access-Control-Allow-Origin", "*");
                                 res.statusCode = 500
-                                res.end("傻逼,重复了。请在盲目上传之前看看库里有没有好么傻逼?")
+                                res.end("和数据库中条目重复")
                                 return
 
                             }
@@ -346,7 +346,7 @@ async function SubmitWrapper(req, res) {
             } else {
                 res.header("Access-Control-Allow-Origin", "*");
                 res.statusCode = 500
-                res.end("傻逼,重复了。请在盲目上传之前看看库里有没有好么傻逼?")
+                res.end("和数据库中条目重复")
             }
 
         })
@@ -486,7 +486,7 @@ app.post("/ncm/url", function (req, res) {
         return
     }
 
-    if (req.body.id !== undefined && req.body.kind !== undefined) {
+    if (!req.body.id && !req.body.kind) {
         try {
             let id = req.body.id
             fetch(ncmAPIUrl + "/song/download/url/v1?id=" + id + "&level=hires", {
@@ -495,6 +495,12 @@ app.post("/ncm/url", function (req, res) {
                 }
             }).then(async result => {
                 if (result.status === 200 || result.status === 304) {
+                    try{
+                        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();