mirror of
https://github.com/anidl/multi-downloader-nx.git
synced 2026-05-12 12:50:40 +00:00
CLI Default for GUI & Pnpm update
This commit is contained in:
parent
1e99c80f81
commit
f32e7b19a2
5 changed files with 624 additions and 722 deletions
|
|
@ -1,11 +1,11 @@
|
|||
import { AuthData, CheckTokenResponse, DownloadData, EpisodeListResponse, MessageHandler, ResolveItemsData, SearchData, SearchResponse } from '../../../@types/messageHandler';
|
||||
import Crunchy from '../../../crunchy';
|
||||
import { ArgvType } from '../../../modules/module.app-args';
|
||||
import { buildDefault, getDefault } from '../../../modules/module.args';
|
||||
import { getDefault } from '../../../modules/module.args';
|
||||
import { languages, subtitleLanguagesFilter } from '../../../modules/module.langsData';
|
||||
import WebSocketHandler from '../websocket';
|
||||
import Base from './base';
|
||||
import { console } from '../../../modules/log';
|
||||
import * as yargs from '../../../modules/module.app-args';
|
||||
|
||||
class CrunchyHandler extends Base implements MessageHandler {
|
||||
private crunchy: Crunchy;
|
||||
|
|
@ -88,7 +88,7 @@ class CrunchyHandler extends Base implements MessageHandler {
|
|||
await this.crunchy.refreshToken(true);
|
||||
console.debug(`Got download options: ${JSON.stringify(data)}`);
|
||||
this.setDownloading(true);
|
||||
const _default = buildDefault() as ArgvType;
|
||||
const _default = yargs.appArgv(this.crunchy.cfg.cli, true);
|
||||
const res = await this.crunchy.downloadFromSeriesID(data.id, {
|
||||
dubLang: data.dubLang,
|
||||
e: data.e
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import { AuthData, CheckTokenResponse, EpisodeListResponse, MessageHandler, QueueItem, ResolveItemsData, SearchData, SearchResponse } from '../../../@types/messageHandler';
|
||||
import Funimation from '../../../funi';
|
||||
import { ArgvType } from '../../../modules/module.app-args';
|
||||
import { buildDefault, getDefault } from '../../../modules/module.args';
|
||||
import { getDefault } from '../../../modules/module.args';
|
||||
import { languages, subtitleLanguagesFilter } from '../../../modules/module.langsData';
|
||||
import WebSocketHandler from '../websocket';
|
||||
import Base from './base';
|
||||
import { console } from '../../../modules/log';
|
||||
import * as yargs from '../../../modules/module.app-args';
|
||||
|
||||
class FunimationHandler extends Base implements MessageHandler {
|
||||
private funi: Funimation;
|
||||
|
|
@ -101,7 +101,7 @@ class FunimationHandler extends Base implements MessageHandler {
|
|||
this.setDownloading(true);
|
||||
console.debug(`Got download options: ${JSON.stringify(data)}`);
|
||||
const res = await this.funi.getShow(false, { all: false, but: false, id: parseInt(data.id), e: data.e });
|
||||
const _default = buildDefault() as ArgvType;
|
||||
const _default = yargs.appArgv(this.funi.cfg.cli, true);
|
||||
if (!res.isOk)
|
||||
return this.alertError(res.reason);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,19 +8,19 @@ export type ArgvType = typeof argvC;
|
|||
|
||||
const appArgv = (cfg: {
|
||||
[key: string]: unknown
|
||||
}) => {
|
||||
}, isGUI = false) => {
|
||||
if (argvC)
|
||||
return argvC;
|
||||
yargs(process.argv.slice(2));
|
||||
const argv = getArgv(cfg)
|
||||
const argv = getArgv(cfg, isGUI)
|
||||
.parseSync();
|
||||
argvC = argv;
|
||||
return argv;
|
||||
};
|
||||
|
||||
|
||||
const overrideArguments = (cfg: { [key:string]: unknown }, override: Partial<typeof argvC>) => {
|
||||
const argv = getArgv(cfg).middleware((ar) => {
|
||||
const overrideArguments = (cfg: { [key:string]: unknown }, override: Partial<typeof argvC>, isGUI = false) => {
|
||||
const argv = getArgv(cfg, isGUI).middleware((ar) => {
|
||||
for (const key of Object.keys(override)) {
|
||||
ar[key] = override[key];
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ export {
|
|||
overrideArguments
|
||||
};
|
||||
|
||||
const getArgv = (cfg: { [key:string]: unknown }) => {
|
||||
const getArgv = (cfg: { [key:string]: unknown }, isGUI: boolean) => {
|
||||
const parseDefault = <T = unknown>(key: string, _default: T) : T=> {
|
||||
if (Object.prototype.hasOwnProperty.call(cfg, key)) {
|
||||
return cfg[key] as T;
|
||||
|
|
@ -51,6 +51,7 @@ const getArgv = (cfg: { [key:string]: unknown }) => {
|
|||
const data = args.map(a => {
|
||||
return {
|
||||
...a,
|
||||
demandOption: !isGUI && a.demandOption,
|
||||
group: groups[a.group],
|
||||
default: typeof a.default === 'object' && !Array.isArray(a.default) ?
|
||||
parseDefault((a.default as any).name || a.name, (a.default as any).default) : a.default
|
||||
|
|
@ -66,7 +67,7 @@ const getArgv = (cfg: { [key:string]: unknown }) => {
|
|||
return value;
|
||||
}
|
||||
},
|
||||
choices: item.choices as unknown as Choices
|
||||
choices: item.name === 'service' && isGUI ? undefined : item.choices as unknown as Choices
|
||||
});
|
||||
return argv as unknown as yargs.Argv<typeof argvC>;
|
||||
};
|
||||
|
|
|
|||
22
package.json
22
package.json
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "multi-downloader-nx",
|
||||
"short_name": "aniDL",
|
||||
"version": "3.4.0",
|
||||
"version": "3.4.1",
|
||||
"description": "Download videos from Funimation or Crunchyroll via cli",
|
||||
"keywords": [
|
||||
"download",
|
||||
|
|
@ -36,7 +36,7 @@
|
|||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.21.0",
|
||||
"@babel/core": "^7.21.3",
|
||||
"@babel/plugin-syntax-flow": "^7.18.6",
|
||||
"@babel/plugin-transform-react-jsx": "^7.21.0",
|
||||
"cheerio": "1.0.0-rc.12",
|
||||
|
|
@ -46,16 +46,16 @@
|
|||
"eslint-plugin-import": "^2.27.5",
|
||||
"express": "^4.18.2",
|
||||
"form-data": "^4.0.0",
|
||||
"fs-extra": "^11.1.0",
|
||||
"fs-extra": "^11.1.1",
|
||||
"got": "^11.8.6",
|
||||
"iso-639": "^0.2.2",
|
||||
"log4js": "^6.8.0",
|
||||
"log4js": "^6.9.1",
|
||||
"lookpath": "^1.2.2",
|
||||
"m3u8-parsed": "^1.3.0",
|
||||
"open": "^8.4.2",
|
||||
"sei-helper": "^3.3.0",
|
||||
"typescript-eslint": "0.0.1-alpha.0",
|
||||
"ws": "^8.12.1",
|
||||
"ws": "^8.13.0",
|
||||
"yaml": "^2.2.1",
|
||||
"yargs": "^17.7.1"
|
||||
},
|
||||
|
|
@ -63,17 +63,17 @@
|
|||
"@types/cors": "^2.8.13",
|
||||
"@types/express": "^4.17.17",
|
||||
"@types/fs-extra": "^11.0.1",
|
||||
"@types/node": "^18.14.6",
|
||||
"@types/node": "^18.15.5",
|
||||
"@types/ws": "^8.5.4",
|
||||
"@types/yargs": "^17.0.22",
|
||||
"@typescript-eslint/eslint-plugin": "^5.54.0",
|
||||
"@typescript-eslint/parser": "^5.54.0",
|
||||
"@types/yargs": "^17.0.23",
|
||||
"@typescript-eslint/eslint-plugin": "^5.56.0",
|
||||
"@typescript-eslint/parser": "^5.56.0",
|
||||
"@vercel/webpack-asset-relocator-loader": "^1.7.3",
|
||||
"eslint": "^8.35.0",
|
||||
"eslint": "^8.36.0",
|
||||
"eslint-config-react-app": "^7.0.1",
|
||||
"eslint-plugin-import": "^2.25.4",
|
||||
"eslint-plugin-react": "7.32.2",
|
||||
"pkg": "^5.8.0",
|
||||
"pkg": "^5.8.1",
|
||||
"removeNPMAbsolutePaths": "^3.0.1",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "5.1.0-dev.20230227"
|
||||
|
|
|
|||
1299
pnpm-lock.yaml
1299
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue