{
  "openapi": "3.1.0",
  "info": {
    "title": "多多直播 API",
    "description": "海外华人影视库，234,000+ 部影视内容。\n- 含豆瓣/TMDB 评分、演员导演、剧情介绍\n- 无需 API Key，IP 限流 60 req/min\n- MCP 端点：POST https://goingtown.com/mcp（Claude 等 AI 模型可直接接入）",
    "version": "1.0.0",
    "contact": {
      "url": "https://goingtown.com"
    }
  },
  "servers": [
    {
      "url": "https://goingtown.com"
    }
  ],
  "paths": {
    "/api/works": {
      "get": {
        "operationId": "searchWorks",
        "summary": "搜索影片列表",
        "description": "关键词 / 类型 / 年份 / 地区多条件搜索，支持分页和排序",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "搜索关键词"
          },
          {
            "name": "type_name",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "类型筛选"
          },
          {
            "name": "year",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "年份"
          },
          {
            "name": "area",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "地区"
          },
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "latest",
                "popular",
                "rating"
              ]
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 20,
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "影片列表",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "works": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/WorkSummary"
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "page": {
                      "type": "integer"
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/works/{id}": {
      "get": {
        "operationId": "getWork",
        "summary": "获取影片详情",
        "description": "返回完整信息：剧情介绍、演员导演、评分、播放线路",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "影片详情",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "work": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/WorkSummary"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "des": {
                              "type": "string",
                              "description": "剧情介绍（可含 HTML）"
                            },
                            "actors": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "directors": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "genres": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "play_count": {
                              "type": "integer"
                            }
                          }
                        }
                      ]
                    },
                    "lines": {
                      "type": "array",
                      "description": "可用播放线路",
                      "items": {
                        "type": "object",
                        "properties": {
                          "provider_id": {
                            "type": "string"
                          },
                          "provider_name": {
                            "type": "string"
                          },
                          "label": {
                            "type": "string"
                          },
                          "is_default": {
                            "type": "boolean"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "影片不存在"
          }
        }
      }
    },
    "/mcp": {
      "post": {
        "operationId": "mcpEndpoint",
        "summary": "MCP (Model Context Protocol) 端点",
        "description": "符合 MCP 2025-03-26 Streamable HTTP 规范的 JSON-RPC 2.0 端点。\n可供 Claude、Cursor、Copilot 等 AI 工具直接调用。\n支持工具：search_works、get_work、list_types",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "jsonrpc": {
                    "type": "string",
                    "enum": [
                      "2.0"
                    ]
                  },
                  "method": {
                    "type": "string",
                    "enum": [
                      "initialize",
                      "tools/list",
                      "tools/call"
                    ]
                  },
                  "params": {
                    "type": "object"
                  },
                  "id": {
                    "type": [
                      "string",
                      "number",
                      "null"
                    ]
                  }
                }
              },
              "examples": {
                "listTools": {
                  "summary": "列出工具",
                  "value": {
                    "jsonrpc": "2.0",
                    "method": "tools/list",
                    "id": 1
                  }
                },
                "searchMovies": {
                  "summary": "搜索影片",
                  "value": {
                    "jsonrpc": "2.0",
                    "method": "tools/call",
                    "id": 2,
                    "params": {
                      "name": "search_works",
                      "arguments": {
                        "query": "肖申克",
                        "limit": 5
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON-RPC 2.0 响应"
          },
          "429": {
            "description": "超出限流（60 req/min/IP）"
          }
        }
      }
    },
    "/v1/models": {
      "get": {
        "operationId": "openaiModels",
        "summary": "OpenAI-compatible 模型列表",
        "responses": {
          "200": {
            "description": "可用模型列表",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string",
                      "enum": [
                        "list"
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "object": {
                            "type": "string",
                            "enum": [
                              "model"
                            ]
                          },
                          "created": {
                            "type": "integer"
                          },
                          "owned_by": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/chat/completions": {
      "post": {
        "operationId": "openaiChatCompletions",
        "summary": "OpenAI-compatible 聊天补全（工具网关）",
        "description": "通过 tool_choice.function.name 指定工具名，tool_arguments 或 user JSON 传参。",
        "responses": {
          "200": {
            "description": "标准 chat.completion 响应"
          },
          "400": {
            "description": "请求参数错误"
          },
          "429": {
            "description": "超出限流（60 req/min/IP）"
          }
        }
      }
    },
    "/v1/responses": {
      "post": {
        "operationId": "openaiResponses",
        "summary": "OpenAI-compatible Responses（工具网关）",
        "responses": {
          "200": {
            "description": "标准 response 响应"
          },
          "400": {
            "description": "请求参数错误"
          },
          "429": {
            "description": "超出限流（60 req/min/IP）"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "WorkSummary": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "title": {
            "type": "string"
          },
          "type_name": {
            "type": "string",
            "description": "分类，如：剧情片、国产剧"
          },
          "year": {
            "type": "string"
          },
          "area": {
            "type": "string"
          },
          "pic": {
            "type": "string",
            "description": "封面图 URL"
          },
          "rating": {
            "type": "number",
            "description": "评分（0-10）"
          },
          "rating_votes": {
            "type": "integer",
            "description": "评分人数"
          },
          "rating_source": {
            "type": "string",
            "enum": [
              "douban",
              "tmdb"
            ],
            "description": "评分来源"
          },
          "play_health": {
            "type": "string",
            "enum": [
              "ready",
              "syncing",
              "none"
            ],
            "description": "可播状态"
          },
          "watch_url": {
            "type": "string",
            "description": "播放页 URL"
          }
        }
      }
    }
  }
}