|  | @@ -54,7 +54,6 @@ function Submit(req, res) {
 | 
	
		
			
				|  |  |      let uuid = crypto.randomUUID()
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      db.connect(function (err) {
 | 
	
		
			
				|  |  |          if (err) {
 | 
	
		
			
				|  |  |              console.log(err)
 | 
	
	
		
			
				|  | @@ -67,22 +66,21 @@ function Submit(req, res) {
 | 
	
		
			
				|  |  |          fetch(req.body.file).then(res => {
 | 
	
		
			
				|  |  |              res.arrayBuffer().then(r => fs.writeFileSync("./" + uuid, Buffer.from(r)));
 | 
	
		
			
				|  |  |          })
 | 
	
		
			
				|  |  | -        if(URL.canParse(req.body.albumCover)){
 | 
	
		
			
				|  |  | +        if (URL.canParse(req.body.albumCover)) {
 | 
	
		
			
				|  |  |              console.log("can parse ")
 | 
	
		
			
				|  |  |              fetch(req.body.albumCover).then(res => {
 | 
	
		
			
				|  |  |                  res.arrayBuffer().then(async r => {
 | 
	
		
			
				|  |  | -                    if(!fs.existsSync("tmp")){
 | 
	
		
			
				|  |  | +                    if (!fs.existsSync("tmp")) {
 | 
	
		
			
				|  |  |                          fs.mkdirSync("tmp")
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  | -                    fs.writeFileSync("tmp/"+uuid, new Buffer.from(r));
 | 
	
		
			
				|  |  | -                    await webp.cwebp("tmp/"+uuid, "tmp/"+uuid+".webp", "-q 50", "-v")
 | 
	
		
			
				|  |  | -                    albumCover = fs.readFileSync("tmp/"+uuid+".webp")
 | 
	
		
			
				|  |  | +                    fs.writeFileSync("tmp/" + uuid, new Buffer.from(r));
 | 
	
		
			
				|  |  | +                    await webp.cwebp("tmp/" + uuid, "tmp/" + uuid + ".webp", "-q 50", "-v")
 | 
	
		
			
				|  |  | +                    albumCover = fs.readFileSync("tmp/" + uuid + ".webp")
 | 
	
		
			
				|  |  |                  })
 | 
	
		
			
				|  |  |              })
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      } catch (err) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          console.log(err)
 | 
	
	
		
			
				|  | @@ -154,10 +152,10 @@ function Submit(req, res) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          })
 | 
	
		
			
				|  |  | -        try{
 | 
	
		
			
				|  |  | -            fs.rmSync("tmp/"+uuid)
 | 
	
		
			
				|  |  | -            fs.rmSync("tmp/"+uuid+".webp")
 | 
	
		
			
				|  |  | -        }catch(err){
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            fs.rmSync("tmp/" + uuid)
 | 
	
		
			
				|  |  | +            fs.rmSync("tmp/" + uuid + ".webp")
 | 
	
		
			
				|  |  | +        } catch (err) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if (req.body.email !== undefined && req.body.email !== "") {
 | 
	
	
		
			
				|  | @@ -215,16 +213,16 @@ function SubmitWrapper(req, res) {
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            if(req.body.name === undefined){
 | 
	
		
			
				|  |  | +            if (req.body.name === undefined) {
 | 
	
		
			
				|  |  |                  req.body.name = "未知名称"
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            if(req.body.albumName === undefined){
 | 
	
		
			
				|  |  | +            if (req.body.albumName === undefined) {
 | 
	
		
			
				|  |  |                  req.body.albumName = "未知专辑"
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            if(req.body.link === undefined){
 | 
	
		
			
				|  |  | +            if (req.body.link === undefined) {
 | 
	
		
			
				|  |  |                  req.body.link = ""
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            if(req.body.artist === undefined){
 | 
	
		
			
				|  |  | +            if (req.body.artist === undefined) {
 | 
	
		
			
				|  |  |                  req.body.artist = "未知艺术家"
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              if (req.body.file !== undefined) {
 | 
	
	
		
			
				|  | @@ -342,23 +340,23 @@ app.get("/getSingle", function (req, res) {
 | 
	
		
			
				|  |  |              res.contentType("application/json");
 | 
	
		
			
				|  |  |              res.header("Access-Control-Allow-Origin", "*");
 | 
	
		
			
				|  |  |              res.header("Access-Control-Allow-Headers", "Content-Type");
 | 
	
		
			
				|  |  | -            if(rows[0]!==undefined){
 | 
	
		
			
				|  |  | -                if(rows[0].albumcover !== null) {
 | 
	
		
			
				|  |  | -                    if(!fs.existsSync("tmp")){
 | 
	
		
			
				|  |  | +            if (rows[0] !== undefined) {
 | 
	
		
			
				|  |  | +                if (rows[0].albumcover !== null) {
 | 
	
		
			
				|  |  | +                    if (!fs.existsSync("tmp")) {
 | 
	
		
			
				|  |  |                          fs.mkdirSync("tmp")
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  | -                    fs.writeFileSync("tmp/"+uuid, rows[0].albumcover);
 | 
	
		
			
				|  |  | -                    await webp.cwebp("tmp/"+uuid, "tmp/"+uuid+".webp", "-q 50", "-v")
 | 
	
		
			
				|  |  | -                    rows[0].albumcover = fs.readFileSync("tmp/"+uuid+".webp")
 | 
	
		
			
				|  |  | +                    fs.writeFileSync("tmp/" + uuid, rows[0].albumcover);
 | 
	
		
			
				|  |  | +                    await webp.cwebp("tmp/" + uuid, "tmp/" + uuid + ".webp", "-q 50", "-v")
 | 
	
		
			
				|  |  | +                    rows[0].albumcover = fs.readFileSync("tmp/" + uuid + ".webp")
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              res.end(JSON.stringify(rows[0]));
 | 
	
		
			
				|  |  | -            try{
 | 
	
		
			
				|  |  | -                fs.rmSync("tmp/"+uuid)
 | 
	
		
			
				|  |  | -                fs.rmSync("tmp/"+uuid+".webp")
 | 
	
		
			
				|  |  | -            }catch(err){
 | 
	
		
			
				|  |  | +            try {
 | 
	
		
			
				|  |  | +                fs.rmSync("tmp/" + uuid)
 | 
	
		
			
				|  |  | +                fs.rmSync("tmp/" + uuid + ".webp")
 | 
	
		
			
				|  |  | +            } catch (err) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -388,8 +386,8 @@ app.post("/ncm/url", function (req, res) {
 | 
	
		
			
				|  |  |                      Cookie: "MUSIC_U=0087F9D8E102A1C1661EBE1792412F3351DA64D1BD3D862BA77E45E9024524725F3A1983345D9B5A4014C725D19C069DD71081F6FE3659F9E1FD412DC427FB809FAF7789AEEA10E9DE6F06C58D1959BA209D2A83C3FA753261036C4CFD0D143B6C7748B8A6D2DD5C2E96E75D1E847E4AAE035CB2C86B175D9AFC6A164C522ED76E24AE654740AB6BAF5B29597F7E3B0158B2EC1C37F2688279871873FA7ADAEF8280A059E84C4BBFB9E4F225F9A2065DF652247D5496587A7B1E3D35DB0CD3F825C06FE5BFE5CFEF1770847099704360504B73C9B396E37CECE4F9DDEE6001588C3C4F5B2861D9ADF339FC47DD480858CA800620785EA032215B63B81025304DB3331F384793FF8EE681247E34C7931176F2F618B66C122F0602F1EA15F963E422DEC79C257F3577A197BECE71E316C751C3B9F5F3CD07BFDC0270A287A1BB6576"
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }).then(async result => {
 | 
	
		
			
				|  |  | -                let result_json = await result.json()
 | 
	
		
			
				|  |  | -                if (result_json.data.url !== null) {
 | 
	
		
			
				|  |  | +                if (result.status === 200 || result.status === 304) {
 | 
	
		
			
				|  |  | +                    let result_json = await result.json()
 | 
	
		
			
				|  |  |                      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")
 | 
	
		
			
				|  |  |                      req.body.name = infos.songs[0].name;
 | 
	
	
		
			
				|  | @@ -405,9 +403,10 @@ app.post("/ncm/url", function (req, res) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  } else {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                    res.status(404).header("Access-Control-Allow-Origin", "*").send("未找到")
 | 
	
		
			
				|  |  | +                    res.status(404).header("Access-Control-Allow-Origin", "*").send("未找到或出现错误")
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              })
 | 
	
		
			
				|  |  |          } catch (err) {
 | 
	
		
			
				|  |  |              res.status(500).header("Access-Control-Allow-Origin", "*");
 |