Browse Source

optimizelogic

AXCWG 3 tháng trước cách đây
mục cha
commit
eee4e679dc
2 tập tin đã thay đổi với 52 bổ sung27 xóa
  1. 44 25
      main.js
  2. 8 2
      test.js

+ 44 - 25
main.js

@@ -88,7 +88,7 @@ function Submit(req) {
                         fs.mkdirSync("tmp")
                     }
                     fs.writeFileSync("tmp/" + uuid, new Buffer.from(r));
-                    await webp.cwebp("tmp/" + uuid, "tmp/" + uuid + ".webp", "-q 50", "-v")
+                    await webp.cwebp("tmp/" + uuid, "tmp/" + uuid + ".webp", "-q 50 -mt ", "-v")
                     albumCover = fs.readFileSync("tmp/" + uuid + ".webp")
                 })
             })
@@ -254,7 +254,11 @@ async function SubmitWrapper(req, res) {
                     Submit(req)
                 })
                 currentTask.push({
-                    name: req.body.name, albumName: req.body.albumName, kind: req.body.kind, artist: req.body.artist,
+                    name: req.body.name,
+                    albumName: req.body.albumName,
+                    kind: req.body.kind,
+                    artist: req.body.artist,
+                    email: req.body.email !== undefined ? req.body.email : null,
                 })
 
                 console.log(queue.contents)
@@ -355,36 +359,51 @@ app.options('/search_api', function (req, res) {
 })
 app.get("/getSingle", function (req, res) {
     let uuid = crypto.randomUUID()
-
     if (req.query.id) {
-        db.execute("SELECT song_name, album_name, artist, kind, albumcover FROM instrunet_entry WHERE uuid = ?", [req.query.id], async function (err, rows) {
-            if (err) {
-                console.log(err);
-            }
-            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")) {
-                        fs.mkdirSync("tmp")
+        if (req.query.albumcover === "true") {
+            db.execute("SELECT albumcover FROM instrunet_entry WHERE uuid = ?", [req.query.id], async function (err, rows) {
+                if (err) {
+                    console.log(err);
+                }
+                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")) {
+                            fs.mkdirSync("tmp")
+                        }
+                        fs.writeFileSync("tmp/" + uuid, rows[0].albumcover);
+                        await webp.cwebp("tmp/" + uuid, "tmp/" + uuid + ".webp", "-q 50 -mt", "-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) {
 
                 }
-            }
 
-            res.end(JSON.stringify(rows[0]));
-            try {
-                fs.rmSync("tmp/" + uuid)
-                fs.rmSync("tmp/" + uuid + ".webp")
-            } catch (err) {
+            })
+        } else
 
-            }
+            db.execute("SELECT song_name, album_name, artist, kind FROM instrunet_entry WHERE uuid = ?", [req.query.id], async function (err, rows) {
+                if (err) {
+                    console.log(err);
+                }
+                res.contentType("application/json");
+                res.header("Access-Control-Allow-Origin", "*");
+                res.header("Access-Control-Allow-Headers", "Content-Type");
 
-        })
+
+                res.end(JSON.stringify(rows[0]));
+
+
+            })
 
     } else {
         res.contentType("application/json");

+ 8 - 2
test.js

@@ -5,7 +5,13 @@ queue1.autoRun = false;
 const cnchar = require('cnchar');
 const sortArray = require("sort-array");
 
+async function sth(){
 
+}
+async function getTask(){
+    console.log(2)
+}
 
-cnchar.setStrokeCount("愛", 13)
-console.log("愛".stroke())
+
+getTask()
+sth()