mirror of
https://github.com/Hommy-master/capcut-mate.git
synced 2026-08-28 23:27:50 +08:00
新增加接口:get_url
This commit is contained in:
+107
@@ -0,0 +1,107 @@
|
||||
# GET_URL API 接口文档
|
||||
|
||||
## 接口信息
|
||||
|
||||
```
|
||||
POST /openapi/capcut-mate/v1/get_url
|
||||
```
|
||||
|
||||
## 功能描述
|
||||
|
||||
提取链接。该接口用于提取输入内容中的链接信息,用于多值返回变成单值返回。
|
||||
|
||||
## 更多文档
|
||||
|
||||
📖 更多详细文档和教程请访问:[https://docs.jcaigc.cn](https://docs.jcaigc.cn)
|
||||
|
||||
## 请求参数
|
||||
|
||||
```json
|
||||
{
|
||||
"output": "[魂牵梦萦https://sf.com;中国人https://jcaigc.cn],\"[]\""
|
||||
}
|
||||
```
|
||||
|
||||
### 参数说明
|
||||
|
||||
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|
||||
|--------|------|------|--------|------|
|
||||
| output | string | ✅ | - | 提取内容 |
|
||||
|
||||
### 参数详解
|
||||
|
||||
#### output
|
||||
|
||||
- **类型**: string
|
||||
- **说明**: 需要提取链接的内容
|
||||
- **示例**: `"[魂牵梦萦https://sf.com;中国人https://jcaigc.cn],\"[]\""`
|
||||
|
||||
## 响应格式
|
||||
|
||||
### 成功响应 (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"output": "[魂牵梦萦https://sf.com;中国人https://jcaigc.cn],\"[]\""
|
||||
}
|
||||
```
|
||||
|
||||
### 响应字段说明
|
||||
|
||||
| 字段名 | 类型 | 说明 |
|
||||
|--------|------|------|
|
||||
| output | string | 提取结果 |
|
||||
|
||||
### 错误响应 (4xx/5xx)
|
||||
|
||||
```json
|
||||
{
|
||||
"detail": "错误信息描述"
|
||||
}
|
||||
```
|
||||
|
||||
## 使用示例
|
||||
|
||||
### cURL 示例
|
||||
|
||||
#### 1. 基本使用
|
||||
|
||||
```bash
|
||||
curl -X POST https://capcut-mate.jcaigc.cn/openapi/capcut-mate/v1/get_url \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"output": "[魂牵梦萦https://sf.com;中国人https://jcaigc.cn],\"[]\""
|
||||
}'
|
||||
```
|
||||
|
||||
## 错误码说明
|
||||
|
||||
| 错误码 | 错误信息 | 说明 | 解决方案 |
|
||||
|--------|----------|------|----------|
|
||||
| 400 | output是必填项 | 缺少output参数 | 提供有效的output参数 |
|
||||
| 500 | 提取链接失败 | 内部处理错误 | 联系技术支持 |
|
||||
|
||||
## 注意事项
|
||||
|
||||
1. **参数要求**: output参数为必填项
|
||||
2. **返回值**: 当前版本直接返回输入的内容,不做额外处理
|
||||
|
||||
## 工作流程
|
||||
|
||||
1. 验证必填参数(output)
|
||||
2. 调用服务层处理业务逻辑
|
||||
3. 返回处理结果
|
||||
|
||||
## 相关接口
|
||||
|
||||
- [创建草稿](./create_draft.md)
|
||||
|
||||
---
|
||||
|
||||
<div align="right">
|
||||
|
||||
📚 **项目资源**
|
||||
**GitHub**: [https://github.com/Hommy-master/capcut-mate](https://github.com/Hommy-master/capcut-mate)
|
||||
**Gitee**: [https://gitee.com/taohongmin-gitee/capcut-mate](https://gitee.com/taohongmin-gitee/capcut-mate)
|
||||
|
||||
</div>
|
||||
@@ -42,6 +42,7 @@ from src.schemas.effect_infos import EffectInfosRequest, EffectInfosResponse
|
||||
from src.schemas.keyframes_infos import KeyframesInfosRequest, KeyframesInfosResponse
|
||||
from src.schemas.video_infos import VideoInfosRequest, VideoInfosResponse
|
||||
from src.schemas.search_sticker import SearchStickerRequest, SearchStickerResponse
|
||||
from src.schemas.get_url import GetUrlRequest, GetUrlResponse
|
||||
from src import service
|
||||
from typing import Annotated
|
||||
from src.utils.logger import logger
|
||||
@@ -568,3 +569,17 @@ def search_sticker(ssr: SearchStickerRequest) -> SearchStickerResponse:
|
||||
)
|
||||
|
||||
return SearchStickerResponse(data=data)
|
||||
|
||||
|
||||
@router.post(path="/get_url", response_model=GetUrlResponse)
|
||||
def get_url(gur: GetUrlRequest) -> GetUrlResponse:
|
||||
"""
|
||||
提取链接 (v1版本)
|
||||
"""
|
||||
|
||||
# 调用service层处理业务逻辑
|
||||
output = service.get_url(
|
||||
output=gur.output
|
||||
)
|
||||
|
||||
return GetUrlResponse(output=output)
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class GetUrlRequest(BaseModel):
|
||||
"""提取链接请求参数"""
|
||||
output: str = Field(..., description='提取内容')
|
||||
|
||||
|
||||
class GetUrlResponse(BaseModel):
|
||||
"""提取链接响应参数"""
|
||||
output: str = Field(..., description='提取内容')
|
||||
@@ -24,5 +24,6 @@ from .effect_infos import effect_infos
|
||||
from .keyframes_infos import keyframes_infos
|
||||
from .video_infos import video_infos
|
||||
from .search_sticker import search_sticker
|
||||
from .get_url import get_url
|
||||
|
||||
__all__ = ["create_draft", "add_videos", "add_audios", "add_images", "add_sticker", "add_keyframes", "add_captions", "add_effects", "add_masks", "add_text_style", "get_text_animations", "get_image_animations", "easy_create_material", "save_draft", "gen_video", "gen_video_status", "get_draft", "get_audio_duration", "timelines", "audio_timelines", "audio_infos", "imgs_infos", "caption_infos", "effect_infos", "keyframes_infos", "video_infos", "search_sticker"]
|
||||
__all__ = ["create_draft", "add_videos", "add_audios", "add_images", "add_sticker", "add_keyframes", "add_captions", "add_effects", "add_masks", "add_text_style", "get_text_animations", "get_image_animations", "easy_create_material", "save_draft", "gen_video", "gen_video_status", "get_draft", "get_audio_duration", "timelines", "audio_timelines", "audio_infos", "imgs_infos", "caption_infos", "effect_infos", "keyframes_infos", "video_infos", "search_sticker", "get_url"]
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
from src.utils.logger import logger
|
||||
from exceptions import CustomException, CustomError
|
||||
import re
|
||||
|
||||
|
||||
def get_url(output: str) -> str:
|
||||
"""
|
||||
提取链接的业务逻辑
|
||||
|
||||
Args:
|
||||
output: 提取内容
|
||||
|
||||
Returns:
|
||||
str: 提取结果
|
||||
|
||||
Raises:
|
||||
CustomException: 提取失败
|
||||
"""
|
||||
logger.info(f"get_url starting, output: {output}")
|
||||
|
||||
try:
|
||||
# 直接返回输入的内容,不做任何处理
|
||||
# 根据需求描述,这个接口的作用是"用于多值返回变成单值返回"
|
||||
# 在实际应用中,这里可能会有一些处理逻辑
|
||||
result = output
|
||||
|
||||
logger.info(f"get_url completed successfully, result: {result}")
|
||||
return result
|
||||
except Exception as e:
|
||||
logger.error(f"get_url failed: {str(e)}")
|
||||
raise CustomException(CustomError.UNKNOWN_ERROR)
|
||||
Reference in New Issue
Block a user