|
@@ -188,6 +188,30 @@ function SubmitWrapper(req, res) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+app.post('/lyric', async (req, res) => {
|
|
|
+ let name = req.body.name;
|
|
|
+ let artist = req.body.artist;
|
|
|
+ let id = (await (await fetch(ncmAPIUrl + `/cloudsearch?keywords=${name}%20${artist}`)).json()).result.songs[0].id
|
|
|
+ let lyric = await (await fetch(ncmAPIUrl + `/lyric?id=${id}`)).json()
|
|
|
+ let ifTrans = false;
|
|
|
+ if(lyric.tlyric.lyric !== ''){
|
|
|
+ ifTrans = true;
|
|
|
+ }
|
|
|
+ let response = {
|
|
|
+ ifTrans: ifTrans,
|
|
|
+ lyric: lyric.lrc,
|
|
|
+ tlyric: lyric.tlyric.lyric
|
|
|
+ }
|
|
|
+ res.header("Access-Control-Allow-Origin", "*");
|
|
|
+ res.end(JSON.stringify(response))
|
|
|
+})
|
|
|
+app.options('/lyric', async (req, res) => {
|
|
|
+ res.header("Access-Control-Allow-Origin", "*");
|
|
|
+ res.header("Access-Control-Allow-Headers", "Content-Type");
|
|
|
+ res.end()
|
|
|
+})
|
|
|
+
|
|
|
+
|
|
|
|
|
|
app.options('/submit', function (req, res) {
|
|
|
res.header("Access-Control-Allow-Origin", "*");
|