Video analysis: download, keyframes, transcripts, thumbnail grids and AI summaries of what's on screen.

0 downloads

dbbasic-video/src/dbbasic_video/download_video.py
Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-video.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-video.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-video.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

danq9 Update README with live PyPI link c32f6df 1 year, 1 month ago History
download_video.py · 1.5 KB · 60 lines
1#!/usr/bin/env python3
2"""
3Download video from YouTube
4"""
5
6import argparse
7import subprocess
8import sys
9
10
11def download_video(url, output="video.mp4", format_spec="bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best"):
12 """Download video using yt-dlp."""
13 print(f"Downloading video from: {url}")
14
15 cmd = [
16 "yt-dlp",
17 "-f", format_spec,
18 "-o", output,
19 url
20 ]
21
22 try:
23 result = subprocess.run(cmd, check=True, capture_output=False)
24 print(f"\nVideo downloaded to: {output}")
25 return output
26 except subprocess.CalledProcessError as e:
27 print(f"Error downloading video: {e}", file=sys.stderr)
28 return None
29 except FileNotFoundError:
30 print("Error: yt-dlp not found. Install with: pip install yt-dlp", file=sys.stderr)
31 return None
32
33
34def main():
35 parser = argparse.ArgumentParser(
36 description="Download video from YouTube"
37 )
38 parser.add_argument(
39 "url",
40 help="YouTube URL"
41 )
42 parser.add_argument(
43 "-o", "--output",
44 default="video.mp4",
45 help="Output filename (default: video.mp4)"
46 )
47 parser.add_argument(
48 "-f", "--format",
49 default="bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best",
50 help="Format specification for yt-dlp"
51 )
52
53 args = parser.parse_args()
54
55 result = download_video(args.url, args.output, args.format)
56 return 0 if result else 1
57
58
59if __name__ == "__main__":
60 sys.exit(main())