This little snippet is downloading a whole youtube video to the folder “downloads”.
import yt_dlp
def download_video(url, output_path='downloads'):
ydl_opts = {
'outtmpl': f'{output_path}/%(title)s.%(ext)s',
'format': 'bestvideo+bestaudio/best',
'merge_output_format': 'mp4',
}
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
ydl.download([url])
if __name__ == '__main__':
url = input("Enter YouTube URL: ").strip()
download_video(url)