Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/libretro-super
.DS_Store
node_modules
pnpm-lock.yaml
package-lock.json
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"private": true,
"type": "module",
"scripts": {
"check-duplicate": "node scripts/check-duplicate.js"
},
"devDependencies": {
"@retrobrainz/dat": "^1.0.1",
"chalk": "^5.6.2"
}
}
30 changes: 30 additions & 0 deletions scripts/check-duplicate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { parse } from "@retrobrainz/dat";
import chalk from "chalk";
import { glob, readFile } from "node:fs/promises";

for await (const datFile of glob(["dat/**/*.dat", "metadat/**/*.dat"], { exclude: ["dat/DOS.dat"] })) {
console.log(datFile);
const datContent = await readFile(datFile, "utf8");
const dat = parse(datContent);
const crcSerialMap = {};
for (const game of dat) {
if (
game.$class !== "game" ||
game.$entries?.length !== 1 ||
game.$entries?.[0].$class !== "rom"
) {
continue;
}
const crc = game.$entries?.[0].crc;
const serial = game.$entries?.[0].serial || game.serial;
// if both crc and serial are the same, mark as duplicate
const key = JSON.stringify({crc, serial});
crcSerialMap[key] = (crcSerialMap[key] || 0) + 1;
}
for (const [key, count] of Object.entries(crcSerialMap)) {
if (count > 1) {
const {crc, serial} = JSON.parse(key);
console.log(chalk.red(` duplicate: crc(${crc}), serial(${serial}), count(${count})`));
}
}
}