Skip to content

Commit

Permalink
Shared function
Browse files Browse the repository at this point in the history
  • Loading branch information
JrMasterModelBuilder committed May 2, 2024
1 parent 20b8d13 commit 0ac62f1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 22 deletions.
10 changes: 2 additions & 8 deletions bin/download-flash-cn.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {file as hashFile} from '../util/hash.mjs';
import {read as packaged} from '../util/packages.mjs';
import {walk} from '../util/util.mjs';
import {download} from '../util/download.mjs';
import {packageUrl} from '../util/ia.mjs';

async function main() {
// eslint-disable-next-line no-process-env
Expand Down Expand Up @@ -133,21 +134,14 @@ async function main() {
size,
hashes: {sha256, sha1, md5}
} of changed) {
console.log(name);
doc.push({
name,
file,
size,
sha256,
sha1,
md5,
source: [
`https://archive.org/download/shockpkg_packages_${sha256[0]}`,
sha256.substr(0, 2),
sha256.substr(2, 2),
sha256.substr(4),
file
].join('/'),
source: packageUrl(sha256, file),
metadata: {
date
}
Expand Down
9 changes: 2 additions & 7 deletions bin/download-harman-air-runtime.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {mkdir, stat} from 'node:fs/promises';
import {file as hashFile} from '../util/hash.mjs';
import {runtimes, userAgent} from '../util/harman.mjs';
import {download} from '../util/download.mjs';
import {packageUrl} from '../util/ia.mjs';

async function main() {
// eslint-disable-next-line no-process-env
Expand Down Expand Up @@ -116,13 +117,7 @@ async function main() {
sha256,
sha1,
md5,
source: [
`https://archive.org/download/shockpkg_packages_${sha256[0]}`,
sha256.substr(0, 2),
sha256.substr(2, 2),
sha256.substr(4),
file
].join('/')
source: packageUrl(sha256, file)
});
}
console.log(JSON.stringify(doc, null, '\t'));
Expand Down
9 changes: 2 additions & 7 deletions bin/download-harman-air-sdk.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {mkdir, stat} from 'node:fs/promises';
import {file as hashFile} from '../util/hash.mjs';
import {sdks, cookies, userAgent} from '../util/harman.mjs';
import {download} from '../util/download.mjs';
import {packageUrl} from '../util/ia.mjs';

async function main() {
// eslint-disable-next-line no-process-env
Expand Down Expand Up @@ -120,13 +121,7 @@ async function main() {
sha256,
sha1,
md5,
source: [
`https://archive.org/download/shockpkg_packages_${sha256[0]}`,
sha256.substr(0, 2),
sha256.substr(2, 2),
sha256.substr(4),
file
].join('/')
source: packageUrl(sha256, file)
});
}
console.log(JSON.stringify(doc, null, '\t'));
Expand Down
9 changes: 9 additions & 0 deletions util/ia.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export function packageUrl(sha256, file) {
return [
`https://archive.org/download/shockpkg_packages_${sha256[0]}`,
sha256.substr(0, 2),
sha256.substr(2, 2),
sha256.substr(4),
encodeURIComponent(file)
].join('/');
}

0 comments on commit 0ac62f1

Please sign in to comment.