-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
36 lines (28 loc) · 775 Bytes
/
main.py
File metadata and controls
36 lines (28 loc) · 775 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
#!/usr/bin/env python3
import sys
import os
import subprocess
# === CONFIG ===
DOWNLOAD_DIR = "/path/to/your/download/folder" # Change this
# === MAIN LOGIC ===
def main():
if len(sys.argv) != 2:
print("Usage: download_youtube.py <YouTube-URL>")
sys.exit(1)
url = sys.argv[1]
# Change to target directory
os.chdir(DOWNLOAD_DIR)
# Run yt-dlp with mp4 conversion
command = [
"yt-dlp",
"-f", "mp4", # Prefer mp4 if available
"--recode", "mp4", # Force recode if not already mp4
url
]
try:
subprocess.run(command, check=True)
print("Download complete.")
except subprocess.CalledProcessError:
print("Error: yt-dlp failed.")
if __name__ == "__main__":
main()