twitter-downloader

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

X / Twitter Video Downloader (twmd)

X / Twitter 视频下载器(twmd)

Download videos from individual X (Twitter) posts using
twmd
, an API-less Go-based downloader.
使用
twmd
这款基于Go语言开发、无需API的下载工具,从单个X(原Twitter)帖子下载视频。

When to Use

使用场景

Use this skill when users:
  • Provide an X/Twitter post URL and want to download its video
  • Mention "下载推文视频", "download Twitter video", "save X video", "下载 X 视频"
  • Share a link like
    https://x.com/username/status/123456
    or
    https://twitter.com/username/status/123456
当用户出现以下情况时,可使用此技能:
  • 提供X/Twitter帖子URL并希望下载其中的视频
  • 提及“下载推文视频”“download Twitter video”“save X video”“下载 X 视频”等内容
  • 分享类似
    https://x.com/username/status/123456
    https://twitter.com/username/status/123456
    的链接

Usage

使用方法

Basic Syntax

基本语法

bash
python scripts/download_tweet.py "TWEET_URL" [OPTIONS]
bash
python scripts/download_tweet.py "TWEET_URL" [OPTIONS]

Common Scenarios

常见场景

Download video from a tweet:
bash
python scripts/download_tweet.py "https://x.com/username/status/1234567890"
Specify output directory:
bash
python scripts/download_tweet.py "https://x.com/username/status/1234567890" -o ~/Downloads/twitter
Download in specific quality:
bash
python scripts/download_tweet.py "https://x.com/username/status/1234567890" -q 720
Print video URL without downloading:
bash
python scripts/download_tweet.py "https://x.com/username/status/1234567890" --url-only
下载推文视频:
bash
python scripts/download_tweet.py "https://x.com/username/status/1234567890"
指定输出目录:
bash
python scripts/download_tweet.py "https://x.com/username/status/1234567890" -o ~/Downloads/twitter
指定画质下载:
bash
python scripts/download_tweet.py "https://x.com/username/status/1234567890" -q 720
仅打印视频URL不下载:
bash
python scripts/download_tweet.py "https://x.com/username/status/1234567890" --url-only

Arguments

参数说明

ArgumentDescriptionDefault
url
X/Twitter post URL (required)-
-o, --output
Output directoryCurrent directory
-q, --quality
Video quality:
best
,
1080
,
720
,
480
best
--url-only
Print video direct URL without downloadingFalse
--cookies
Path to cookies file (for private/restricted content)None
参数描述默认值
url
X/Twitter帖子URL(必填)-
-o, --output
输出目录当前目录
-q, --quality
视频画质选项:
best
1080
720
480
best
--url-only
仅打印视频直链,不执行下载False
--cookies
Cookies文件路径(用于访问私密/受限内容)None

Dependencies

依赖安装

bash
pip install yt-dlp
No additional setup needed.
yt-dlp
handles public X/Twitter posts without cookies or API keys.
bash
pip install yt-dlp
无需额外配置。
yt-dlp
可直接处理公开的X/Twitter帖子,无需Cookies或API密钥。

Output Structure

输出结构

OutputDir/
└── <tweet_id>.mp4     # Downloaded video file
twmd
names files by tweet ID. The script reports the file path after download.
OutputDir/
└── <tweet_id>.mp4     # 下载后的视频文件
twmd
以推文ID作为文件名。下载完成后,脚本会返回文件路径。

Authentication (Optional)

身份验证(可选)

For private accounts or login-gated content, export cookies from your browser:
  1. Install a browser extension like "Get cookies.txt LOCALLY"
  2. Log in to X, then export cookies for
    x.com
    as a Netscape-format
    .txt
    file
  3. Pass the file with
    --cookies
    :
bash
python scripts/download_tweet.py "URL" --cookies ~/x-cookies.txt
如需下载私人账号或需登录才能查看的内容,请从浏览器导出Cookies:
  1. 安装浏览器扩展,如“Get cookies.txt LOCALLY”
  2. 登录X账号,导出
    x.com
    的Netscape格式
    .txt
    文件
  3. 通过
    --cookies
    参数传入该文件:
bash
python scripts/download_tweet.py "URL" --cookies ~/x-cookies.txt

Claude Integration

与Claude集成

When user provides an X/Twitter post URL and wants to download its video:
  1. Check if yt-dlp is installed:
    bash
    yt-dlp --version
  2. Install if missing:
    bash
    pip install yt-dlp
  3. Execute download:
    bash
    python twitter-downloader/scripts/download_tweet.py "TWEET_URL" -o ./output
  4. Report the downloaded file to the user with its path and size.
当用户提供X/Twitter帖子URL并希望下载视频时:
  1. 检查yt-dlp是否已安装:
    bash
    yt-dlp --version
  2. 若未安装则执行安装:
    bash
    pip install yt-dlp
  3. 执行下载命令:
    bash
    python twitter-downloader/scripts/download_tweet.py "TWEET_URL" -o ./output
  4. 向用户反馈下载结果,包括文件路径和大小。

Common Issues

常见问题

Q: Download fails with "Unable to extract" error? A: Update yt-dlp first:
pip install -U yt-dlp
— X/Twitter frequently changes its API.
Q: The tweet has no video? A: Try
--url-only
to check what media yt-dlp can find. Image-only tweets will not yield a video URL.
Q: Need to download from a private account? A: Export browser cookies (see Authentication section above) and pass with
--cookies
.
Q: Why not just use youtube-downloader for Twitter URLs? A: You can — yt-dlp handles Twitter URLs too. This skill provides a Twitter-focused interface with cleaner prompts and no unneeded options (playlists, subtitles, etc.).
问:下载时出现“Unable to extract”错误怎么办? 答:先更新yt-dlp:
pip install -U yt-dlp
——X/Twitter经常会更改其API。
问:推文里没有视频? 答:尝试使用
--url-only
参数查看yt-dlp能识别到哪些媒体内容。仅含图片的推文无法获取视频URL。
问:需要从私人账号下载内容? 答:按照上述“身份验证”部分的步骤导出浏览器Cookies,并通过
--cookies
参数传入。
问:为什么不直接用youtube-downloader处理Twitter链接? 答:其实也可以——yt-dlp本身也支持Twitter链接。本技能提供了针对Twitter的专用界面,提示更简洁,且没有多余选项(如播放列表、字幕等)。

References

参考资料