693 lines
24 KiB
Go
693 lines
24 KiB
Go
// Package docs Code generated by swaggo/swag. DO NOT EDIT
|
|
package docs
|
|
|
|
import "github.com/swaggo/swag"
|
|
|
|
const docTemplate = `{
|
|
"schemes": {{ marshal .Schemes }},
|
|
"swagger": "2.0",
|
|
"info": {
|
|
"description": "{{escape .Description}}",
|
|
"title": "{{.Title}}",
|
|
"termsOfService": "http://swagger.io/terms/",
|
|
"contact": {
|
|
"name": "API Support",
|
|
"url": "https://github.com/caorushizi/mediago-core",
|
|
"email": "support@mediago.local"
|
|
},
|
|
"license": {
|
|
"name": "MIT",
|
|
"url": "https://opensource.org/licenses/MIT"
|
|
},
|
|
"version": "{{.Version}}"
|
|
},
|
|
"host": "{{.Host}}",
|
|
"basePath": "{{.BasePath}}",
|
|
"paths": {
|
|
"/config": {
|
|
"post": {
|
|
"description": "更新系统配置,包括最大并发下载数、下载目录、代理、代理开关等、下载目录、代理等",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"Config"
|
|
],
|
|
"summary": "更新系统配置",
|
|
"parameters": [
|
|
{
|
|
"description": "配置参数",
|
|
"name": "config",
|
|
"in": "body",
|
|
"required": true,
|
|
"schema": {
|
|
"$ref": "#/definitions/caorushizi_cn_mediago_internal_api_dto.UpdateConfigRequest"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "配置更新成功",
|
|
"schema": {
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/definitions/caorushizi_cn_mediago_internal_api_dto.SuccessResponse"
|
|
},
|
|
{
|
|
"type": "object",
|
|
"properties": {
|
|
"data": {
|
|
"$ref": "#/definitions/caorushizi_cn_mediago_internal_api_dto.UpdateConfigResponse"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "请求参数错误",
|
|
"schema": {
|
|
"$ref": "#/definitions/caorushizi_cn_mediago_internal_api_dto.ErrorResponse"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/events": {
|
|
"get": {
|
|
"description": "订阅服务器推送事件(SSE),实时接收下载任务的状态变更通知\n事件类型包括:download-start(任务开始), download-success(任务成功), download-failed(任务失败), download-stop(任务停止)\n注意:不包含进度更新事件,如需获取下载进度,请通过 GET /api/tasks/{id} 接口轮询",
|
|
"produces": [
|
|
"text/event-stream"
|
|
],
|
|
"tags": [
|
|
"Events"
|
|
],
|
|
"summary": "SSE 事件流",
|
|
"responses": {
|
|
"200": {
|
|
"description": "SSE 事件流",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/healthy": {
|
|
"get": {
|
|
"description": "检查服务是否正常运行",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"Health"
|
|
],
|
|
"summary": "健康检查",
|
|
"responses": {
|
|
"200": {
|
|
"description": "服务正常",
|
|
"schema": {
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/definitions/caorushizi_cn_mediago_internal_api_dto.SuccessResponse"
|
|
},
|
|
{
|
|
"type": "object",
|
|
"properties": {
|
|
"data": {
|
|
"$ref": "#/definitions/caorushizi_cn_mediago_internal_api_dto.HealthResponse"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/tasks": {
|
|
"get": {
|
|
"description": "获取所有任务的状态和进度信息列表",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"Tasks"
|
|
],
|
|
"summary": "获取所有任务状态",
|
|
"responses": {
|
|
"200": {
|
|
"description": "任务列表",
|
|
"schema": {
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/definitions/caorushizi_cn_mediago_internal_api_dto.SuccessResponse"
|
|
},
|
|
{
|
|
"type": "object",
|
|
"properties": {
|
|
"data": {
|
|
"$ref": "#/definitions/caorushizi_cn_mediago_internal_api_dto.TaskListResponse"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"post": {
|
|
"description": "创建一个新的下载任务并加入队列,可选择性提供任务 ID\n支持 M3U8、Bilibili、Direct 三种下载类型",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"Tasks"
|
|
],
|
|
"summary": "创建下载任务",
|
|
"parameters": [
|
|
{
|
|
"description": "下载任务参数",
|
|
"name": "task",
|
|
"in": "body",
|
|
"required": true,
|
|
"schema": {
|
|
"$ref": "#/definitions/caorushizi_cn_mediago_internal_api_dto.CreateTaskReq"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "任务创建成功,返回任务状态 (pending/success)",
|
|
"schema": {
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/definitions/caorushizi_cn_mediago_internal_api_dto.SuccessResponse"
|
|
},
|
|
{
|
|
"type": "object",
|
|
"properties": {
|
|
"data": {
|
|
"$ref": "#/definitions/caorushizi_cn_mediago_internal_api_dto.CreateTaskResponse"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "请求参数错误",
|
|
"schema": {
|
|
"$ref": "#/definitions/caorushizi_cn_mediago_internal_api_dto.ErrorResponse"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/tasks/{id}": {
|
|
"get": {
|
|
"description": "获取指定ID的任务状态和进度信息",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"Tasks"
|
|
],
|
|
"summary": "获取任务状态",
|
|
"parameters": [
|
|
{
|
|
"type": "string",
|
|
"example": "task-1",
|
|
"description": "任务ID",
|
|
"name": "id",
|
|
"in": "path",
|
|
"required": true
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "任务信息",
|
|
"schema": {
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/definitions/caorushizi_cn_mediago_internal_api_dto.SuccessResponse"
|
|
},
|
|
{
|
|
"type": "object",
|
|
"properties": {
|
|
"data": {
|
|
"$ref": "#/definitions/caorushizi_cn_mediago_internal_core.TaskInfo"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"404": {
|
|
"description": "任务不存在",
|
|
"schema": {
|
|
"$ref": "#/definitions/caorushizi_cn_mediago_internal_api_dto.ErrorResponse"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/tasks/{id}/logs": {
|
|
"get": {
|
|
"description": "获取指定任务ID的完整下载日志内容",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"Tasks"
|
|
],
|
|
"summary": "获取任务日志",
|
|
"parameters": [
|
|
{
|
|
"type": "string",
|
|
"example": "task-1",
|
|
"description": "任务ID",
|
|
"name": "id",
|
|
"in": "path",
|
|
"required": true
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "任务日志内容",
|
|
"schema": {
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/definitions/caorushizi_cn_mediago_internal_api_dto.SuccessResponse"
|
|
},
|
|
{
|
|
"type": "object",
|
|
"properties": {
|
|
"data": {
|
|
"$ref": "#/definitions/caorushizi_cn_mediago_internal_api_dto.TaskLogResponse"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"404": {
|
|
"description": "日志不存在",
|
|
"schema": {
|
|
"$ref": "#/definitions/caorushizi_cn_mediago_internal_api_dto.ErrorResponse"
|
|
}
|
|
},
|
|
"500": {
|
|
"description": "日志系统未配置或读取失败",
|
|
"schema": {
|
|
"$ref": "#/definitions/caorushizi_cn_mediago_internal_api_dto.ErrorResponse"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/tasks/{id}/stop": {
|
|
"post": {
|
|
"description": "停止指定ID的下载任务",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"Tasks"
|
|
],
|
|
"summary": "停止下载任务",
|
|
"parameters": [
|
|
{
|
|
"type": "string",
|
|
"example": "task-1",
|
|
"description": "任务ID",
|
|
"name": "id",
|
|
"in": "path",
|
|
"required": true
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "任务停止成功",
|
|
"schema": {
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/definitions/caorushizi_cn_mediago_internal_api_dto.SuccessResponse"
|
|
},
|
|
{
|
|
"type": "object",
|
|
"properties": {
|
|
"data": {
|
|
"$ref": "#/definitions/caorushizi_cn_mediago_internal_api_dto.StopTaskResponse"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"404": {
|
|
"description": "任务不存在",
|
|
"schema": {
|
|
"$ref": "#/definitions/caorushizi_cn_mediago_internal_api_dto.ErrorResponse"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"definitions": {
|
|
"caorushizi_cn_mediago_internal_api_dto.CreateTaskReq": {
|
|
"type": "object",
|
|
"required": [
|
|
"name",
|
|
"type",
|
|
"url"
|
|
],
|
|
"properties": {
|
|
"folder": {
|
|
"description": "子文件夹",
|
|
"type": "string",
|
|
"example": "movies"
|
|
},
|
|
"headers": {
|
|
"description": "HTTP 请求头",
|
|
"type": "array",
|
|
"items": {
|
|
"type": "string"
|
|
},
|
|
"example": [
|
|
"User-Agent: custom"
|
|
]
|
|
},
|
|
"id": {
|
|
"description": "(可选) 自定义任务 ID",
|
|
"type": "string",
|
|
"example": "my-custom-id"
|
|
},
|
|
"name": {
|
|
"description": "文件名",
|
|
"type": "string",
|
|
"example": "video"
|
|
},
|
|
"type": {
|
|
"description": "下载类型",
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/definitions/caorushizi_cn_mediago_internal_core.DownloadType"
|
|
}
|
|
],
|
|
"example": "m3u8"
|
|
},
|
|
"url": {
|
|
"description": "下载 URL",
|
|
"type": "string",
|
|
"example": "https://example.com/video.m3u8"
|
|
}
|
|
}
|
|
},
|
|
"caorushizi_cn_mediago_internal_api_dto.CreateTaskResponse": {
|
|
"type": "object",
|
|
"properties": {
|
|
"id": {
|
|
"description": "任务ID",
|
|
"type": "string"
|
|
},
|
|
"message": {
|
|
"description": "响应消息",
|
|
"type": "string"
|
|
},
|
|
"status": {
|
|
"description": "任务状态 (pending/success)",
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"caorushizi_cn_mediago_internal_api_dto.ErrorResponse": {
|
|
"type": "object",
|
|
"properties": {
|
|
"code": {
|
|
"type": "integer"
|
|
},
|
|
"message": {
|
|
"type": "string"
|
|
},
|
|
"success": {
|
|
"type": "boolean",
|
|
"example": false
|
|
}
|
|
}
|
|
},
|
|
"caorushizi_cn_mediago_internal_api_dto.HealthResponse": {
|
|
"type": "object",
|
|
"properties": {
|
|
"status": {
|
|
"type": "string",
|
|
"example": "ok"
|
|
}
|
|
}
|
|
},
|
|
"caorushizi_cn_mediago_internal_api_dto.StopTaskResponse": {
|
|
"type": "object",
|
|
"properties": {
|
|
"message": {
|
|
"description": "响应消息",
|
|
"type": "string",
|
|
"example": "Task stopped"
|
|
}
|
|
}
|
|
},
|
|
"caorushizi_cn_mediago_internal_api_dto.SuccessResponse": {
|
|
"type": "object",
|
|
"properties": {
|
|
"code": {
|
|
"type": "integer",
|
|
"example": 200
|
|
},
|
|
"data": {},
|
|
"message": {
|
|
"type": "string",
|
|
"example": "OK"
|
|
},
|
|
"success": {
|
|
"type": "boolean",
|
|
"example": true
|
|
}
|
|
}
|
|
},
|
|
"caorushizi_cn_mediago_internal_api_dto.TaskListResponse": {
|
|
"type": "object",
|
|
"properties": {
|
|
"tasks": {
|
|
"description": "任务列表",
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/definitions/caorushizi_cn_mediago_internal_core.TaskInfo"
|
|
}
|
|
},
|
|
"total": {
|
|
"description": "总数量",
|
|
"type": "integer"
|
|
}
|
|
}
|
|
},
|
|
"caorushizi_cn_mediago_internal_api_dto.TaskLogResponse": {
|
|
"type": "object",
|
|
"properties": {
|
|
"id": {
|
|
"description": "任务ID",
|
|
"type": "string"
|
|
},
|
|
"log": {
|
|
"description": "日志内容",
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"caorushizi_cn_mediago_internal_api_dto.UpdateConfigRequest": {
|
|
"type": "object",
|
|
"properties": {
|
|
"deleteSegments": {
|
|
"description": "是否删除分段",
|
|
"type": "boolean"
|
|
},
|
|
"localDir": {
|
|
"description": "本地保存目录",
|
|
"type": "string"
|
|
},
|
|
"maxRunner": {
|
|
"description": "最大并发下载数",
|
|
"type": "integer"
|
|
},
|
|
"proxy": {
|
|
"description": "代理地址",
|
|
"type": "string"
|
|
},
|
|
"useProxy": {
|
|
"description": "是否使用代理",
|
|
"type": "boolean"
|
|
}
|
|
}
|
|
},
|
|
"caorushizi_cn_mediago_internal_api_dto.UpdateConfigResponse": {
|
|
"type": "object",
|
|
"properties": {
|
|
"message": {
|
|
"description": "响应消息",
|
|
"type": "string",
|
|
"example": "Config updated"
|
|
}
|
|
}
|
|
},
|
|
"caorushizi_cn_mediago_internal_core.DownloadType": {
|
|
"type": "string",
|
|
"enum": [
|
|
"m3u8",
|
|
"bilibili",
|
|
"direct"
|
|
],
|
|
"x-enum-varnames": [
|
|
"TypeM3U8",
|
|
"TypeBilibili",
|
|
"TypeDirect"
|
|
]
|
|
},
|
|
"caorushizi_cn_mediago_internal_core.TaskInfo": {
|
|
"type": "object",
|
|
"properties": {
|
|
"error": {
|
|
"description": "错误信息(如果有)",
|
|
"type": "string"
|
|
},
|
|
"id": {
|
|
"description": "任务ID",
|
|
"type": "string"
|
|
},
|
|
"isLive": {
|
|
"description": "是否为直播流",
|
|
"type": "boolean"
|
|
},
|
|
"name": {
|
|
"description": "文件名",
|
|
"type": "string"
|
|
},
|
|
"percent": {
|
|
"description": "完成百分比",
|
|
"type": "number"
|
|
},
|
|
"speed": {
|
|
"description": "下载速度",
|
|
"type": "string"
|
|
},
|
|
"status": {
|
|
"description": "任务状态",
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/definitions/caorushizi_cn_mediago_internal_core.TaskStatus"
|
|
}
|
|
]
|
|
},
|
|
"type": {
|
|
"description": "下载类型",
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/definitions/caorushizi_cn_mediago_internal_core.DownloadType"
|
|
}
|
|
]
|
|
},
|
|
"url": {
|
|
"description": "下载URL",
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"caorushizi_cn_mediago_internal_core.TaskStatus": {
|
|
"type": "string",
|
|
"enum": [
|
|
"pending",
|
|
"downloading",
|
|
"success",
|
|
"failed",
|
|
"stopped"
|
|
],
|
|
"x-enum-comments": {
|
|
"StatusDownloading": "下载中",
|
|
"StatusFailed": "失败",
|
|
"StatusPending": "等待中",
|
|
"StatusStopped": "已停止",
|
|
"StatusSuccess": "成功完成"
|
|
},
|
|
"x-enum-descriptions": [
|
|
"等待中",
|
|
"下载中",
|
|
"成功完成",
|
|
"失败",
|
|
"已停止"
|
|
],
|
|
"x-enum-varnames": [
|
|
"StatusPending",
|
|
"StatusDownloading",
|
|
"StatusSuccess",
|
|
"StatusFailed",
|
|
"StatusStopped"
|
|
]
|
|
}
|
|
},
|
|
"tags": [
|
|
{
|
|
"description": "健康检查相关接口",
|
|
"name": "Health"
|
|
},
|
|
{
|
|
"description": "下载任务管理相关接口",
|
|
"name": "Tasks"
|
|
},
|
|
{
|
|
"description": "系统配置相关接口",
|
|
"name": "Config"
|
|
},
|
|
{
|
|
"description": "实时事件推送相关接口",
|
|
"name": "Events"
|
|
}
|
|
]
|
|
}`
|
|
|
|
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
|
var SwaggerInfo = &swag.Spec{
|
|
Version: "1.0",
|
|
Host: "localhost:8080",
|
|
BasePath: "/api",
|
|
Schemes: []string{"http", "https"},
|
|
Title: "MediaGo Downloader API",
|
|
Description: "MediaGo 多任务下载系统 API 文档\n支持 M3U8、Bilibili、Direct 三种下载类型\n提供任务管理、配置更新、实时事件推送等功能",
|
|
InfoInstanceName: "swagger",
|
|
SwaggerTemplate: docTemplate,
|
|
LeftDelim: "{{",
|
|
RightDelim: "}}",
|
|
}
|
|
|
|
func init() {
|
|
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
|
|
}
|