mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-25 02:57:30 +00:00
Extract text from skins
This commit is contained in:
parent
5d46d4d028
commit
4ea4b7b193
2 changed files with 54 additions and 1 deletions
|
|
@ -20,7 +20,8 @@
|
|||
"test": "react-scripts test --env=jsdom",
|
||||
"eject": "react-scripts eject",
|
||||
"build-index": "node ./scripts/findSkins.js",
|
||||
"create-search-index": "node ./scripts/createSearchIndex.js > index.json"
|
||||
"create-search-index": "node ./scripts/createSearchIndex.js > index.json",
|
||||
"extract": "find ../webamp/experiments/automatedScreenshots/skins \"(\" -name \"*.wsz\" -o -name \"*.zip\" \")\" -exec node ./scripts/extractSkinText.js \"{}\" \\;"
|
||||
},
|
||||
"prettier": {},
|
||||
"browserslist": [
|
||||
|
|
|
|||
52
scripts/extractSkinText.js
Normal file
52
scripts/extractSkinText.js
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
const path = require("path");
|
||||
var { exec } = require("child_process");
|
||||
|
||||
async function extractTextData(path) {
|
||||
const reg = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/g;
|
||||
const extract = value => (value && value.match(reg)) || [];
|
||||
|
||||
const ignoreFiles = [
|
||||
"genex.txt",
|
||||
"genexinfo.txt",
|
||||
"gen_gslyrics.txt",
|
||||
"region.txt",
|
||||
"pledit.txt",
|
||||
"viscolor.txt",
|
||||
"winampmb.txt",
|
||||
"gen_ex help.txt",
|
||||
"mbinner.txt"
|
||||
// Skinning Updates.txt ?
|
||||
];
|
||||
|
||||
const ignoreArgs = ignoreFiles
|
||||
.map(file => `-x "**/${file}" ${file}`)
|
||||
.join(" ");
|
||||
|
||||
// Change -p to -c to get context of which file is missing
|
||||
const debug = false;
|
||||
const listFlag = debug ? "-c" : "-p";
|
||||
|
||||
// TODO: Escape path
|
||||
const cmd = `unzip ${listFlag} -C "${path}" "file_id.diz" "*.txt" ${ignoreArgs}`;
|
||||
|
||||
const raw = await new Promise((resolve, reject) => {
|
||||
exec(cmd, function(error, stdout, stderr) {
|
||||
if (error != null) {
|
||||
//reject(error);
|
||||
//return;
|
||||
}
|
||||
resolve(stdout);
|
||||
});
|
||||
});
|
||||
|
||||
return { raw, emails: extract(raw) };
|
||||
}
|
||||
|
||||
const skinPath = path.join(process.cwd(), process.argv[2]);
|
||||
|
||||
extractTextData(skinPath).then(data => {
|
||||
if (data.emails.length) {
|
||||
// console.log(data.emails);
|
||||
}
|
||||
console.log(data);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue