V1.0 working version

This commit is contained in:
Patryk Mazur
2026-04-22 01:00:59 +02:00
parent 5a9fba903d
commit 474793bcaa
5 changed files with 76 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
import os
import yt_dlp
def download_video(yt_url: str) -> str:
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
DOWNLOADS = os.path.join(BASE_DIR, "downloads")
ydl_opts = {
'format': 'bestvideo+bestaudio/best',
'merge_output_format': 'mp4',
'outtmpl': f'{DOWNLOADS}/%(title)s.%(ext)s',
}
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
os.makedirs(DOWNLOADS, exist_ok=True)
info = ydl.extract_info(yt_url, download=True)
filename = ydl.prepare_filename(info)
return filename