File size: 578 Bytes
21bc372
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import yt_dlp
import os
import uuid
from akn.utils.logger import LOGS

def all_one_downloader(url: str, download_path: str = "./downloads/"):
    unique_id = str(uuid.uuid4())

    ydl_opts = {
        "outtmpl": os.path.join(download_path, f"{unique_id}.%(ext)s"),
        "quiet": True,
        "noplaylist": True,
        "format": "best",
    }

    with yt_dlp.YoutubeDL(ydl_opts) as ydl:
        info = ydl.extract_info(url, download=True)
        video_title = info.get("title", "Video")
        video_path = ydl.prepare_filename(info)

    return video_path, video_title