douyin-mcp-server

repository·main·Indexed 22 days ago

https://github.com/yzfly/douyin-mcp-server

An MCP server for downloading no-watermark Douyin videos and extracting spoken content using AI-powered voice recognition. It provides tools for parsing video metadata, retrieving download links, and transcribing audio via SiliconFlow or Alibaba Cloud DashScope (Qwen-3-ASR-Flash). The package includes a WebUI, a CLI tool for batch processing, and integration support for Claude Desktop and Cherry Studio.

Tokens
4.5K
Snippets
11
Records
32
Agent score
77%

What's inside douyin-mcp-server

  1. Understand Large File Handling for Audio Transcription

    main

    The system automatically handles large audio files that exceed API limits (typically 1 hour or 50MB) using the following workflow:

    1. Detects audio duration and file size.
    2. Uses FFmpeg to split the audio into 9-minute segments.
    3. Calls the API to transcribe each segment sequentially.
    4. Merges all transcribed text results into a single output.
  2. Configure API Key for transcript extraction

    main

    The transcript extraction feature requires a SiliconFlow API key. You must set this as an environment variable named API_KEY before running the extraction commands.

    1. Obtain a key from https://cloud.siliconflow.cn/
    2. Set the environment variable:
    export API_KEY="your-siliconflow-api-key"
  3. Configure the MCP Server for Claude Desktop

    main

    To use this project as an MCP server in Claude Desktop or Cherry Studio, add the following configuration to your MCP settings file.

    Note: You can use a SiliconFlow key via API_KEY or an Alibaba Cloud DashScope key via DASHSCOPE_API_KEY.

    {
      "mcpServers": {
        "douyin-mcp": {
          "command": "uvx",
          "args": ["douyin-mcp-server"],
          "env": {
            "API_KEY": "sk-xxxxxxxxxxxxxxxx"
          }
        }
      }
    }
  4. Install and Run the WebUI

    main

    The WebUI is the recommended way for general users to interact with the service via a browser.

    Prerequisites

    • uv (Python package manager)
    • Python 3.10+
    • FFmpeg (for audio/video processing)

    Setup Steps

    1. Clone the repository:
      git clone https://github.com/yzfly/douyin-mcp-server.git
      cd douyin-mcp-server
    2. Install dependencies using uv:
      uv sync
    3. Start the service:
      uv run python web/app.py
    4. Access the interface at http://localhost:8080.
    # 1. 克隆项目
    git clone https://github.com/yzfly/douyin-mcp-server.git
    cd douyin-mcp-server
    
    # 2. 安装依赖
    uv sync
    
    # 3. 启动服务
    uv run python web/app.py
  5. Install dependencies for douyin-video

    main

    To use the douyin-video tool, you need to install the required Python packages and ensure FFmpeg is installed on your system for audio/video processing.

    Python Dependencies

    pip install requests ffmpeg-python

    System Requirements (FFmpeg)

    • macOS: brew install ffmpeg
    • Ubuntu: apt install ffmpeg
  6. Configure API Key for WebUI

    main

    To extract text (AI voice recognition), you must provide an API Key from SiliconFlow. There are two ways to configure it:

    1. Open the WebUI in your browser.
    2. Click the 「API 未配置」 (API not configured) button at the top.
    3. Enter your API Key and save. The key is stored locally in your browser.

    Option 2: Via Environment Variable

    Set the API_KEY environment variable before running the server:

    export API_KEY="sk-xxxxxxxxxxxxxxxx"
    uv run python web/app.py
  7. Start the WebUI service

    main

    To run the WebUI, set your API_KEY environment variable and execute the app.py script. The service defaults to http://localhost:8080 unless HOST or PORT environment variables are provided.

    export API_KEY="sk-xxx"
    python web/app.py
  8. Configure Claude Desktop for Douyin MCP

    main

    To use this server with Claude Desktop, add the following configuration to your claude_desktop_config.json. Ensure you replace your-siliconflow-api-key with your actual key.

    {
      "mcpServers": {
        "douyin-mcp": {
          "command": "uvx",
          "args": ["douyin-mcp-server"],
          "env": {
            "API_KEY": "your-siliconflow-api-key"
          }
        }
      }
    }
  9. Configure Environment Variables for ASR Backends

    main

    The Douyin MCP Server supports two Automatic Speech Recognition (ASR) backends. You must set one of the following environment variables to enable text extraction features:

    1. SiliconFlow (Recommended):

    2. Alibaba DashScope (Aliyun Bailian):

      • Set DASHSCOPE_API_KEY with your key from Alibaba Cloud.
      • Default model: qwen3-asr-flash.

    Note: get_douyin_download_link and parse_douyin_video_info do not require an API key.

  10. Troubleshoot douyin-video issues

    main
    • Ensure the link is a valid Douyin share link (e.g., https://v.douyin.com/xxxxx/ or a full video URL).

    Transcript Extraction Failed

    • Verify that the API_KEY environment variable is set.
    • Check if the API key is valid and has sufficient quota.
    • Ensure FFmpeg is installed and accessible in your system path.

    Slow Download Speeds

    • This depends on your network conditions and video size; the script will display download progress.
  11. Use MCP Tools for Douyin Video Processing

    main

    When integrated via MCP, the following tools are available:

    Tool NameFunctionRequires API
    parse_douyin_video_infoParses video metadata
    get_douyin_download_linkGets the no-watermark download link
    extract_douyin_textDownloads video and extracts AI transcript
    recognize_audio_fileRecognizes local audio files (DashScope)
    recognize_audio_urlRecognizes online audio URLs (DashScope)
  12. Integrate douyin-video into Python code

    main

    You can import functions from douyin_downloader to use the tool within your own Python applications.

    Functions:

    • get_video_info(link): Returns a dictionary containing video_id, title, and url.
    • download_video(link, output_dir): Downloads the video and returns the local file path.
    • extract_text(link, output_dir): Extracts text and returns a dictionary with output_path and text.

    Example Usage:

    from douyin_downloader import get_video_info, download_video, extract_text
    
    # Get video info
    info = get_video_info("抖音分享链接")
    print(f"视频ID: {info['video_id']}")
    
    # Download video
    video_path = download_video("抖音分享链接", output_dir="./videos")
    
    # Extract transcript
    result = extract_text("抖音分享链接", output_dir="./output")
    print(f"文案已保存到: {result['output_path']}")
    print(result['text'])
    from douyin_downloader import get_video_info, download_video, extract_text
    
    # Get video info
    info = get_video_info("抖音分享链接")
    print(f"视频ID: {info['video_id']}")
    print(f"标题: {info['title']}")
    print(f"下载链接: {info['url']}")
    
    # Download video
    video_path = download_video("抖音分享链接", output_dir="./videos")
    
    # Extract transcript and save to file
    result = extract_text("抖音分享链接", output_dir="./output")
    print(f"文案已保存到: {result['output_path']}")
    print(result['text'])