-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmy_ytubedownloader.py
More file actions
49 lines (27 loc) · 897 Bytes
/
my_ytubedownloader.py
File metadata and controls
49 lines (27 loc) · 897 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import yt_dlp
import os
while True:
def download_video(link):
folder_name = "Yt_dow"
if not os.path.exists(folder_name):
os.makedirs(folder_name)
print(f" Created folder: {folder_name}")
try:
ydl_opts = {
'format': 'best',
'outtmpl': f'{folder_name}/%(title)s.%(ext)s',
'noplaylist': True,
}
print(f" Accessing the video...")
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
ydl.download([link])
print(f"\nDownload complete! Check the '{folder_name}' folder.")
except Exception as e:
print(f" An error occurred: {e}")
if __name__ == "__main__":
print("--- Python YouTube Downloader ---")
url = input(" Paste the YouTube URL here: ").strip()
if url:
download_video(url)
else:
print("Somthing went wrong Please try again!")