Skip to content

Commit

Permalink
add formatter config & update README
Browse files Browse the repository at this point in the history
  • Loading branch information
nicks96432 committed Aug 10, 2021
1 parent 978927a commit fc4e2e4
Show file tree
Hide file tree
Showing 12 changed files with 2,226 additions and 2,181 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
indent_size = 4
indent_style = space

[*.js,*.md]
insert_final_newline = true
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"arrowParens": "avoid",
"endOfLine": "lf",
"trailingComma": "none",
"useTabs": false,
"semi": true
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ yarn build
## License

Licensed under [MIT](LICENSE).

The copyright of anything that downloaded from this program belongs to Bandai Namco Entertainment.
2 changes: 2 additions & 0 deletions README.zh-TW.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ yarn build
## 授權條款

本軟體遵守[MIT](LICENSE)授權條款。

所有從本軟體下載的資料版權由萬代南夢宮娛樂所有
54 changes: 27 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
{
"name": "mltd-asset-downloader",
"version": "1.0.0",
"license": "MIT",
"private": true,
"scripts": {
"build": "webpack --mode production",
"postbuild": "pkg -t node16-linux-x64,node16-macos-x64,node16-win-x64 -C brotli --out-path dist dist/mltd-asset-downloader.js",
"dev": "webpack --mode development --watch",
"start": "node build/mltd-asset-downloader"
},
"dependencies": {
"@msgpack/msgpack": "^2.7.0",
"bluebird": "^3.7.2",
"chalk": "^4.1.2",
"cli-progress": "^3.9.0",
"commander": "^8.1.0",
"inquirer": "^8.1.2",
"log-update": "^4.0.0",
"node-fetch": "^2.6.1",
"sprintf-js": "^1.1.2"
},
"devDependencies": {
"pkg": "^5.3.1",
"webpack": "^5.48.0",
"webpack-cli": "^4.7.2"
}
{
"name": "mltd-asset-downloader",
"version": "1.0.0",
"license": "MIT",
"private": true,
"scripts": {
"build": "webpack --mode production",
"postbuild": "pkg -t node16-linux-x64,node16-macos-x64,node16-win-x64 -C brotli --out-path dist dist/mltd-asset-downloader.js",
"dev": "webpack --mode development --watch",
"start": "node build/mltd-asset-downloader"
},
"dependencies": {
"@msgpack/msgpack": "^2.7.0",
"bluebird": "^3.7.2",
"chalk": "^4.1.2",
"cli-progress": "^3.9.0",
"commander": "^8.1.0",
"inquirer": "^8.1.2",
"log-update": "^4.0.0",
"node-fetch": "^2.6.1",
"sprintf-js": "^1.1.2"
},
"devDependencies": {
"pkg": "^5.3.1",
"webpack": "^5.48.0",
"webpack-cli": "^4.7.2"
}
}
22 changes: 17 additions & 5 deletions src/downloadAssets.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ const downloadAssets = async (assetList, args, i18n) => {
} catch (e) {}
for (const assetVersion of downloadList) {
const outputPath = path.join(args.outputPath, assetVersion);
logUpdate(sprintf(i18n.downloadAssets, outputPath));
if (args.checksum)
logUpdate(sprintf(i18n.checksummingAssets, outputPath));
else logUpdate(sprintf(i18n.downloadingAssets, outputPath));
if (!args.dryRun && !args.checksum)
try {
await fs.mkdir(outputPath, { recursive: true });
Expand All @@ -42,10 +44,12 @@ const downloadAssets = async (assetList, args, i18n) => {
await Promise.map(
assetList[assetVersion],
async assetListItem => {
let dataURL = `https://d3k5923sb1sy5k.cloudfront.net/${assetVersion}/production/`;
let dataURL =
"https://d3k5923sb1sy5k.cloudfront.net/" +
`${assetVersion}/production/`;
assetVersion < 70000
? (dataURL += `2017v1`)
: (dataURL += `2018v1`);
? (dataURL += "2017v1")
: (dataURL += "2018v1");
dataURL += `/Android/${assetListItem.file}`;
if (!args.dryRun || args.checksum)
try {
Expand Down Expand Up @@ -82,8 +86,16 @@ const downloadAssets = async (assetList, args, i18n) => {
},
{ concurrency: parseInt(args.batchSize, 10) }
);

bar.stop();
logUpdate(sprintf(`${i18n.downloadAssets} ${i18n.done}`, outputPath));
if (args.checksum)
logUpdate(
sprintf(`${i18n.checksummingAssets} ${i18n.done}`, outputPath)
);
else
logUpdate(
sprintf(`${i18n.downloadingAssets} ${i18n.done}`, outputPath)
);
logUpdate.done();
}
};
Expand Down
47 changes: 27 additions & 20 deletions src/getAssetList.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,30 @@ const getAssetList = async (args, i18n) => {
let manifestList = [];
logUpdate(args.latest ? i18n.getLatestManifest : i18n.getManifestList);
const res = await fetchWithRetry(
`https://api.matsurihi.me/mltd/v1/zh/version/${
args.latest ? "latest" : "assets"
}`
"https://api.matsurihi.me/mltd/v1/zh/version/" +
`${args.latest ? "latest" : "assets"}`
);
if (!args.latest) {
(await res.json()).forEach(manifest => {
let dataURL = `https://d3k5923sb1sy5k.cloudfront.net/${manifest.version}/production/`;
manifest.version < 70000
? (dataURL += "2017v1")
: (dataURL += "2018v1");
let dataURL = "https://d3k5923sb1sy5k.cloudfront.net/";
dataURL += `${manifest.version}/production/`;
dataURL += manifest.version < 70000 ? "2017v1" : "2018v1";
dataURL += `/Android/${manifest.indexName}`;
manifestList.push({ ...manifest, dataURL });
manifestList.push({
...manifest,
dataURL
});
});
} else {
const manifest = (await res.json()).res;
let dataURL = `https://d3k5923sb1sy5k.cloudfront.net/${manifest.version}/production/`;
manifest.version < 70000
? (dataURL += "2017v1")
: (dataURL += "2018v1");
let dataURL = "https://d3k5923sb1sy5k.cloudfront.net/";
dataURL += `${manifest.version}/production/`;
dataURL += manifest.version < 70000 ? "2017v1" : "2018v1";
dataURL += `/Android/${manifest.indexName}`;
manifestList.push({ ...manifest, dataURL });
manifestList.push({
...manifest,
dataURL
});
}
logUpdate(
`${args.latest ? i18n.getLatestManifest : i18n.getManifestList} ${
Expand All @@ -43,15 +46,14 @@ const getAssetList = async (args, i18n) => {
);
logUpdate.done();

logUpdate(i18n.downloadManifest);
let downloaded;
if (args.checksum)
try {
downloaded = await (
await import("fs/promises")
).readdir(args.outputPath);
manifestList = manifestList.filter(manifest =>
downloaded.includes(manifest)
downloaded.includes(manifest.version.toString())
);
} catch (e) {
if (e.code === "EACCES") {
Expand All @@ -60,12 +62,14 @@ const getAssetList = async (args, i18n) => {
}
manifestList = [];
}

logUpdate(i18n.downloadingManifest);
const bar = new SingleBar(
{
clearOnComplete: true,
format: `${chalk.red(
"{bar}"
)} {file} (asset {version}) | {value}/{total}`
format:
chalk.red("{bar}") +
" {file} (asset {version}) | {value}/{total}"
},
Presets.shades_classic
);
Expand Down Expand Up @@ -97,10 +101,13 @@ const getAssetList = async (args, i18n) => {
version: manifest.version
});
},
{ concurrency: parseInt(args.batchSize, 10) }
{
concurrency: parseInt(args.batchSize, 10)
}
);

if (!args.latest) bar.stop();
logUpdate(`${i18n.downloadManifest} ${i18n.done}`);
logUpdate(`${i18n.downloadingManifest} ${i18n.done}`);
logUpdate.done();
return assetList;
};
Expand Down
47 changes: 24 additions & 23 deletions src/i18n/en-US.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
{
"checksumFailed": "checksum failed while downloading %s.",
"checksumComplete": "checksum completed.",
"cliBatchSize": "batch size of downloading file, default CPU cores count",
"cliChecksum": "don't download any file and check all downloaded files",
"cliDescription": "asset downloader for THE IDOLM@STER MILLION LIVE! Theater Days (MLTD)",
"cliDryRun": "don't download to disk. This may be helpful to test your network speed ¯\\_(ツ)_/¯",
"cliHelp": "display this help",
"cliLatest": "skip all interactive prompts and download latest assets directly",
"cliOutputPath": "downloaded path",
"cliUsage": "[options]",
"cliVersion": "output the version number",
"confirmDownload": "downloading selected assets, proceed?",
"done": "done",
"downloadAssets": "downloading assets to %s ...",
"downloadComplete": "download completed.",
"downloadManifest": "downloading manifests ...",
"downloadMessage": "choose assets to download",
"eaccesText": "permission denied: accessing %s",
"getLatestManifest": "getting latest manifest from https://api.matsurihi.me ...",
"getManifestList": "getting manifest list from https://api.matsurihi.me ...",
"file": "files",
"sigintText": "aborted by user."
{
"checksumFailed": "checksum failed while downloading %s.",
"checksumComplete": "checksum completed.",
"checksummingAssets": "checksumming assets in %s ...",
"cliBatchSize": "batch size of downloading file, default CPU cores count",
"cliChecksum": "don't download any file and check all downloaded files",
"cliDescription": "asset downloader for THE IDOLM@STER MILLION LIVE! Theater Days (MLTD)",
"cliDryRun": "don't download to disk. This may be helpful to test your network speed ¯\\_(ツ)_/¯",
"cliHelp": "display this help",
"cliLatest": "skip all interactive prompts and download latest assets directly",
"cliOutputPath": "downloaded path",
"cliUsage": "[options]",
"cliVersion": "output the version number",
"confirmDownload": "downloading selected assets, proceed?",
"done": "done",
"downloadComplete": "download completed.",
"downloadingAssets": "downloading assets to %s ...",
"downloadingManifest": "downloading manifests ...",
"downloadMessage": "choose assets to download",
"eaccesText": "permission denied: accessing %s",
"getLatestManifest": "getting latest manifest from https://api.matsurihi.me ...",
"getManifestList": "getting manifest list from https://api.matsurihi.me ...",
"file": "files",
"sigintText": "aborted by user."
}
47 changes: 24 additions & 23 deletions src/i18n/zh-TW.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
{
"checksumFailed": "下載檔案 %s 時校驗失敗。",
"checksumComplete": "檔案校驗完成。",
"cliBatchSize": "一次要下載幾個檔案,預設為CPU核心數",
"cliChecksum": "不下載任何檔案,只檢查已下載的檔案是否正確",
"cliDescription": "偶像大師 百萬人演唱會! 劇場時光 (MLTD) 遊戲資源下載器",
"cliDryRun": "不要把檔案存到硬碟裡。這個功能可能在測網速的時候有用 ¯\\_(ツ)_/¯",
"cliHelp": "顯示這個說明",
"cliLatest": "跳過所有選項並直接下載最新版遊戲資源",
"cliOutputPath": "存檔路徑",
"cliUsage": "[選項]",
"cliVersion": "印出版本號",
"confirmDownload": "是否要開始下載所選的資源?",
"done": "完成",
"downloadAssets": "正在下載檔案到 %s ...",
"downloadComplete": "下載完成。",
"downloadManifest": "正在下載資源列表 ...",
"downloadMessage": "選擇要下載的資源版本",
"eaccesText": "沒有權限存取: %s",
"getLatestManifest": "正在從 https://api.matsurihi.me 取得最新版資源列表 ...",
"getManifestList": "正在從 https://api.matsurihi.me 取得資源列表 ...",
"file": "個檔案",
"sigintText": "被使用者中斷。"
{
"checksumFailed": "下載檔案 %s 時檢查失敗。",
"checksumComplete": "檔案檢查完成。",
"checksummingAssets": "正在檢查 %s 裡的檔案 ...",
"cliBatchSize": "一次要下載幾個檔案,預設為CPU核心數",
"cliChecksum": "不下載任何檔案,只檢查已下載的檔案是否正確",
"cliDescription": "偶像大師 百萬人演唱會! 劇場時光 (MLTD) 遊戲資源下載器",
"cliDryRun": "不要把檔案存到硬碟裡。這個功能可能在測網速的時候有用 ¯\\_(ツ)_/¯",
"cliHelp": "顯示這個說明",
"cliLatest": "跳過所有選項並直接下載最新版遊戲資源",
"cliOutputPath": "存檔路徑",
"cliUsage": "[選項]",
"cliVersion": "印出版本號",
"confirmDownload": "是否要開始下載所選的資源?",
"done": "完成",
"downloadComplete": "下載完成。",
"downloadingAssets": "正在下載檔案到 %s ...",
"downloadingManifest": "正在下載資源列表 ...",
"downloadMessage": "選擇要下載的資源版本",
"eaccesText": "沒有權限存取 %s 。",
"getLatestManifest": "正在從 https://api.matsurihi.me 取得最新版資源列表 ...",
"getManifestList": "正在從 https://api.matsurihi.me 取得資源列表 ...",
"file": "個檔案",
"sigintText": "被使用者中斷。"
}
Loading

0 comments on commit fc4e2e4

Please sign in to comment.