From 898af95ceb378291de9467ee3cb48e766848ff76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2EFernando=20S=C3=A1nchez?= Date: Thu, 11 Oct 2012 21:22:41 +0200 Subject: [PATCH] Added support for HD. No empty fields --- player.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/player.js b/player.js index 06d70ff..9ae721d 100644 --- a/player.js +++ b/player.js @@ -36,12 +36,19 @@ app.get('/search', function(req, resp){ html += data; }).on('end', function() { // the whole of webpage data has been collected. parsing time! - $(html).find('.play').each(function(i,elem){ - var prev = $(elem).prev(); - var title = $(prev).children(".song").text(); - var group = $(prev).children(".group").text(); - var id = prev.attr("href").split("/")[1]; - results.push({id:id,title:title,group:group}) + $(html).find('a.play').each(function(i,elem){ + var prev = $(elem).prevAll('a'); + var title = $(prev).children('.song').text(); + var quality = $(elem).next("p").text().split("|")[0].trim(); + title+=" ["+quality+"]"; + if($(elem).prev().is("img")){ + title+=" HD!"; + } + var group = $(prev).children('.group').text(); + var id = prev.attr('href').split('/')[1]; + if(typeof title != 'undefined' && typeof group != 'undefined' ){ + results.push({id:id,title:title,group:group}) + } }); console.log("Results:"+JSON.stringify(results)); resp.send(JSON.stringify(results));