init
This commit is contained in:
19
python/ytdl/download_video.py
Normal file
19
python/ytdl/download_video.py
Normal file
@ -0,0 +1,19 @@
|
||||
import yt_dlp
|
||||
|
||||
def download_video(url, path='.'):
|
||||
# Options for downloading the best quality video and audio
|
||||
ydl_opts = {
|
||||
'format': 'bestvideo+bestaudio/best', # Selects the best quality of video and audio available
|
||||
'outtmpl': f'{path}/%(title)s.%(ext)s', # Template for output file name
|
||||
}
|
||||
|
||||
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
||||
try:
|
||||
ydl.download([url])
|
||||
print("Video downloaded successfully.")
|
||||
except Exception as e:
|
||||
print(f"An error occurred while downloading the video: {e}")
|
||||
|
||||
# Example usage
|
||||
video_url = input("Video URL: ")
|
||||
download_video(video_url)
|
||||
Reference in New Issue
Block a user