Skip to main content
Glama

get_douyin_download_link

Extract watermark-free download links from Douyin video share links to save videos without branding.

Instructions

获取抖音视频的无水印下载链接

参数:
- share_link: 抖音分享链接或包含链接的文本

返回:
- 包含下载链接和视频信息的JSON字符串

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
share_linkYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'get_douyin_download_link' tool, decorated with @mcp.tool(). It creates a DouyinProcessor instance and calls parse_share_url to get the no-watermark download link, returning it as JSON.
    @mcp.tool()
    def get_douyin_download_link(share_link: str) -> str:
        """
        获取抖音视频的无水印下载链接
        
        参数:
        - share_link: 抖音分享链接或包含链接的文本
        
        返回:
        - 包含下载链接和视频信息的JSON字符串
        """
        try:
            processor = DouyinProcessor("")  # 获取下载链接不需要API密钥
            video_info = processor.parse_share_url(share_link)
            
            return json.dumps({
                "status": "success",
                "video_id": video_info["video_id"],
                "title": video_info["title"],
                "download_url": video_info["url"],
                "description": f"视频标题: {video_info['title']}",
                "usage_tip": "可以直接使用此链接下载无水印视频"
            }, ensure_ascii=False, indent=2)
            
        except Exception as e:
            return json.dumps({
                "status": "error",
                "error": f"获取下载链接失败: {str(e)}"
            }, ensure_ascii=False, indent=2)
  • Core helper method in DouyinProcessor class that implements the logic to parse Douyin share URL, fetch page, extract JSON data, and compute the no-watermark video download URL.
    def parse_share_url(self, share_text: str) -> dict:
        """从分享文本中提取无水印视频链接"""
        # 提取分享链接
        urls = re.findall(r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', share_text)
        if not urls:
            raise ValueError("未找到有效的分享链接")
        
        share_url = urls[0]
        share_response = requests.get(share_url, headers=HEADERS)
        video_id = share_response.url.split("?")[0].strip("/").split("/")[-1]
        share_url = f'https://www.iesdouyin.com/share/video/{video_id}'
        
        # 获取视频页面内容
        response = requests.get(share_url, headers=HEADERS)
        response.raise_for_status()
        
        pattern = re.compile(
            pattern=r"window\._ROUTER_DATA\s*=\s*(.*?)</script>",
            flags=re.DOTALL,
        )
        find_res = pattern.search(response.text)
    
        if not find_res or not find_res.group(1):
            raise ValueError("从HTML中解析视频信息失败")
    
        # 解析JSON数据
        json_data = json.loads(find_res.group(1).strip())
        VIDEO_ID_PAGE_KEY = "video_(id)/page"
        NOTE_ID_PAGE_KEY = "note_(id)/page"
        
        if VIDEO_ID_PAGE_KEY in json_data["loaderData"]:
            original_video_info = json_data["loaderData"][VIDEO_ID_PAGE_KEY]["videoInfoRes"]
        elif NOTE_ID_PAGE_KEY in json_data["loaderData"]:
            original_video_info = json_data["loaderData"][NOTE_ID_PAGE_KEY]["videoInfoRes"]
        else:
            raise Exception("无法从JSON中解析视频或图集信息")
    
        data = original_video_info["item_list"][0]
    
        # 获取视频信息
        video_url = data["video"]["play_addr"]["url_list"][0].replace("playwm", "play")
        desc = data.get("desc", "").strip() or f"douyin_{video_id}"
        
        # 替换文件名中的非法字符
        desc = re.sub(r'[\\/:*?"<>|]', '_', desc)
        
        return {
            "url": video_url,
            "title": desc,
            "video_id": video_id
        }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. While it mentions the tool returns '包含下载链接和视频信息的JSON字符串' (JSON string containing download link and video information), it doesn't disclose important behavioral traits like whether this requires authentication, rate limits, error conditions, or what happens with invalid links. The description provides basic output information but lacks crucial operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and well-structured with clear sections for purpose, parameters, and return value. Each sentence earns its place by providing essential information. The Chinese text is direct and avoids unnecessary elaboration, though it could be slightly more front-loaded by stating the core purpose more prominently.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (single parameter, specific purpose) and the presence of an output schema (which handles return value documentation), the description is reasonably complete. It covers the core functionality, parameter semantics, and output format. The main gap is the lack of behavioral context that would normally come from annotations, but the description provides adequate information for basic usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description must compensate for the lack of parameter documentation in the schema. It successfully adds semantic meaning by explaining that the 'share_link' parameter accepts '抖音分享链接或包含链接的文本' (Douyin share link or text containing a link), which clarifies the parameter's purpose beyond what the bare schema provides. This is valuable context for a single-parameter tool.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('获取' meaning 'get') and resource ('抖音视频的无水印下载链接' meaning 'Douyin video watermark-free download link'). It distinguishes from sibling tools like 'extract_douyin_text' and 'parse_douyin_video_info' by focusing specifically on obtaining download links rather than text extraction or video information parsing.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context through the parameter description ('抖音分享链接或包含链接的文本' meaning 'Douyin share link or text containing a link'), suggesting this tool should be used when you have a share link. However, it doesn't explicitly state when to use this tool versus the sibling tools, nor does it provide any exclusion criteria or alternative scenarios.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yzfly/douyin-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server