瀏覽代碼

fix undefined

xCss 7 年之前
父節點
當前提交
a06d75453b
共有 1 個文件被更改,包括 9 次插入5 次删除
  1. 9 5
      routes/netease.js

+ 9 - 5
routes/netease.js

@@ -33,6 +33,7 @@ router.get('/:channel', function(req, res, next) {
                 "n": 1000,
                 "csrf_token": ""
             }
+            request(config,id,channel)
             break;
         case 'song':
             config['params'] = {
@@ -40,6 +41,7 @@ router.get('/:channel', function(req, res, next) {
                 "ids": '[' + id + ']',
                 "csrf_token": ""
             }
+            request(config,id,channel)
             break;
         default:
             res.send({
@@ -49,13 +51,16 @@ router.get('/:channel', function(req, res, next) {
                     msg: 'no support url. Please set `song` or `playlist`'
                 }
             })
-            return
             break;
     }
+
+});
+function request(config,id,channel){
+
     util.requestServer(config).then(ret => {
         if (channel == 'song') {
             let songs = ret.songs
-            if (song && songs.length) {
+            if (songs && songs.length) {
                 config['path'] = links.song_url
                 config['params'] = {
                     "ids": [id],
@@ -93,7 +98,7 @@ router.get('/:channel', function(req, res, next) {
         } else {
             res.send(ret)
         }
-
+    
     }).catch(err => {
         console.log(err)
         res.send({
@@ -104,8 +109,7 @@ router.get('/:channel', function(req, res, next) {
             }
         })
     })
-
-});
+}
 
 
 module.exports = router;