From c90814902d52b35b61e35e2ed6a58de81e607ffb Mon Sep 17 00:00:00 2001 From: Dantenerosas Date: Sun, 1 Oct 2023 03:18:00 +0300 Subject: [PATCH] added resolution parameter, minor fixes --- src/web/main.py | 6 +++++- src/web/schemes/submit.py | 11 +++++++++++ src/web/templates/index.html | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/web/main.py b/src/web/main.py index 6bef8c0..d5dc204 100644 --- a/src/web/main.py +++ b/src/web/main.py @@ -102,7 +102,11 @@ async def get_url_for_download_video(request: Request, data: SubmitIn = Depends( body = [ { "link": data.link, - "format": f"bestvideo[ext={data.video_format.value}]+bestaudio[ext={data.audio_format.value}]/best[ext={data.video_format.value}]/best", + "format": f"bv[width={data.resolution.value}][ext={data.video_format.value}]+ba[ext={data.audio_format.value}]/" + f"bv[width={data.resolution.value}][ext=mp4]+ba[ext=m4a]/" + f"bv[width={data.resolution.value}][ext=webm]+ba[ext=webm]/" + f"best[ext={data.video_format.value}]/" + f"best[ext!=unknown_video]", "merge_output_format": data.merge_output_format.value, "outtmpl": f"downloads/%(extractor_key)s/%(id)s_%(resolution)s.%(ext)s", }, ] diff --git a/src/web/schemes/submit.py b/src/web/schemes/submit.py index 2f5fcb3..629b69f 100644 --- a/src/web/schemes/submit.py +++ b/src/web/schemes/submit.py @@ -28,6 +28,16 @@ class AudioFormatEnum(Enum): format_wav = "wav" +class ResolutionEnum(Enum): + resolution_240 = "240" + resolution_360 = "360" + resolution_480 = "480" + resolution_720 = "720" + resolution_1080 = "1080" + resolution_2048 = "2048" + resolution_3820 = "3840" + + class MergeOutputFormatEnum(Enum): format_avi = "avi" format_flv = "flv" @@ -42,6 +52,7 @@ class SubmitIn: link: str = Form(...) video_format: VideoFormatEnum = Form(default=MergeOutputFormatEnum.format_webm) audio_format: AudioFormatEnum = Form(default=AudioFormatEnum.format_webm) + resolution: ResolutionEnum = Form(default=ResolutionEnum.resolution_1080) merge_output_format: MergeOutputFormatEnum = Form(default=MergeOutputFormatEnum.format_mkv) diff --git a/src/web/templates/index.html b/src/web/templates/index.html index 9bd7eb0..16c0f74 100644 --- a/src/web/templates/index.html +++ b/src/web/templates/index.html @@ -74,6 +74,7 @@ +