Add script for finding duplicate entries
This commit is contained in:
parent
891ca12890
commit
6fc21111aa
3 changed files with 32 additions and 0 deletions
28
src/bin.ts
28
src/bin.ts
|
@ -10,6 +10,7 @@ interface Cli {
|
|||
wiki?: boolean,
|
||||
manifest?: boolean,
|
||||
stats?: boolean,
|
||||
duplicates?: boolean,
|
||||
all?: boolean,
|
||||
irregularPathUntagged?: boolean,
|
||||
skipUntil?: string,
|
||||
|
@ -52,6 +53,33 @@ async function main() {
|
|||
process.exit(0);
|
||||
}
|
||||
|
||||
if (args.duplicates) {
|
||||
const data: {[key: string]: Array<{ name: string; pageId: number }>} = {};
|
||||
for (const [name, info] of Object.entries(manifest.data)) {
|
||||
const key = JSON.stringify(info);
|
||||
let safe = false;
|
||||
for (const file of Object.keys(info.files ?? {})) {
|
||||
if (file.includes("<game>") || file.includes("<base>")) {
|
||||
safe = true;
|
||||
}
|
||||
}
|
||||
if (safe) {
|
||||
continue;
|
||||
}
|
||||
if (!(key in data)) {
|
||||
data[key] = [];
|
||||
}
|
||||
data[key].push({ name, pageId: wikiCache.data[name]?.pageId ?? 0 });
|
||||
}
|
||||
for (const games of Object.values(data)) {
|
||||
if (games.length > 1) {
|
||||
const lines = games.map(({ name, pageId }) => `[${pageId}] ${name}`);
|
||||
console.log(`\nSame manifest entry:\n - ${lines.join("\n - ")}`);
|
||||
}
|
||||
}
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
try {
|
||||
if (args.wiki) {
|
||||
if (args.recent) {
|
||||
|
|
Reference in a new issue