Skip to main content

MCP server for downloading Douyin videos and extracting text

Project description

抖音无水印视频文本提取 MCP 服务器

PyPI version Python version

一个基于 Model Context Protocol (MCP) 的服务器,可以从抖音分享链接下载无水印视频,提取音频并转换为文本。

功能特性

  • 🎵 从抖音分享链接获取无水印视频
  • 🎧 自动提取视频音频
  • 📝 使用AI语音识别提取文本内容
  • 🧹 自动清理中间临时文件
  • 🔧 支持自定义API配置, API 默认使用 SiliconFlow API

安装

使用 uvx 安装(推荐)

uvx douyin-mcp-server

使用 pip 安装

pip install douyin-mcp-server

使用方法

1. 启动服务器

douyin-mcp-server

2. 在Claude Desktop中配置

在你的 claude_desktop_config.json 中添加:

{
  "mcpServers": {
    "douyin-mcp": {
      "command": "uvx",
      "args": ["douyin-mcp-server"],
      "env": {
        "DOUYIN_API_KEY": "your-api-key-here"
      }
    }
  }
}

3. 使用MCP工具

获取无水印下载链接

使用 get_douyin_download_link 工具:

# 在Claude中使用,无需API密钥
get_douyin_download_link("https://v.douyin.com/xxx")

提取视频文本

使用 extract_douyin_text 工具(需要设置环境变量 DOUYIN_API_KEY):

# 在Claude中使用
extract_douyin_text("https://v.douyin.com/xxx")

解析视频信息

使用 parse_douyin_video_info 工具:

parse_douyin_video_info("https://v.douyin.com/xxx")

API 配置

默认配置

服务器默认使用 SiliconFlow API

  • API URL: https://api.siliconflow.cn/v1/audio/transcriptions
  • 模型: FunAudioLLM/SenseVoiceSmall

自定义配置

你可以自定义API配置:

extract_douyin_text(
    share_link="your-douyin-link",
    api_base_url="https://your-custom-api.com/transcriptions",
    model="your-custom-model"
)

环境变量配置

在Claude Desktop的配置文件中设置环境变量:

{
  "mcpServers": {
    "douyin-mcp": {
      "command": "uvx",
      "args": ["douyin-mcp-server"],
      "env": {
        "DOUYIN_API_KEY": "sk-your-api-key-here"
      }
    }
  }
}

工具说明

get_douyin_download_link

获取抖音视频的无水印下载链接,无需API密钥。

参数:

  • share_link: 抖音分享链接或包含链接的文本

返回:

  • 包含下载链接和视频信息的JSON格式数据

extract_douyin_text

完整的文本提取工具,执行以下步骤:

  1. 解析抖音分享链接
  2. 下载无水印视频
  3. 提取音频
  4. 转换音频为文本
  5. 清理临时文件

参数:

  • share_link: 抖音分享链接或包含链接的文本
  • api_base_url: API基础URL(可选)
  • model: 语音识别模型(可选)

环境变量:

  • DOUYIN_API_KEY: 语音识别API密钥(必需)

parse_douyin_video_info

仅解析视频基本信息,不下载视频。

参数:

  • share_link: 抖音分享链接

资源访问

  • douyin://video/{video_id}: 通过视频ID获取详细信息

依赖要求

  • Python 3.8+
  • ffmpeg(系统需要安装ffmpeg)
  • requests
  • ffmpeg-python
  • tqdm
  • mcp

安装 ffmpeg

macOS

brew install ffmpeg

Ubuntu/Debian

sudo apt update
sudo apt install ffmpeg

Windows

下载并安装 ffmpeg

开发

本地开发

git clone https://github.com/yzfly/douyin-mcp-server.git
cd douyin-mcp-server
pip install -e .

运行测试

python -m douyin_mcp_server.server

注意事项

  • 确保系统已安装 ffmpeg
  • 需要在环境变量中设置有效的语音识别API密钥 DOUYIN_API_KEY
  • 获取下载链接功能无需API密钥
  • 中间文件会自动清理,不会占用磁盘空间
  • 支持大部分抖音视频格式

许可证

MIT License

作者

贡献

欢迎提交 Issue 和 Pull Request!

更新日志

v1.0.0

  • 初始版本
  • 支持抖音视频文本提取
  • 支持获取无水印视频下载链接
  • 从环境变量读取API密钥
  • 自动清理临时文件
  • 支持自定义API配置

v1.1.0

  • 修复提取视频时文件名过长的bug

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

douyin_mcp_server-1.1.0.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

douyin_mcp_server-1.1.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file douyin_mcp_server-1.1.0.tar.gz.

File metadata

  • Download URL: douyin_mcp_server-1.1.0.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for douyin_mcp_server-1.1.0.tar.gz
Algorithm Hash digest
SHA256 f593fb80de0f14cb348dfcd8c2d825090bc2a9ff503b53dbd0b326818cd51a03
MD5 ca4dc883f635b13b45e1b0ad0d459b5c
BLAKE2b-256 81fe75b6bc21ca4c9ec457383dd104396dd587f9008299c5b2ee6fffe1344a76

See more details on using hashes here.

File details

Details for the file douyin_mcp_server-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for douyin_mcp_server-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c99c10fb61d563500350634e88a07975a17f95f80f672a414e7282575e8cd54b
MD5 a115b30eb081f8b15e1f2a9aabcc122a
BLAKE2b-256 756f4f86c8e78406449c0063b6caaae4d471ec353e51c8d8d0c217adbf597618

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page