From 06e84aa1643ba9beaabfa66fd4977d88bb213cbd Mon Sep 17 00:00:00 2001 From: Ted Kulp Date: Wed, 21 Jul 2021 11:35:25 -0400 Subject: [PATCH] Allow posting directly to /queue. Uses "best" format if not passed. --- src/types.ts | 6 +++--- src/web/web.controller.ts | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/types.ts b/src/types.ts index 135df7e..6f671eb 100644 --- a/src/types.ts +++ b/src/types.ts @@ -3,8 +3,8 @@ export class UploadDto { } export class QueueDto { - format: number; + format? = 'best'; url: string; - title: string; - extractor: string; + title?: string; + extractor?: string; } diff --git a/src/web/web.controller.ts b/src/web/web.controller.ts index 2cad59c..fc0efe4 100644 --- a/src/web/web.controller.ts +++ b/src/web/web.controller.ts @@ -92,6 +92,12 @@ export class WebController { @Redirect('/') @UsePipes(new ValidationPipe({ transform: true })) async queue(@Body() body: QueueDto) { + if (!body.extractor || !body.title) { + const videoInfo = await this.ytdlService.getVideoInfo(body.url); + body.extractor = videoInfo.extractor; + body.title = videoInfo.title; + } + const job = await this.vidgrabQueue.add('download', body); // Redirect to main page