视频下载mcp
这是一个基于MCP的视频下载工具,支持从抖音、TikTok、哔哩哔哩等平台下载无水印视频。使用Playwright模拟浏览器环境,绕过网站的防爬措施。该工具可以作为MCP服务运行,也可以直接通过测试脚本使用。
服务介绍
MCP Video Download URL Parser
This is a video download tool based on MCP, supporting the download of watermark-free videos from platforms such as Douyin, TikTok, and Bilibili.
Features
- Supports downloading watermark-free videos from platforms like Douyin, TikTok, and Bilibili
- Uses Playwright to simulate a browser environment, bypassing anti-crawling measures of websites
- Automatically extracts video titles and download links
- Supports custom download paths
- Can be run as an MCP service
Installation of Dependencies
bash
Install Python dependencies
pip install -r requirements.txt
Install Playwright browsers
playwright install
Usage
Running as an MCP Service
bash
uv run --index-url https://mirrors.aliyun.com/pypi/simple/ main.py
Then, you can call the download_video function via MCP:
python
Example of MCP invocation
result = await mcp_video_url_parser_download_video(url="https://v.douyin.com/your_video_id/", output_path="D:\视频")
Direct Use with Test Script
bash
Using the default test URL
uv run direct_test.py
Specifying the video URL
uv run direct_test.py "https://v.douyin.com/your_video_id/"
Technical Implementation
This tool uses two methods to extract video URLs:
-
Playwright Browser Simulation (Primary Method):
- Fully simulates a real browser environment
- Automatically visits the snapany.com website
- Inputs the video link and clicks the extraction button
- Listens for API responses or directly extracts video elements from the page
- Bypasses anti-crawling measures such as request header verification and cookie validation
-
Direct API Request (Fallback Method):
- Sends requests directly to the snapany.com API
- Adds necessary request headers and parameters
- Handles multiple possible response formats
Solutions to Anti-Crawling Measures
The snapany.com website has strict anti-crawling measures, including:
- Request Header Verification: Requires specific request headers such as g-timestamp and g-footer
- Cookie Verification: Requires valid session cookies
- Browser Fingerprinting: Checks the browser environment, Canvas fingerprint, etc.
- Dynamic Signature Generation: May generate signatures dynamically based on various factors
We successfully bypass these anti-crawling measures by using Playwright to fully simulate a browser environment. Playwright provides a real browser environment, including JavaScript execution, cookie management, and request interception, allowing us to interact with the website just like a real user.
Notes
- This tool is intended for learning and research purposes only
- Please comply with the terms of use and copyright regulations of the relevant platforms
- Do not use it too frequently to avoid putting pressure on the target website
Installation and Execution
Installation via Smithery
To automatically install MCP Video Download URL Parser for Claude Desktop via Smithery:
bash
npx -y @smithery/cli install @tansunyj/mcp_video_download_url_parser --client claude
Manual Installation
- Clone the repository:
git clone https://github.com/tansunyj/mcp_video_download_url_parser.git - Navigate to the directory:
cd mcp_video_download_url_parser - Install dependencies:
pip install -r requirements.txt - Start the MCP server:
python main.py
Configuring Claude Desktop or Cursor
- Add the following configuration:
json
{
"mcpServers": {
"video-url-parser": {
"command": "python",
"args": [
"/path/to/mcp_video_download_url_parser/main.py"
],
"env": {}
}
}
}
Deployment Configuration in Magic Tower Community (Cursor)
To deploy this MCP service on the Magic Tower Community platform, follow these steps:
-
Upload Project: Upload the project to the Magic Tower Community platform
-
Configure Service: In the Magic Tower Community console, find the "MCP Service Configuration" section and add the following configuration information:
json
{
"name": "video-url-parser",
"description": "Video download parsing tool",
"version": "1.0.0",
"main": "main.py",
"requirements": ["playwright", "asyncio", "aiohttp", "beautifulsoup4"],
"environmentVariables": {
"DOWNLOAD_PATH": "./downloads"
}
}
-
Start Service: In the Magic Tower Community console, find the added service and click the "Start Service" button
-
Service Invocation: In the Magic Tower Community, you can invoke the service as follows:
python
Example of service invocation
result = await mcp_video_url_parser_download_video(
url="https://v.douyin.com/your_video_id/",
output_path="指定保存路径"
)5. Troubleshooting Common Issues:
- Ensure all dependencies are correctly installed
- Check if environment variables are properly configured
- If there are network issues, confirm that the server can access the video platform website
- If the service fails to start, check the logs for detailed error information
Usage Examples
After configuration, you can use the following prompts:
- "Download this video: [video_url]"
- "Save this video to D:/videos directory: [video_url]"
Environment Variables
DOWNLOAD_PATH: The path where downloaded videos will be saved (default: ./downloads)
Development
To contribute to the development:
bash
git clone https://github.com/tansunyj/mcp_video_download_url_parser.git
cd mcp_video_download_url_parser
python -m pytest tests/
Security
This MCP server runs on your local machine. While it does not execute arbitrary code, please be cautious when parsing URLs from untrusted sources.
Acknowledgments
This project uses SnapAny.com's API for video parsing and downloading.
License
MIT License