import yt_dlp import os def download_video(url): ydl_opts = { 'format': 'bestvideo+bestaudio', 'outtmpl': '/downloads/%(title)s.%(ext)s', 'noplaylist': True, } with yt_dlp.YoutubeDL(ydl_opts) as ydl: info_dict = ydl.extract_info(url, download=True) # Get the file name and path of the downloaded video video_title = info_dict.get("title", "video") video_ext = info_dict.get("ext", "mp4") video_path = f'/downloads/{video_title}.{video_ext}' return video_path URL = input("Insert the url: ")