Created
October 7, 2013 21:48
-
-
Save denysonique/6875509 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('request'); | |
var cheerio = require('cheerio'); | |
var pages, channel, link, url, page, week, songCount, list; | |
getMusic = function (link, pages, callfuck) { | |
console.log('Initializing Music retrieval...'); | |
for (pageX = 0; pageX <= pages; pageX++) { | |
url = link + pageX; | |
console.log(url, pageX); | |
getPage(pageX, callfuck); | |
}; | |
}; | |
function getPage (pageX, callfuck) { | |
console.log('enter get page'); | |
request(url, function(err, response, body) { | |
if(!err && response.statusCode == 200) { | |
$ = cheerio.load(body); | |
getSongs(body, callfuck) | |
} else { | |
throw err; | |
} | |
}); | |
}; | |
function getSongs(body, callfuck) { | |
console.log('enter get songs'); | |
for (x = 0; x <= songCount; x++) { | |
var songName = $('td.channel:first-child').parent().nextAll().eq(x).children('td:nth-child(2)').text(); | |
var songArtist = $('td.channel:first-child').parent().nextAll().eq(x).children('td:nth-child(3)').text(); | |
var dateAdded = $('td.channel:first-child').parent().nextAll().eq(x).children('td:nth-child(4)').text(); | |
list.push({'name': songName, 'artist': songArtist, 'date': dateAdded}); | |
}; | |
callfuck(list) | |
}; | |
pages = 4; | |
//choose channel, week out of year (year + week #), page has to be last in link for looping, songs per page | |
channel = '&channel=51'; | |
week = '&tdate=201340' | |
page = '&page=' | |
link = 'http://www.dogstarradio.com/search_playlist.php?' + channel + week + page; | |
songCount = 5; //49 | |
list = []; | |
getMusic(link, 0, function(songs) { console.log(songs)}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment