Allow posting directly to /queue. Uses "best" format if not passed.

This commit is contained in:
2021-07-21 11:35:25 -04:00
parent 72daf8e93b
commit 06e84aa164
2 changed files with 9 additions and 3 deletions

View File

@@ -3,8 +3,8 @@ export class UploadDto {
} }
export class QueueDto { export class QueueDto {
format: number; format? = 'best';
url: string; url: string;
title: string; title?: string;
extractor: string; extractor?: string;
} }

View File

@@ -92,6 +92,12 @@ export class WebController {
@Redirect('/') @Redirect('/')
@UsePipes(new ValidationPipe({ transform: true })) @UsePipes(new ValidationPipe({ transform: true }))
async queue(@Body() body: QueueDto) { 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); const job = await this.vidgrabQueue.add('download', body);
// Redirect to main page // Redirect to main page