返回 Skill 列表
extension
分类: 内容与媒体无需 API Key

视频高速本地下载

基于 python 的视频高速本地下载 skill,安装后根据指示完成环境配置后,提供视频链接 URL 即可保存 mp4 文件到本地。基本实现所见即所得,支持读取浏览器 cookiee 以应对网站本身拦截。

person作者: tengfeifeifeifeihubModelScope

Video Downloader

Configure and use yt-dlp + aria2 to download online videos as mp4 files at high speed.

Workflow

Step 1: Check what's already available

# Check if yt-dlp is already installed
which yt-dlp 2>/dev/null && yt-dlp --version || echo "yt-dlp not found"

# Check if aria2 is available
which aria2c 2>/dev/null && aria2c --version | head -1 || echo "aria2 not found"

# Check if conda is available
which conda 2>/dev/null && conda --version || echo "conda not found"

Step 2: Install missing dependencies

If conda is available (recommended — provides isolated environment):

# Check if video-dl env exists, create if not
conda info --envs | grep -q video-dl || {
  # Fix macOS permission issue if needed
  sudo chown -R $(whoami):staff ~/.conda 2>/dev/null
  # Accept tos if needed
  conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main 2>/dev/null
  conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r 2>/dev/null
  conda create -n video-dl python=3.11 -y
}

# Install yt-dlp
conda activate video-dl
pip install yt-dlp requests

# Install aria2 (try conda first, fall back to direct download)
conda install -c conda-forge aria2 -y 2>/dev/null || {
  curl -L https://github.com/aria2/aria2/releases/download/release-1.37.0/aria2-1.37.0-macOS-arm64.tar.bz2 -o /tmp/aria2.tar.bz2
  tar -xjf /tmp/aria2.tar.bz2 -C /tmp/
  sudo cp /tmp/aria2-*/aria2c /usr/local/bin/
}

If conda is NOT available (use system Python directly):

# Install yt-dlp via pip
pip3 install yt-dlp requests

# Install aria2
# macOS with Homebrew:
brew install aria2 2>/dev/null || \
  curl -L https://github.com/aria2/aria2/releases/download/release-1.37.0/aria2-1.37.0-macOS-arm64.tar.bz2 -o /tmp/aria2.tar.bz2 && \
  tar -xjf /tmp/aria2.tar.bz2 -C /tmp/ && \
  sudo cp /tmp/aria2-*/aria2c /usr/local/bin/

# Linux:
# sudo apt install aria2 -y   (Debian/Ubuntu)
# sudo yum install aria2 -y   (CentOS/RHEL)

If neither conda nor pip is available, guide the user to install Python first.

Step 3: Download the video

With conda:

conda activate video-dl
yt-dlp \
  --cookies-from-browser chrome \
  --downloader aria2c \
  --concurrent-fragments 16 \
  --merge-output-format mp4 \
  -o "~/Downloads/%(title)s.%(ext)s" \
  "<USER_PROVIDED_URL>"

Without conda:

yt-dlp \
  --cookies-from-browser chrome \
  --downloader aria2c \
  --concurrent-fragments 16 \
  --merge-output-format mp4 \
  -o "~/Downloads/%(title)s.%(ext)s" \
  "<USER_PROVIDED_URL>"

The download command is the same — the only difference is whether you need conda activate first.

Step 4: Verify the result

Confirm the file was downloaded successfully:

ls -lh ~/Downloads/*.mp4 | tail -5

Key parameters explained

| Parameter | Purpose | |-----------|---------| | --cookies-from-browser chrome | Import login session from Chrome — most sites require authentication to access videos | | --downloader aria2c | Use aria2 multi-threaded downloader instead of the built-in one, significantly faster | | --concurrent-fragments 16 | Download 16 segments in parallel for HLS/DASH streams | | --merge-output-format mp4 | Ensure final output is mp4 regardless of source format | | -o "~/Downloads/%(title)s.%(ext)s" | Save to Downloads folder with the video's original title |

Fallback: Download without aria2

If aria2 installation fails, yt-dlp's built-in downloader still works — just slower:

yt-dlp -N 8 --merge-output-format mp4 -o "~/Downloads/%(title)s.%(ext)s" "<URL>"

-N 8 enables 8 concurrent fragments which helps improve speed without aria2.

Troubleshooting

| Error | Cause | Fix | |-------|-------|-----| | HTTP 410 Gone | Site blocks script requests or resource deleted | Add --cookies-from-browser chrome to use login session | | impersonation warning | Site detects bot via TLS fingerprint | pip install "curl-cffi>=0.6" for browser TLS emulation | | Slow download speed | Default downloader is single-threaded | Ensure aria2 is installed and verify --downloader aria2c is set | | SSL certificate errors | Network proxy or VPN interference | Add --no-check-certificates flag | | Download stalls | Connection reset or throttling | Reduce --concurrent-fragments to 8 or try without aria2 | | conda: command not found | Conda not installed or not in PATH | Follow the "without conda" path above | | pip3: command not found | Python not installed | Guide user to install Python first |