8000 A20plus data update by noahm · Pull Request #49 · noahm/DDRCardDraw · GitHub
[go: up one dir, main page]

Skip to content
Merged
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
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/scraper/shock-arrows.js"
"name": "Launch Current Script",
"program": "${workspaceFolder}/${relativeFile}"
}
]
}
}
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ and [FuriousDCSL](https://github.com/FuriousDCSL). Contributions are welcome!
## Customizing / Contributing

This app can be easily customized for any format a tournament might use, including adding song
data for other games. If you have requests or ideas, [please reach out](https://m.me/noah.manneschmidt)!
data for other games. If you have requests or ideas, you're welcome reach out on [Facebook](https://m.me/noah.manneschmidt),
[Twitter](https://twitter.com/Cathadan), Discord (Cathadan#2431), or wherever else you can find me.

If you want to take a stab at it yourself, you will want to have node.js >= 10.0.0 installed along with
If you want to take a stab at it yourself, you will want to have node.js >= 14.0.0 installed along with
[yarn](https://yarnpkg.com/) and some familarity with [Preact](https://github.com/developit/preact)
(or react) apps.

Expand All @@ -40,5 +41,16 @@ yarn validate:json
yarn build
```

There are some other useful scripts in `scripts/` that help in maintaining data integrity and pulling
in new song data. Several have top-level aliases so you can conveniently update song data:

```sh
# download latest StepManiaX song data and jackets
yarn import:smx

# download latest DDR A20 Plus song data and jackets (when available on RemyWiki)
yarn import:ddr
```

Ideas for future develoment are now being tracked as issues on this repo. Feel free to jump in if you
want to help build out something new!
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"deploy": "npm run build && surge ./dist https://ddrdraw.surge.sh",
"deploy:staging": "npm run build && surge ./dist https://ddrdraw-staging.surge.sh",
"deploy:firebase": "npm run build && firebase deploy",
"import:a20plus": "node scripts/import-a20plus.js",
"import:sdvx": "node scripts/import-sdvx.js",
"import:smx": "node scripts/import-smx.js",
"migrate": "node scripts/migrate.js",
Expand Down Expand Up @@ -49,9 +50,11 @@
"fork-ts-checker-webpack-plugin": "^4.0.4",
"formdata-polyfill": "^3.0.19",
"fuzzy-search": "^3.0.2",
"he": "^1.2.0",
"html-webpack-plugin": "^3.2.0",
"iconv-lite": "^0.6.2",
"jimp": "^0.14.0",
"iconv-lite": "^0.6.3",
"inquirer": "^8.1.2",
"jimp": "^0.16.0",
"jsdom": "^15.2.1",
"json-schema-to-typescript": "^8.0.0",
"jsonschema": "^1.2.2",
Expand Down
3 changes: 3 additions & 0 deletions scraper/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This folder contains some older python scripts that other folks wrote
years ago to help wrangle data. These days my personal data scraping
libraries are all located in `scripts/scraping` instead.
154 changes: 0 additions & 154 deletions scraper/a20plus.js

This file was deleted.

77 changes: 0 additions & 77 deletions scraper/shock-arrows.js

This file was deleted.

12 changes: 12 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
This folder contains utility scripts, mostly for helping to maintain data integrity.

`scraping/*` contains utility functions and historical efforts to scrape data from
various online sources to collect DDR song data and jacket images.

The `import-*.js` scripts help bring in data from various sources, sometimes online,
sometimes local DB files or data dumps.

`validate.js` is important as it does a bunch of sanity checks on all data files,
ensures they match the specified schema for song data (from `songs.schema.json`),
and finally does some code-gen to write an updated typescript interface for that
song data into `src/models/SongData.ts`
76 changes: 76 additions & 0 deletions scripts/image-audit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/** Run this to help audit which songs need jackets, and which already have jackets but are not linked up */
const fs = require("fs");
const path = require("path");
const inquirer = require("inquirer");
const fuzzysearch = require("fuzzy-search");
const { writeJsonData } = require("./utils");

const jacketDir = path.resolve(__dirname, "..", "src/assets/jackets");
const targetFile = path.resolve(__dirname, "../src/songs/a20plus.json");

const images = fs
.readdirSync(jacketDir)
.filter((file) => !file.startsWith("ex_"));
const jacketIndex = new fuzzysearch(images, undefined, { sort: true });

function jacketExists(song) {
return fs.existsSync(path.join(jacketDir, song.jacket));
}

function jacketOnDisc(song) {
return (
fs.existsSync(path.join(jacketDir, song.name + ".png")) ||
fs.existsSync(path.join(jacketDir, song.name_translation + ".png"))
);
}

async function promptForJacket(song) {
const jacketKey = song.name_translation || song.name;
let results = jacketIndex.search(jacketKey);
if (!results.length) {
results = jacketIndex.search(jacketKey.slice(0, 3));
}
results.unshift("");
const answers = await inquirer.prompt({
type: "list",
name: "image",
message: `Pick a jacket for ${jacketKey}`,
choices: results,
});
return answers.image;
}

const counts = {
missingJacket: [],
unusedJacketOnDisc: [],
missingOnDisc: [],
};

async function main() {
const data = require(targetFile);

for (const song of data.songs) {
if (song.jacket) {
if (!jacketExists(song)) {
counts.missingOnDisc.push(song.name);
}
} else {
counts.missingJacket.push(song.name_translation || song.name);
if (jacketOnDisc(song)) {
counts.unusedJacketOnDisc.push(song.name);
} else {
song.jacket = await promptForJacket(song);
}
}
}

console.log(counts);
console.log({
missingJacket: counts.missingJacket.length,
unusedJacketOnDisc: counts.unusedJacketOnDisc.length,
missingOnDisc: counts.missingOnDisc.length,
});
writeJsonData(data, targetFile);
}

main();
Loading
0