You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
609 B
Python
28 lines
609 B
Python
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: ")
|
|
|
|
|
|
|
|
|
|
|