mirror of
https://github.com/anidl/multi-downloader-nx.git
synced 2026-01-11 12:00:22 +00:00
Some checks are pending
auto-documentation / documentation (push) Waiting to run
build and push docker image / build-node (push) Waiting to run
Style and build test / tsc (push) Waiting to run
Style and build test / eslint (push) Blocked by required conditions
Style and build test / prettier (push) Blocked by required conditions
Style and build test / build-test-windows-arm64 (push) Blocked by required conditions
Style and build test / build-test-linux-arm64 (push) Blocked by required conditions
Style and build test / build-test-macos-arm64 (push) Blocked by required conditions
Style and build test / build-test-windows-x64 (push) Blocked by required conditions
Style and build test / build-test-linux-x64 (push) Blocked by required conditions
Style and build test / build-test-macos-x64 (push) Blocked by required conditions
74 lines
2.2 KiB
TypeScript
74 lines
2.2 KiB
TypeScript
import { console } from './modules/log';
|
|
import { appArgv, overrideArguments } from './modules/module.app-args';
|
|
import * as yamlCfg from './modules/module.cfg-loader';
|
|
import { makeCommand, addToArchive } from './modules/module.downloadArchive';
|
|
import Crunchy from './crunchy';
|
|
import Hidive from './hidive';
|
|
import ADN from './adn';
|
|
|
|
import update from './modules/module.updater';
|
|
|
|
const SERVICES: Record<string, any> = {
|
|
crunchy: Crunchy,
|
|
hidive: Hidive,
|
|
adn: ADN
|
|
};
|
|
|
|
(async () => {
|
|
const cfg = yamlCfg.loadCfg();
|
|
const argv = appArgv(cfg.cli);
|
|
if (!argv.skipUpdate) await update(argv.update);
|
|
|
|
if (argv.all && argv.but) {
|
|
console.error('--all and --but exclude each other!');
|
|
return;
|
|
}
|
|
|
|
if (argv.addArchive) {
|
|
if (argv.service === 'crunchy') {
|
|
if (argv.s === undefined && argv.series === undefined) return console.error('`-s` or `--srz` not found');
|
|
if (argv.s && argv.series) return console.error('Both `-s` and `--srz` found');
|
|
addToArchive(
|
|
{
|
|
service: 'crunchy',
|
|
type: argv.s === undefined ? 'srz' : 's'
|
|
},
|
|
(argv.s === undefined ? argv.series : argv.s) as string
|
|
);
|
|
console.info('Added %s to the downloadArchive list', argv.s === undefined ? argv.series : argv.s);
|
|
} else if (argv.service === 'hidive') {
|
|
if (argv.s === undefined) return console.error('`-s` not found');
|
|
addToArchive(
|
|
{
|
|
service: 'hidive',
|
|
//type: argv.s === undefined ? 'srz' : 's'
|
|
type: 's'
|
|
},
|
|
(argv.s === undefined ? argv.series : argv.s) as string
|
|
);
|
|
console.info('Added %s to the downloadArchive list', argv.s === undefined ? argv.series : argv.s);
|
|
}
|
|
} else if (argv.downloadArchive && argv.service) {
|
|
const ids = makeCommand(argv.service);
|
|
for (const id of ids) {
|
|
overrideArguments(cfg.cli, id);
|
|
const Service = SERVICES[argv.service];
|
|
if (!Service) {
|
|
console.error('Unknown service:', argv.service);
|
|
process.exit(1);
|
|
}
|
|
|
|
const service = new Service();
|
|
await service.cli();
|
|
}
|
|
} else if (argv.service) {
|
|
const Service = SERVICES[argv.service];
|
|
if (!Service) {
|
|
console.error('Unknown service:', argv.service);
|
|
process.exit(1);
|
|
}
|
|
|
|
const service = new Service();
|
|
await service.cli();
|
|
}
|
|
})();
|