Skip to content

Instantly share code, notes, and snippets.

@Askill
Created February 14, 2026 09:23
Show Gist options
  • Select an option

  • Save Askill/e3812fee3dad0b62dd10761fdef33cff to your computer and use it in GitHub Desktop.

Select an option

Save Askill/e3812fee3dad0b62dd10761fdef33cff to your computer and use it in GitHub Desktop.
import subprocess
import sys
from pathlib import Path
if len(sys.argv) != 2:
print("Usage: python download_youtube.py <URL | playlist | channel | txt file>")
sys.exit(1)
source = sys.argv[1]
cmd = [
"python -m yt_dlp",
"-f", "bv*+ba/b", # best video + best audio
"--merge-output-format", "mkv",
"--embed-metadata",
"--embed-thumbnail",
"--add-metadata",
"--yes-playlist",
"--ignore-errors",
"--ffmpeg-location \"C:\dev\ffmpeg-8.0.1\bin\"",
"-o", "./yt_downloads/%(uploader)s/%(title)s.%(ext)s",
]
if Path(source).suffix == ".txt":
cmd.extend(["-a", source])
else:
cmd.append(source)
print(" ".join(cmd))
subprocess.run(cmd, check=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment