Add --raw flag

Currently only applies to --new on Crunchy
This commit is contained in:
AnimeDL 2025-08-02 10:14:33 -07:00
parent 6920f0ffe9
commit 5c11d942c1
4 changed files with 24 additions and 5 deletions

View file

@ -113,7 +113,7 @@ export default class Crunchy implements ServiceClass {
}
else if(argv.new){
await this.refreshToken();
await this.getNewlyAdded(argv.page);
await this.getNewlyAdded(argv.page, argv.raw);
}
else if(argv.search && argv.search.length > 2){
await this.refreshToken();
@ -1028,7 +1028,7 @@ export default class Crunchy implements ServiceClass {
}
}
public async getNewlyAdded(page?: number){
public async getNewlyAdded(page?: number, raw: boolean = false) {
if(!this.token.access_token){
console.error('Authentication required!');
return;
@ -1042,7 +1042,7 @@ export default class Crunchy implements ServiceClass {
};
const newlyAddedParams = new URLSearchParams({
sort_by: 'newly_added',
n: '25',
n: '50',
start: (page ? (page-1)*25 : 0).toString(),
}).toString();
const newlyAddedReq = await this.req.getData(`${api.browse}?${newlyAddedParams}`, newlyAddedReqOpts);
@ -1051,6 +1051,12 @@ export default class Crunchy implements ServiceClass {
return;
}
const newlyAddedResults = await newlyAddedReq.res.json();
if (raw) {
console.info(JSON.stringify(newlyAddedResults, null, 2));
return;
}
console.info('Newly added:');
for(const i of newlyAddedResults.items){
await this.logObject(i, 2);

View file

@ -69,7 +69,8 @@ let argvC: {
fileName: string;
numbers: number;
nosess: string;
debug: boolean | undefined;
debug: boolean | undefined;
raw: boolean;
nocleanup: boolean;
help: boolean | undefined;
service: 'crunchy' | 'hidive' | 'ao' | 'adn';

View file

@ -831,6 +831,18 @@ const args: TAppArg<boolean|number|string|unknown[]>[] = [
default: false
}
},
{
name: 'raw',
describe: 'If true, the tool will output the raw data from the API (Where applicable, the feature is a WIP)',
docDescribe: true,
group: 'util',
service: ['all'],
type: 'boolean',
usage: '',
default: {
default: false
}
},
{
name: 'force',
describe: 'Set the default option for the \'alredy exists\' prompt',

View file

@ -1,7 +1,7 @@
{
"name": "multi-downloader-nx",
"short_name": "aniDL",
"version": "5.5.1",
"version": "5.5.2",
"description": "Downloader for Crunchyroll, Hidive, AnimeOnegai, and AnimationDigitalNetwork with CLI and GUI",
"keywords": [
"download",