Skip to content

Commit 7828351

Browse files
committed
ytd
1 parent b6db5f5 commit 7828351

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

youtube/ytd.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import sys
2+
from pytube import YouTube
3+
4+
# Check if URL is passed as an argument
5+
if len(sys.argv) != 2:
6+
print("Usage: python3 ytd.py <youtube_url>")
7+
sys.exit(1)
8+
9+
# Store the URL
10+
url = sys.argv[1]
11+
12+
try:
13+
# Create a YouTube object with the URL
14+
yt = YouTube(url)
15+
16+
# Get the highest resolution stream available
17+
stream = yt.streams.get_highest_resolution()
18+
19+
# Download the video
20+
print(f"Downloading {yt.title}...")
21+
stream.download()
22+
print("Download completed!")
23+
except Exception as e:
24+
print(f"An error occurred: {e}")
25+
sys.exit(1)

0 commit comments

Comments
 (0)