Showing
1 changed file
with
6 additions
and
4 deletions
... | @@ -45,6 +45,8 @@ const client = new line.Client(config); | ... | @@ -45,6 +45,8 @@ const client = new line.Client(config); |
45 | // about the middleware, please refer to doc | 45 | // about the middleware, please refer to doc |
46 | 46 | ||
47 | 47 | ||
48 | +var songList=[]; // list to store music(singer, song, lyric url) | ||
49 | + | ||
48 | 50 | ||
49 | app.post('/webhook', line.middleware(config), (req, res) => { | 51 | app.post('/webhook', line.middleware(config), (req, res) => { |
50 | Promise | 52 | Promise |
... | @@ -214,10 +216,10 @@ function handleEvent(event) { | ... | @@ -214,10 +216,10 @@ function handleEvent(event) { |
214 | var $ = cheerio.load(html); | 216 | var $ = cheerio.load(html); |
215 | const $bodyList= $('#body-content > div.search_lyrics > div.music-list-wrap.type-lyrics > table > tbody > tr'); | 217 | const $bodyList= $('#body-content > div.search_lyrics > div.music-list-wrap.type-lyrics > table > tbody > tr'); |
216 | 218 | ||
217 | - var songList=[]; | 219 | + var songs=[]; |
218 | $bodyList.each(function(i, elem){ | 220 | $bodyList.each(function(i, elem){ |
219 | if(i<20){ | 221 | if(i<20){ |
220 | - songList.push({ | 222 | + songs.push({ |
221 | singer: $(this).find("td.info").find("a.artist.ellipsis").text().trim(), | 223 | singer: $(this).find("td.info").find("a.artist.ellipsis").text().trim(), |
222 | song: $(this).find("td.info").find("a.title.ellipsis").text().trim(), | 224 | song: $(this).find("td.info").find("a.title.ellipsis").text().trim(), |
223 | }); | 225 | }); |
... | @@ -226,8 +228,8 @@ function handleEvent(event) { | ... | @@ -226,8 +228,8 @@ function handleEvent(event) { |
226 | }) | 228 | }) |
227 | var resultm=''; | 229 | var resultm=''; |
228 | for(var i=0;i<songList.length;i++){ | 230 | for(var i=0;i<songList.length;i++){ |
229 | - if(songList[i].singer!=''){ | 231 | + if(songs[i].singer!=''){ |
230 | - resultm+=songList[i].singer+", "+songList[i].song+"\n"; | 232 | + resultm+=songs[i].singer+", "+songs[i].song+"\n"; |
231 | } | 233 | } |
232 | } | 234 | } |
233 | var result = { type: 'text', text:resultm}; | 235 | var result = { type: 'text', text:resultm}; | ... | ... |
-
Please register or login to post a comment