AXCWG 3 月之前
父节点
当前提交
e87f940e82
共有 1 个文件被更改,包括 2 次插入26 次删除
  1. 2 26
      main.js

+ 2 - 26
main.js

@@ -225,35 +225,11 @@ app.post('/lyric', async (req, res) => {
     let name = req.body.name
     let artist = req.body.artist;
     let album = req.body.albumName;
-    let id = "";
-    for (const result of (await (await fetch(ncmAPIUrl + `/cloudsearch?keywords=${name}%20${artist}%20${album}`)).json()).result.songs) {
-        if(result.name === await convertert2s.convertPromise(name) ){
-            id = result.id
-            break;
-        }
-
-    }
-    let lyric = await (await fetch(ncmAPIUrl + `/lyric?id=${id}`)).json()
-    let ifTrans = false;
-    try{
-        if (lyric.tlyric.lyric !== '') {
-            ifTrans = true;
-        }
-    }catch(err){
-        console.log(err);
-        res.header("Access-Control-Allow-Origin", "*");
 
-        res.end("{}")
-        return
-    }
+    let lrc = await (await fetch(`https://api.lrc.cx/api/v1/lyrics/single?title=${name}&album=${album}&artist=${artist}`)).text()
 
-    let response = {
-        ifTrans: ifTrans,
-        lyric: lyric.lrc.lyric,
-        tlyric: lyric.tlyric.lyric
-    }
     res.header("Access-Control-Allow-Origin", "*");
-    res.end(JSON.stringify(response))
+    res.end(lrc)
 })
 app.options('/lyric', async (req, res) => {
     res.header("Access-Control-Allow-Origin", "*");