|
@@ -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", "*");
|