L’interface est localisée ; les présentations et documents des Skills sont traduits automatiquement par IA dans votre langue. Le code, les commandes, chemins et termes techniques restent en version originale, et le document de l’auteur fait foi.
Explorer les Skills
Productivité · SKILL.md

video-downloader

video-downloader

Universal video downloader supporting multiple platforms (YouTube, Bilibili, TikTok, Douyin, Instagram, Twitter/X). Automatically detects platform and uses best download method.

Independent GitHub snapshot · Automated classification · Original documentation governs

Bbuda-ai / bunny-agentApache-2.0

Documentation de la Skill

GitHub

name: video-downloader description: Universal video downloader supporting multiple platforms (YouTube, Bilibili, TikTok, Douyin, Instagram, Twitter/X). Automatically detects platform and uses best download method.

通用视频下载器

支持多平台视频下载的通用工具,自动识别平台并选择最佳下载方式。

支持的平台

平台URL 特征认证需求
YouTubeyoutube.com, youtu.beCookies 推荐
Bilibilibilibili.com, b23.tv可选(高清需要)
抖音douyin.com无需
TikToktiktok.com无需
Instagraminstagram.comCookies
Twitter/Xtwitter.com, x.com无需
小红书xiaohongshu.comCookies
快手kuaishou.com无需

使用方法

下载视频: [任意平台URL]
Download video from: https://www.bilibili.com/video/BVxxxxx

Instructions

Step 1: 识别平台

VIDEO_URL="[USER_INPUT_URL]"

# 识别平台类型
detect_platform() {
  local url="$1"
  case "$url" in
    *youtube.com*|*youtu.be*)
      echo "youtube"
      ;;
    *bilibili.com*|*b23.tv*)
      echo "bilibili"
      ;;
    *douyin.com*)
      echo "douyin"
      ;;
    *tiktok.com*)
      echo "tiktok"
      ;;
    *instagram.com*)
      echo "instagram"
      ;;
    *twitter.com*|*x.com*)
      echo "twitter"
      ;;
    *xiaohongshu.com*|*xhslink.com*)
      echo "xiaohongshu"
      ;;
    *kuaishou.com*)
      echo "kuaishou"
      ;;
    *)
      echo "unknown"
      ;;
  esac
}

PLATFORM=$(detect_platform "$VIDEO_URL")
echo "检测到平台: $PLATFORM"

Step 2: 配置下载参数

# 创建目录
mkdir -p ./output/downloads ./temp ./config

# 加载 cookies(如果存在)
COOKIES_OPT=""
if [ -f "./config/cookies.txt" ]; then
  COOKIES_OPT="--cookies ./config/cookies.txt"
fi

# 平台特定配置
case "$PLATFORM" in
  youtube)
    # YouTube 需要 cookies 避免 bot 检测
    if [ -z "$COOKIES_OPT" ] && [ -n "$COBALT_API" ]; then
      echo "YouTube: 将使用 Cobalt API"
      USE_COBALT=true
    fi
    ;;
  bilibili)
    # B站通常不需要 cookies,但高清需要
    EXTRA_OPTS="--referer https://www.bilibili.com"
    ;;
  douyin|tiktok)
    # 抖音/TikTok 通常不需要认证
    EXTRA_OPTS=""
    ;;
  instagram)
    # Instagram 需要 cookies
    if [ -z "$COOKIES_OPT" ]; then
      echo "⚠️ Instagram 需要 cookies,请配置 ./config/cookies.txt"
    fi
    ;;
esac

Step 3: 尝试 Cobalt(如果配置)

if [ -n "$COBALT_API" ]; then
  echo "尝试使用 Cobalt API..."
  
  RESPONSE=$(curl -s -X POST "$COBALT_API/api/json" \
    -H "Content-Type: application/json" \
    -d "{\"url\": \"$VIDEO_URL\", \"vQuality\": \"1080\"}")
  
  STATUS=$(echo "$RESPONSE" | python3 -c "import sys,json; print(json.load(sys.stdin).get('status',''))" 2>/dev/null)
  
  if [ "$STATUS" = "stream" ] || [ "$STATUS" = "redirect" ]; then
    DOWNLOAD_URL=$(echo "$RESPONSE" | python3 -c "import sys,json; print(json.load(sys.stdin).get('url',''))")
    VIDEO_ID=$(echo "$VIDEO_URL" | md5sum | cut -c1-12)
    curl -L -o "./output/downloads/${VIDEO_ID}.mp4" "$DOWNLOAD_URL"
    echo "✅ 通过 Cobalt 下载成功"
    exit 0
  fi
  
  echo "Cobalt 失败,回退到 yt-dlp"
fi

Step 4: 使用 yt-dlp 下载

# 检查 yt-dlp
which yt-dlp || { echo "请安装 yt-dlp: brew install yt-dlp"; exit 1; }

# 下载视频
echo "使用 yt-dlp 下载..."
yt-dlp $COOKIES_OPT $EXTRA_OPTS \
  -f "bestvideo[height<=1080]+bestaudio/best[height<=1080]" \
  -o "./output/downloads/%(id)s.%(ext)s" \
  --merge-output-format mp4 \
  --write-info-json \
  "$VIDEO_URL"

if [ $? -eq 0 ]; then
  echo "✅ 下载成功"
  ls -la ./output/downloads/
else
  echo "❌ 下载失败,请检查 URL 或认证配置"
fi

Step 5: 获取视频信息

# 查找下载的文件
DOWNLOADED_FILE=$(ls -t ./output/downloads/*.mp4 2>/dev/null | head -1)
INFO_FILE="${DOWNLOADED_FILE%.mp4}.info.json"

if [ -f "$INFO_FILE" ]; then
  python3 << EOF
import json
with open("$INFO_FILE") as f:
    info = json.load(f)
print(f"""
## 📹 视频信息

**标题**: {info.get('title', 'N/A')}
**时长**: {info.get('duration', 0) // 60}分{info.get('duration', 0) % 60}秒
**平台**: {info.get('extractor', 'N/A')}
**上传者**: {info.get('uploader', 'N/A')}
**文件**: $DOWNLOADED_FILE
""")
EOF
fi

平台特殊说明

YouTube

  • 强烈建议配置 cookies 或使用 Cobalt
  • 支持播放列表下载
  • 支持自动字幕下载

Bilibili

  • 无需登录可下载 480p
  • 登录后可下载 1080p
  • 支持分P视频

抖音

  • 无需登录
  • 自动去水印
  • 支持图集下载

TikTok

  • 无需登录
  • 自动去水印
  • 部分地区可能需要代理

Instagram

  • 需要登录 cookies
  • 支持 Reels/Posts/Stories
  • 私密账号需要关注

错误处理

错误可能原因解决方案
403 Forbidden需要认证配置 cookies
Video unavailable私密/删除检查 URL
Rate limit请求过多等待或换 IP
Bot detectionYouTube 反爬使用 Cobalt

输出

  • 视频文件: ./output/downloads/{video_id}.mp4
  • 信息文件: ./output/downloads/{video_id}.info.json
Skills enregistrées