Skip to content

Instantly share code, notes, and snippets.

@inolen
Created March 19, 2018 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inolen/56e7e54a99347f620201fe17f9d574bb to your computer and use it in GitHub Desktop.
Save inolen/56e7e54a99347f620201fe17f9d574bb to your computer and use it in GitHub Desktop.
const fs = require('fs');
const cheerio = require('cheerio');
const request = require('request-promise-native');
function sanitizeName (name) {
name = name.replace(/\s+\(Disc \d+\)/i, '');
name = name.replace(' (Europe)', '');
name = name.replace(' (Japan)', '');
name = name.replace(' (NTSC)', '');
name = name.replace(' (PAL)', '');
name = name.replace(' (PAL, NTSC)', '');
return name;
}
async function getRedumpList () {
var games = {};
var page = 1;
while (1) {
var url = 'http://redump.org/discs/system/dc/?page=' + page;
var html = await request(url);
var $ = cheerio.load(html);
var rows = $('table.games tbody tr[class!="th"]');
if (!rows.length) {
break;
}
rows.each(function (i, el) {
var columns = $(el).children('td');
var name = sanitizeName(columns.eq(1).children('a').contents()[0].data);
var version = columns.eq(3).text();
var serials = columns.eq(6).text().split(/[,|]/).map(function (x) {
return x.trim();
});
if (!games[name]) {
games[name] = [];
}
for (var serial of serials) {
games[name].push({
version: version,
serial: serial
});
}
});
page++;
}
return games;
}
(async function () {
var redump = await getRedumpList();
console.log(redump);
}())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment