Download X/Twitter Video
Download video from X/Twitter posts via yt-dlp.
Prerequisites
yt-dlp:brew install yt-dlp
Usage
python3 scripts/download_x_video.py "https://x.com/user/status/123/video/1" [/output/dir]
Prints the downloaded file path to stdout.
How It Works
- Uses yt-dlp with
--print after_move:filepathfor reliable path detection - Handles Twitter's HLS streaming format (fragmented MP4)
- Output template:
x_video_<tweet_id>.<ext>in the specified directory
Troubleshooting
yt-dlp auth errors
If Twitter requires login, yt-dlp may need cookies:
yt-dlp --cookies-from-browser chrome "https://x.com/..."