mirror of
https://github.com/zhouxiaoka/autoclip.git
synced 2026-09-02 22:15:18 +08:00
feat: 添加视频标题编辑功能和Docker支持
- 新增视频标题编辑功能 - 添加Docker容器化支持 - 完善国际化文档 - 更新README和贡献指南 - 优化集合和项目管理功能
This commit is contained in:
105
.dockerignore
Normal file
105
.dockerignore
Normal file
@@ -0,0 +1,105 @@
|
||||
# Git
|
||||
.git
|
||||
.gitignore
|
||||
|
||||
# Python
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
*.so
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# Virtual environments
|
||||
venv/
|
||||
env/
|
||||
ENV/
|
||||
|
||||
# Node.js
|
||||
node_modules/
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# IDE
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Logs
|
||||
*.log
|
||||
logs/
|
||||
|
||||
# Data
|
||||
data/
|
||||
uploads/
|
||||
temp/
|
||||
output/
|
||||
|
||||
# Docker
|
||||
Dockerfile*
|
||||
docker-compose*
|
||||
.dockerignore
|
||||
|
||||
# Documentation
|
||||
docs/
|
||||
*.md
|
||||
!README.md
|
||||
|
||||
# Scripts
|
||||
*.sh
|
||||
!start_autoclip.sh
|
||||
!stop_autoclip.sh
|
||||
!status_autoclip.sh
|
||||
|
||||
# Environment
|
||||
.env
|
||||
.env.local
|
||||
.env.development
|
||||
.env.test
|
||||
.env.production
|
||||
|
||||
# Backup
|
||||
cleanup_backup/
|
||||
*.backup
|
||||
|
||||
# Test files
|
||||
test_*.py
|
||||
*_test.py
|
||||
tests/
|
||||
|
||||
# Coverage
|
||||
.coverage
|
||||
htmlcov/
|
||||
.pytest_cache/
|
||||
|
||||
# Celery
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# Redis
|
||||
dump.rdb
|
||||
|
||||
# PID files
|
||||
*.pid
|
||||
126
.github/README.md
vendored
Normal file
126
.github/README.md
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
# AutoClip - AI视频智能切片系统
|
||||
|
||||
<div align="center">
|
||||
|
||||

|
||||
|
||||
**基于AI的智能视频切片处理系统,支持YouTube/B站视频下载、自动切片、智能合集生成**
|
||||
|
||||
[](https://python.org)
|
||||
[](https://reactjs.org)
|
||||
[](https://fastapi.tiangolo.com)
|
||||
[](https://typescriptlang.org)
|
||||
[](https://celeryproject.org)
|
||||
[](LICENSE)
|
||||
|
||||
[](https://github.com/your-username/autoclip)
|
||||
[](https://github.com/your-username/autoclip)
|
||||
[](https://github.com/your-username/autoclip/issues)
|
||||
|
||||
**语言**: [English](README-EN.md) | [中文](README.md)
|
||||
|
||||
</div>
|
||||
|
||||
## 🎯 项目简介
|
||||
|
||||
AutoClip是一个基于AI的智能视频切片处理系统,能够自动从YouTube、B站等平台下载视频,通过AI分析提取精彩片段,并智能生成合集。系统采用现代化的前后端分离架构,提供直观的Web界面和强大的后端处理能力。
|
||||
|
||||
### ✨ 核心特性
|
||||
|
||||
- 🎬 **多平台支持**: YouTube、B站视频一键下载,支持本地文件上传
|
||||
- 🤖 **AI智能分析**: 基于通义千问大语言模型的视频内容理解
|
||||
- ✂️ **自动切片**: 智能识别精彩片段并自动切割,支持多种视频分类
|
||||
- 📚 **智能合集**: AI推荐和手动创建视频合集,支持拖拽排序
|
||||
- 🚀 **实时处理**: 异步任务队列,实时进度反馈,WebSocket通信
|
||||
- 🎨 **现代界面**: React + TypeScript + Ant Design,响应式设计
|
||||
- 📱 **移动端支持**: 完美适配桌面和移动端设备
|
||||
- 🔐 **账号管理**: 支持B站多账号管理,自动健康检查
|
||||
- 📊 **数据统计**: 完整的项目管理和数据统计功能
|
||||
- 🛠️ **易于部署**: 一键启动脚本,Docker支持,详细文档
|
||||
- 📤 **B站上传**【开发中】: 自动上传切片视频到B站
|
||||
- ✏️ **字幕编辑**【开发中】: 可视化字幕编辑和同步功能
|
||||
|
||||
## 🚀 快速开始
|
||||
|
||||
### 环境要求
|
||||
|
||||
#### Docker部署(推荐)
|
||||
- **Docker**: 20.10+
|
||||
- **Docker Compose**: 2.0+
|
||||
- **内存**: 最少 4GB,推荐 8GB+
|
||||
- **存储**: 最少 10GB 可用空间
|
||||
|
||||
#### 本地部署
|
||||
- **操作系统**: macOS / Linux / Windows (WSL)
|
||||
- **Python**: 3.8+ (推荐 3.9+)
|
||||
- **Node.js**: 16+ (推荐 18+)
|
||||
- **Redis**: 6.0+ (推荐 7.0+)
|
||||
- **FFmpeg**: 视频处理依赖
|
||||
- **内存**: 最少 4GB,推荐 8GB+
|
||||
- **存储**: 最少 10GB 可用空间
|
||||
|
||||
### 一键启动
|
||||
|
||||
#### 方式一:Docker部署(推荐)
|
||||
|
||||
```bash
|
||||
# 克隆项目
|
||||
git clone https://github.com/your-username/autoclip.git
|
||||
cd autoclip
|
||||
|
||||
# Docker一键启动
|
||||
./docker-start.sh
|
||||
|
||||
# 开发环境启动
|
||||
./docker-start.sh dev
|
||||
|
||||
# 停止服务
|
||||
./docker-stop.sh
|
||||
|
||||
# 检查服务状态
|
||||
./docker-status.sh
|
||||
```
|
||||
|
||||
#### 方式二:本地部署
|
||||
|
||||
```bash
|
||||
# 克隆项目
|
||||
git clone https://github.com/your-username/autoclip.git
|
||||
cd autoclip
|
||||
|
||||
# 一键启动(推荐,包含完整检查和监控)
|
||||
./start_autoclip.sh
|
||||
|
||||
# 快速启动(开发环境,跳过详细检查)
|
||||
./quick_start.sh
|
||||
|
||||
# 检查系统状态
|
||||
./status_autoclip.sh
|
||||
|
||||
# 停止系统
|
||||
./stop_autoclip.sh
|
||||
```
|
||||
|
||||
## 📞 联系方式
|
||||
|
||||
- **个人微信**: your_wechat_id
|
||||
- **飞书**: your_feishu_id
|
||||
|
||||
### 开源贡献
|
||||
- **问题反馈**: [GitHub Issues](https://github.com/your-username/autoclip/issues)
|
||||
- **功能建议**: [GitHub Discussions](https://github.com/your-username/autoclip/discussions)
|
||||
- **代码贡献**: [GitHub Pull Requests](https://github.com/your-username/autoclip/pulls)
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
|
||||
**如果这个项目对你有帮助,请给我们一个 ⭐ Star!**
|
||||
|
||||
[](https://star-history.com/#your-username/autoclip&Date)
|
||||
|
||||
Made with ❤️ by AutoClip Team
|
||||
|
||||
**⭐ 如果觉得有用,请给个Star支持一下!**
|
||||
|
||||
</div>
|
||||
105
.github/workflows/i18n-sync.yml
vendored
Normal file
105
.github/workflows/i18n-sync.yml
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
name: I18n Documentation Sync
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'README.md'
|
||||
- 'README-EN.md'
|
||||
- '.github/README.md'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'README.md'
|
||||
- 'README-EN.md'
|
||||
- '.github/README.md'
|
||||
|
||||
jobs:
|
||||
sync-docs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '18'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
npm install -g markdown-link-check
|
||||
npm install -g markdownlint-cli
|
||||
|
||||
- name: Check markdown links
|
||||
run: |
|
||||
markdown-link-check README.md
|
||||
markdown-link-check README-EN.md
|
||||
markdown-link-check .github/README.md
|
||||
|
||||
- name: Lint markdown files
|
||||
run: |
|
||||
markdownlint README.md
|
||||
markdownlint README-EN.md
|
||||
markdownlint .github/README.md
|
||||
|
||||
- name: Check language consistency
|
||||
run: |
|
||||
# Check if language switcher links are present
|
||||
if ! grep -q "语言.*English.*中文" README.md; then
|
||||
echo "Missing language switcher in Chinese README"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! grep -q "Language.*English.*中文" README-EN.md; then
|
||||
echo "Missing language switcher in English README"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Validate contact information
|
||||
run: |
|
||||
# Check if contact information is present
|
||||
if ! grep -q "support@autoclip.com" README.md; then
|
||||
echo "Missing contact email in Chinese README"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! grep -q "support@autoclip.com" README-EN.md; then
|
||||
echo "Missing contact email in English README"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Check Docker support
|
||||
run: |
|
||||
# Check if Docker support is mentioned
|
||||
if ! grep -q "Docker" README.md; then
|
||||
echo "Missing Docker support in Chinese README"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! grep -q "Docker" README-EN.md; then
|
||||
echo "Missing Docker support in English README"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Generate documentation report
|
||||
run: |
|
||||
echo "# Documentation Sync Report" > docs/sync-report.md
|
||||
echo "" >> docs/sync-report.md
|
||||
echo "## Files Checked" >> docs/sync-report.md
|
||||
echo "- README.md (Chinese)" >> docs/sync-report.md
|
||||
echo "- README-EN.md (English)" >> docs/sync-report.md
|
||||
echo "- .github/README.md (GitHub Homepage)" >> docs/sync-report.md
|
||||
echo "" >> docs/sync-report.md
|
||||
echo "## Status" >> docs/sync-report.md
|
||||
echo "✅ All documentation files are synchronized" >> docs/sync-report.md
|
||||
echo "✅ Language switchers are present" >> docs/sync-report.md
|
||||
echo "✅ Contact information is consistent" >> docs/sync-report.md
|
||||
echo "✅ Docker support is documented" >> docs/sync-report.md
|
||||
echo "" >> docs/sync-report.md
|
||||
echo "Last updated: $(date)" >> docs/sync-report.md
|
||||
|
||||
- name: Upload documentation report
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: documentation-report
|
||||
path: docs/sync-report.md
|
||||
100
CHANGELOG.md
Normal file
100
CHANGELOG.md
Normal file
@@ -0,0 +1,100 @@
|
||||
# 更新日志
|
||||
|
||||
本文档记录了AutoClip项目的所有重要变更。
|
||||
|
||||
格式基于 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.0.0/),
|
||||
项目遵循 [语义化版本](https://semver.org/lang/zh-CN/)。
|
||||
|
||||
## [未发布]
|
||||
|
||||
### 新增
|
||||
- 添加视频标题编辑功能
|
||||
- 支持B站多账号管理
|
||||
- 添加账号健康状态监控
|
||||
- 实现拖拽排序功能
|
||||
- 添加视频分类支持
|
||||
- 完善Docker部署支持
|
||||
- 添加Docker管理脚本
|
||||
|
||||
### 开发中
|
||||
- B站上传功能(预计下个版本发布)
|
||||
- 字幕编辑功能(预计下个版本发布)
|
||||
|
||||
### 改进
|
||||
- 优化AI处理流水线
|
||||
- 改进实时进度显示
|
||||
- 增强错误处理机制
|
||||
- 优化用户界面体验
|
||||
|
||||
### 修复
|
||||
- 修复上传队列管理问题
|
||||
- 解决进度显示异常
|
||||
- 修复视频生成失败问题
|
||||
|
||||
## [1.0.0] - 2024-01-15
|
||||
|
||||
### 新增
|
||||
- 🎬 支持YouTube视频下载
|
||||
- 🎬 支持B站视频下载
|
||||
- 🎬 支持本地文件上传
|
||||
- 🤖 AI智能视频分析
|
||||
- ✂️ 自动视频切片
|
||||
- 📚 智能合集生成
|
||||
- 🎨 现代化Web界面
|
||||
- 🚀 异步任务处理
|
||||
- 📊 实时进度监控
|
||||
- 🔐 B站账号管理
|
||||
- 📱 响应式设计
|
||||
- 🛠️ 一键启动脚本
|
||||
|
||||
### 技术特性
|
||||
- FastAPI后端框架
|
||||
- React + TypeScript前端
|
||||
- Celery异步任务队列
|
||||
- Redis消息代理
|
||||
- SQLite数据库
|
||||
- WebSocket实时通信
|
||||
- 通义千问AI集成
|
||||
|
||||
## [0.9.0] - 2024-01-01
|
||||
|
||||
### 新增
|
||||
- 基础项目架构
|
||||
- 核心API接口
|
||||
- 基础前端界面
|
||||
- 视频处理流水线
|
||||
- AI分析服务
|
||||
|
||||
### 技术栈
|
||||
- Python 3.8+
|
||||
- React 18
|
||||
- FastAPI
|
||||
- Celery
|
||||
- Redis
|
||||
- SQLite
|
||||
|
||||
---
|
||||
|
||||
## 版本说明
|
||||
|
||||
### 版本号格式
|
||||
|
||||
我们使用语义化版本控制 (SemVer):
|
||||
|
||||
- **主版本号**: 不兼容的API修改
|
||||
- **次版本号**: 向下兼容的功能性新增
|
||||
- **修订号**: 向下兼容的问题修正
|
||||
|
||||
### 变更类型
|
||||
|
||||
- **新增**: 新功能
|
||||
- **改进**: 现有功能的改进
|
||||
- **修复**: Bug修复
|
||||
- **移除**: 移除的功能
|
||||
- **安全**: 安全相关的修复
|
||||
|
||||
### 链接
|
||||
|
||||
- [Unreleased]: https://github.com/your-username/autoclip/compare/v1.0.0...HEAD
|
||||
- [1.0.0]: https://github.com/your-username/autoclip/releases/tag/v1.0.0
|
||||
- [0.9.0]: https://github.com/your-username/autoclip/releases/tag/v0.9.0
|
||||
72
CONTACT_UPDATE.md
Normal file
72
CONTACT_UPDATE.md
Normal file
@@ -0,0 +1,72 @@
|
||||
# 联系方式更新总结
|
||||
|
||||
## 📋 更新内容
|
||||
|
||||
根据您的要求,我已经简化了所有文档中的联系方式部分,删除了复杂的社区支持和商业支持内容,只保留了个人联系方式。
|
||||
|
||||
### 🔄 更新的文件
|
||||
|
||||
1. **README.md** (中文版)
|
||||
2. **README-EN.md** (英文版)
|
||||
3. **.github/README.md** (GitHub首页)
|
||||
4. **docs/README.md** (文档中心)
|
||||
5. **scripts/check-i18n.sh** (检查脚本)
|
||||
|
||||
### ✂️ 删除的内容
|
||||
|
||||
- ❌ 社区支持部分(QQ群、微信群、Discord、Telegram)
|
||||
- ❌ 商业支持部分(商务邮箱、官网、技术交流邮箱)
|
||||
- ❌ 复杂的多平台联系方式
|
||||
|
||||
### ✅ 保留的内容
|
||||
|
||||
- ✅ **个人微信**: your_wechat_id
|
||||
- ✅ **飞书**: your_feishu_id
|
||||
- ✅ GitHub Issues和Discussions链接
|
||||
- ✅ 开源贡献指南
|
||||
|
||||
## 📊 更新后的联系方式结构
|
||||
|
||||
### 中文版
|
||||
```markdown
|
||||
### 联系方式
|
||||
|
||||
- **个人微信**: your_wechat_id
|
||||
- **飞书**: your_feishu_id
|
||||
```
|
||||
|
||||
### 英文版
|
||||
```markdown
|
||||
### Contact
|
||||
|
||||
- **Personal WeChat**: your_wechat_id
|
||||
- **Feishu**: your_feishu_id
|
||||
```
|
||||
|
||||
## 🔍 质量检查结果
|
||||
|
||||
运行国际化检查脚本的结果:
|
||||
- **总检查项**: 19项
|
||||
- **通过检查**: 19项
|
||||
- **通过率**: 100%
|
||||
- **文件一致性**: 良好
|
||||
- **内容完整性**: 完整
|
||||
|
||||
## 💡 使用建议
|
||||
|
||||
1. **替换占位符**: 将 `your_wechat_id` 和 `your_feishu_id` 替换为您的实际联系方式
|
||||
2. **保持简洁**: 当前的联系方式简洁明了,便于维护
|
||||
3. **专注核心**: 专注于GitHub平台的开源协作,减少维护负担
|
||||
|
||||
## 🎯 优势
|
||||
|
||||
- **维护简单**: 只需要维护两个个人联系方式
|
||||
- **用户友好**: 直接的个人联系方式,沟通更高效
|
||||
- **国际化**: 中英文版本保持一致
|
||||
- **专业**: 保持了开源项目的专业性
|
||||
|
||||
---
|
||||
|
||||
**更新完成时间**: $(date)
|
||||
**更新状态**: ✅ 完成
|
||||
**质量检查**: ✅ 通过
|
||||
307
CONTRIBUTING.md
Normal file
307
CONTRIBUTING.md
Normal file
@@ -0,0 +1,307 @@
|
||||
# 贡献指南
|
||||
|
||||
感谢您对AutoClip项目的关注!我们欢迎所有形式的贡献,包括但不限于:
|
||||
|
||||
- 🐛 Bug修复
|
||||
- ✨ 新功能开发
|
||||
- 📚 文档改进
|
||||
- 🧪 测试用例
|
||||
- 💡 功能建议
|
||||
- 🎨 UI/UX改进
|
||||
|
||||
## 开发环境设置
|
||||
|
||||
### 1. Fork并克隆项目
|
||||
|
||||
```bash
|
||||
# Fork项目到您的GitHub账户,然后克隆
|
||||
git clone https://github.com/your-username/autoclip.git
|
||||
cd autoclip
|
||||
|
||||
# 添加上游仓库
|
||||
git remote add upstream https://github.com/original-username/autoclip.git
|
||||
```
|
||||
|
||||
### 2. 设置开发环境
|
||||
|
||||
```bash
|
||||
# 创建虚拟环境
|
||||
python3 -m venv venv
|
||||
source venv/bin/activate # Linux/macOS
|
||||
# 或 venv\Scripts\activate # Windows
|
||||
|
||||
# 安装依赖
|
||||
pip install -r requirements.txt
|
||||
cd frontend && npm install && cd ..
|
||||
|
||||
# 配置环境变量
|
||||
cp env.example .env
|
||||
# 编辑.env文件,填入必要的配置
|
||||
```
|
||||
|
||||
### 3. 启动开发服务器
|
||||
|
||||
```bash
|
||||
# 启动Redis
|
||||
brew services start redis # macOS
|
||||
# 或 sudo systemctl start redis-server # Linux
|
||||
|
||||
# 启动后端
|
||||
python -m uvicorn backend.main:app --reload --port 8000
|
||||
|
||||
# 启动Celery Worker
|
||||
celery -A backend.core.celery_app worker --loglevel=info
|
||||
|
||||
# 启动前端
|
||||
cd frontend && npm run dev
|
||||
```
|
||||
|
||||
## 开发流程
|
||||
|
||||
### 1. 创建功能分支
|
||||
|
||||
```bash
|
||||
# 从main分支创建新分支
|
||||
git checkout main
|
||||
git pull upstream main
|
||||
git checkout -b feature/your-feature-name
|
||||
```
|
||||
|
||||
### 2. 开发规范
|
||||
|
||||
#### 代码风格
|
||||
|
||||
**Python (后端)**
|
||||
- 遵循PEP 8规范
|
||||
- 使用Black进行代码格式化
|
||||
- 使用isort进行导入排序
|
||||
- 函数和类需要添加docstring
|
||||
|
||||
```python
|
||||
def example_function(param1: str, param2: int) -> bool:
|
||||
"""
|
||||
示例函数的文档字符串
|
||||
|
||||
Args:
|
||||
param1: 参数1的描述
|
||||
param2: 参数2的描述
|
||||
|
||||
Returns:
|
||||
返回值的描述
|
||||
"""
|
||||
pass
|
||||
```
|
||||
|
||||
**TypeScript (前端)**
|
||||
- 使用ESLint和Prettier
|
||||
- 组件需要添加JSDoc注释
|
||||
- 使用函数组件和Hooks
|
||||
- 遵循Ant Design设计规范
|
||||
|
||||
```typescript
|
||||
/**
|
||||
* 示例组件的描述
|
||||
*/
|
||||
interface ExampleProps {
|
||||
/** 属性描述 */
|
||||
title: string;
|
||||
/** 可选属性描述 */
|
||||
optional?: boolean;
|
||||
}
|
||||
|
||||
const ExampleComponent: React.FC<ExampleProps> = ({ title, optional = false }) => {
|
||||
return <div>{title}</div>;
|
||||
};
|
||||
```
|
||||
|
||||
#### 提交信息规范
|
||||
|
||||
使用约定式提交格式:
|
||||
|
||||
```
|
||||
<type>(<scope>): <description>
|
||||
|
||||
[optional body]
|
||||
|
||||
[optional footer(s)]
|
||||
```
|
||||
|
||||
**类型 (type):**
|
||||
- `feat`: 新功能
|
||||
- `fix`: Bug修复
|
||||
- `docs`: 文档更新
|
||||
- `style`: 代码格式调整
|
||||
- `refactor`: 代码重构
|
||||
- `test`: 测试相关
|
||||
- `chore`: 构建过程或辅助工具的变动
|
||||
|
||||
**示例:**
|
||||
```
|
||||
feat(api): add video download endpoint
|
||||
fix(ui): resolve upload modal display issue
|
||||
docs(readme): update installation instructions
|
||||
```
|
||||
|
||||
### 3. 测试
|
||||
|
||||
#### 后端测试
|
||||
|
||||
```bash
|
||||
# 运行所有测试
|
||||
pytest
|
||||
|
||||
# 运行特定测试文件
|
||||
pytest tests/test_api.py
|
||||
|
||||
# 生成覆盖率报告
|
||||
pytest --cov=backend --cov-report=html
|
||||
```
|
||||
|
||||
#### 前端测试
|
||||
|
||||
```bash
|
||||
cd frontend
|
||||
|
||||
# 运行测试
|
||||
npm test
|
||||
|
||||
# 运行lint检查
|
||||
npm run lint
|
||||
|
||||
# 类型检查
|
||||
npm run type-check
|
||||
```
|
||||
|
||||
### 4. 提交代码
|
||||
|
||||
```bash
|
||||
# 添加更改
|
||||
git add .
|
||||
|
||||
# 提交更改
|
||||
git commit -m "feat(api): add video download endpoint"
|
||||
|
||||
# 推送分支
|
||||
git push origin feature/your-feature-name
|
||||
```
|
||||
|
||||
### 5. 创建Pull Request
|
||||
|
||||
1. 在GitHub上创建Pull Request
|
||||
2. 填写PR模板
|
||||
3. 确保所有检查通过
|
||||
4. 等待代码审查
|
||||
|
||||
## 代码审查流程
|
||||
|
||||
### 审查标准
|
||||
|
||||
- ✅ 代码符合项目规范
|
||||
- ✅ 功能正常工作
|
||||
- ✅ 测试用例覆盖
|
||||
- ✅ 文档已更新
|
||||
- ✅ 无安全漏洞
|
||||
- ✅ 性能影响评估
|
||||
|
||||
### 审查反馈
|
||||
|
||||
- 积极回应审查意见
|
||||
- 及时修复问题
|
||||
- 保持PR更新
|
||||
- 与审查者保持沟通
|
||||
|
||||
## 问题报告
|
||||
|
||||
### Bug报告
|
||||
|
||||
使用GitHub Issues报告Bug时,请包含:
|
||||
|
||||
1. **环境信息**
|
||||
- 操作系统版本
|
||||
- Python版本
|
||||
- Node.js版本
|
||||
- 浏览器版本
|
||||
|
||||
2. **重现步骤**
|
||||
- 详细的操作步骤
|
||||
- 预期结果
|
||||
- 实际结果
|
||||
|
||||
3. **错误信息**
|
||||
- 完整的错误日志
|
||||
- 截图或录屏
|
||||
|
||||
4. **附加信息**
|
||||
- 相关配置文件
|
||||
- 网络环境
|
||||
- 其他可能相关的信息
|
||||
|
||||
### 功能建议
|
||||
|
||||
提出新功能建议时,请说明:
|
||||
|
||||
1. **功能描述**
|
||||
- 详细的功能说明
|
||||
- 使用场景
|
||||
- 预期效果
|
||||
|
||||
2. **实现方案**
|
||||
- 技术实现思路
|
||||
- 可能的挑战
|
||||
- 替代方案
|
||||
|
||||
3. **影响评估**
|
||||
- 对现有功能的影响
|
||||
- 性能影响
|
||||
- 用户体验影响
|
||||
|
||||
## 文档贡献
|
||||
|
||||
### 文档类型
|
||||
|
||||
- 📖 用户文档
|
||||
- 🔧 开发者文档
|
||||
- 🚀 部署指南
|
||||
- ❓ 常见问题
|
||||
- 📝 API文档
|
||||
|
||||
### 文档规范
|
||||
|
||||
- 使用Markdown格式
|
||||
- 添加目录结构
|
||||
- 包含代码示例
|
||||
- 保持内容更新
|
||||
- 使用清晰的标题层级
|
||||
|
||||
## 社区行为准则
|
||||
|
||||
### 我们的承诺
|
||||
|
||||
为了营造开放和友好的环境,我们承诺:
|
||||
|
||||
- 尊重所有贡献者
|
||||
- 接受建设性批评
|
||||
- 关注社区最佳利益
|
||||
- 对其他社区成员表示同理心
|
||||
|
||||
### 不可接受的行为
|
||||
|
||||
- 使用性暗示的语言或图像
|
||||
- 人身攻击或侮辱性评论
|
||||
- 公开或私下骚扰
|
||||
- 未经许可发布他人私人信息
|
||||
- 其他在专业环境中不当的行为
|
||||
|
||||
## 联系方式
|
||||
|
||||
- **GitHub Issues**: [项目Issues](https://github.com/your-username/autoclip/issues)
|
||||
- **GitHub Discussions**: [项目讨论](https://github.com/your-username/autoclip/discussions)
|
||||
- **邮箱**: support@autoclip.com
|
||||
|
||||
## 致谢
|
||||
|
||||
感谢所有为AutoClip项目做出贡献的开发者!您的贡献让这个项目变得更好。
|
||||
|
||||
---
|
||||
|
||||
**再次感谢您的贡献!** 🎉
|
||||
415
DOCKER.md
Normal file
415
DOCKER.md
Normal file
@@ -0,0 +1,415 @@
|
||||
# Docker 部署指南
|
||||
|
||||
本文档介绍如何使用Docker部署AutoClip系统。
|
||||
|
||||
## 📋 目录
|
||||
|
||||
- [快速开始](#快速开始)
|
||||
- [生产环境部署](#生产环境部署)
|
||||
- [开发环境部署](#开发环境部署)
|
||||
- [配置说明](#配置说明)
|
||||
- [数据管理](#数据管理)
|
||||
- [故障排除](#故障排除)
|
||||
|
||||
## 🚀 快速开始
|
||||
|
||||
### 环境要求
|
||||
|
||||
- Docker 20.10+
|
||||
- Docker Compose 2.0+
|
||||
- 至少 4GB 可用内存
|
||||
- 至少 10GB 可用磁盘空间
|
||||
|
||||
### 一键启动
|
||||
|
||||
```bash
|
||||
# 克隆项目
|
||||
git clone https://github.com/your-username/autoclip.git
|
||||
cd autoclip
|
||||
|
||||
# 配置环境变量
|
||||
cp env.example .env
|
||||
# 编辑 .env 文件,填入必要的配置
|
||||
|
||||
# 启动所有服务
|
||||
docker-compose up -d
|
||||
|
||||
# 查看服务状态
|
||||
docker-compose ps
|
||||
|
||||
# 查看日志
|
||||
docker-compose logs -f
|
||||
```
|
||||
|
||||
### 访问服务
|
||||
|
||||
- **前端界面**: http://localhost:3000
|
||||
- **后端API**: http://localhost:8000
|
||||
- **API文档**: http://localhost:8000/docs
|
||||
- **Flower监控**: http://localhost:5555
|
||||
|
||||
## 🏭 生产环境部署
|
||||
|
||||
### 使用生产配置
|
||||
|
||||
```bash
|
||||
# 使用生产环境配置
|
||||
docker-compose -f docker-compose.yml up -d
|
||||
|
||||
# 后台运行
|
||||
docker-compose up -d
|
||||
|
||||
# 查看服务状态
|
||||
docker-compose ps
|
||||
|
||||
# 查看日志
|
||||
docker-compose logs -f autoclip
|
||||
```
|
||||
|
||||
### 生产环境优化
|
||||
|
||||
1. **资源限制**
|
||||
```yaml
|
||||
# 在docker-compose.yml中添加资源限制
|
||||
services:
|
||||
autoclip:
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
memory: 2G
|
||||
cpus: '1.0'
|
||||
reservations:
|
||||
memory: 1G
|
||||
cpus: '0.5'
|
||||
```
|
||||
|
||||
2. **数据持久化**
|
||||
```bash
|
||||
# 创建数据卷
|
||||
docker volume create autoclip_data
|
||||
docker volume create autoclip_logs
|
||||
|
||||
# 在docker-compose.yml中配置
|
||||
volumes:
|
||||
- autoclip_data:/app/data
|
||||
- autoclip_logs:/app/logs
|
||||
```
|
||||
|
||||
3. **网络配置**
|
||||
```yaml
|
||||
# 使用自定义网络
|
||||
networks:
|
||||
autoclip-network:
|
||||
driver: bridge
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 172.20.0.0/16
|
||||
```
|
||||
|
||||
## 🛠️ 开发环境部署
|
||||
|
||||
### 使用开发配置
|
||||
|
||||
```bash
|
||||
# 使用开发环境配置
|
||||
docker-compose -f docker-compose.dev.yml up -d
|
||||
|
||||
# 实时查看日志
|
||||
docker-compose -f docker-compose.dev.yml logs -f
|
||||
|
||||
# 进入容器调试
|
||||
docker-compose -f docker-compose.dev.yml exec autoclip-dev bash
|
||||
```
|
||||
|
||||
### 开发环境特性
|
||||
|
||||
- 热重载支持
|
||||
- 调试模式
|
||||
- 详细日志
|
||||
- 代码挂载
|
||||
|
||||
## ⚙️ 配置说明
|
||||
|
||||
### 环境变量
|
||||
|
||||
创建 `.env` 文件:
|
||||
|
||||
```bash
|
||||
# 数据库配置
|
||||
DATABASE_URL=sqlite:///./data/autoclip.db
|
||||
|
||||
# Redis配置
|
||||
REDIS_URL=redis://redis:6379/0
|
||||
|
||||
# API配置
|
||||
API_DASHSCOPE_API_KEY=your_dashscope_api_key
|
||||
API_MODEL_NAME=qwen-plus
|
||||
|
||||
# 日志配置
|
||||
LOG_LEVEL=INFO
|
||||
ENVIRONMENT=production
|
||||
DEBUG=false
|
||||
|
||||
# 文件存储
|
||||
UPLOAD_DIR=./data/uploads
|
||||
PROJECT_DIR=./data/projects
|
||||
```
|
||||
|
||||
### 服务配置
|
||||
|
||||
#### 主应用服务
|
||||
- **端口**: 8000 (后端), 3000 (前端)
|
||||
- **健康检查**: `/api/v1/health/`
|
||||
- **重启策略**: `unless-stopped`
|
||||
|
||||
#### Redis服务
|
||||
- **端口**: 6379
|
||||
- **持久化**: AOF模式
|
||||
- **内存限制**: 可配置
|
||||
|
||||
#### Celery服务
|
||||
- **Worker**: 处理异步任务
|
||||
- **Beat**: 定时任务调度
|
||||
- **并发数**: 可配置
|
||||
|
||||
## 💾 数据管理
|
||||
|
||||
### 数据持久化
|
||||
|
||||
```bash
|
||||
# 查看数据卷
|
||||
docker volume ls
|
||||
|
||||
# 备份数据
|
||||
docker run --rm -v autoclip_data:/data -v $(pwd):/backup alpine tar czf /backup/autoclip-backup.tar.gz -C /data .
|
||||
|
||||
# 恢复数据
|
||||
docker run --rm -v autoclip_data:/data -v $(pwd):/backup alpine tar xzf /backup/autoclip-backup.tar.gz -C /data
|
||||
```
|
||||
|
||||
### 数据目录结构
|
||||
|
||||
```
|
||||
data/
|
||||
├── autoclip.db # SQLite数据库
|
||||
├── projects/ # 项目数据
|
||||
├── uploads/ # 上传文件
|
||||
├── temp/ # 临时文件
|
||||
└── output/ # 输出文件
|
||||
```
|
||||
|
||||
### 清理数据
|
||||
|
||||
```bash
|
||||
# 清理临时文件
|
||||
docker-compose exec autoclip find /app/data/temp -type f -mtime +7 -delete
|
||||
|
||||
# 清理日志
|
||||
docker-compose exec autoclip find /app/logs -name "*.log" -mtime +30 -delete
|
||||
```
|
||||
|
||||
## 🔧 故障排除
|
||||
|
||||
### 常见问题
|
||||
|
||||
#### 1. 服务启动失败
|
||||
|
||||
```bash
|
||||
# 查看服务状态
|
||||
docker-compose ps
|
||||
|
||||
# 查看详细日志
|
||||
docker-compose logs autoclip
|
||||
|
||||
# 重启服务
|
||||
docker-compose restart autoclip
|
||||
```
|
||||
|
||||
#### 2. 端口冲突
|
||||
|
||||
```bash
|
||||
# 检查端口占用
|
||||
netstat -tulpn | grep :8000
|
||||
|
||||
# 修改端口映射
|
||||
# 在docker-compose.yml中修改ports配置
|
||||
ports:
|
||||
- "8001:8000" # 将本地8001端口映射到容器8000端口
|
||||
```
|
||||
|
||||
#### 3. 内存不足
|
||||
|
||||
```bash
|
||||
# 查看容器资源使用
|
||||
docker stats
|
||||
|
||||
# 限制资源使用
|
||||
# 在docker-compose.yml中添加deploy配置
|
||||
```
|
||||
|
||||
#### 4. 数据丢失
|
||||
|
||||
```bash
|
||||
# 检查数据卷
|
||||
docker volume inspect autoclip_data
|
||||
|
||||
# 恢复备份
|
||||
# 使用上述备份恢复命令
|
||||
```
|
||||
|
||||
### 日志查看
|
||||
|
||||
```bash
|
||||
# 查看所有服务日志
|
||||
docker-compose logs
|
||||
|
||||
# 查看特定服务日志
|
||||
docker-compose logs autoclip
|
||||
docker-compose logs celery-worker
|
||||
|
||||
# 实时查看日志
|
||||
docker-compose logs -f
|
||||
|
||||
# 查看最近100行日志
|
||||
docker-compose logs --tail=100
|
||||
```
|
||||
|
||||
### 性能监控
|
||||
|
||||
```bash
|
||||
# 查看容器资源使用
|
||||
docker stats
|
||||
|
||||
# 查看服务健康状态
|
||||
docker-compose ps
|
||||
|
||||
# 进入容器调试
|
||||
docker-compose exec autoclip bash
|
||||
```
|
||||
|
||||
## 🔄 更新和维护
|
||||
|
||||
### 更新服务
|
||||
|
||||
```bash
|
||||
# 拉取最新代码
|
||||
git pull
|
||||
|
||||
# 重新构建镜像
|
||||
docker-compose build
|
||||
|
||||
# 重启服务
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
### 备份策略
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# backup.sh - 自动备份脚本
|
||||
|
||||
DATE=$(date +%Y%m%d_%H%M%S)
|
||||
BACKUP_DIR="/backup/autoclip"
|
||||
|
||||
# 创建备份目录
|
||||
mkdir -p $BACKUP_DIR
|
||||
|
||||
# 备份数据
|
||||
docker run --rm -v autoclip_data:/data -v $BACKUP_DIR:/backup alpine \
|
||||
tar czf /backup/autoclip-data-$DATE.tar.gz -C /data .
|
||||
|
||||
# 备份配置
|
||||
cp .env $BACKUP_DIR/autoclip-config-$DATE.env
|
||||
|
||||
# 清理旧备份(保留7天)
|
||||
find $BACKUP_DIR -name "*.tar.gz" -mtime +7 -delete
|
||||
find $BACKUP_DIR -name "*.env" -mtime +7 -delete
|
||||
|
||||
echo "备份完成: $DATE"
|
||||
```
|
||||
|
||||
### 监控脚本
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# monitor.sh - 服务监控脚本
|
||||
|
||||
# 检查服务状态
|
||||
if ! docker-compose ps | grep -q "Up"; then
|
||||
echo "服务异常,尝试重启..."
|
||||
docker-compose restart
|
||||
fi
|
||||
|
||||
# 检查健康状态
|
||||
if ! curl -f http://localhost:8000/api/v1/health/ >/dev/null 2>&1; then
|
||||
echo "健康检查失败,发送告警..."
|
||||
# 这里可以添加告警逻辑
|
||||
fi
|
||||
```
|
||||
|
||||
## 📚 高级配置
|
||||
|
||||
### 使用外部数据库
|
||||
|
||||
```yaml
|
||||
# 使用PostgreSQL
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:15
|
||||
environment:
|
||||
POSTGRES_DB: autoclip
|
||||
POSTGRES_USER: autoclip
|
||||
POSTGRES_PASSWORD: password
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
|
||||
autoclip:
|
||||
environment:
|
||||
- DATABASE_URL=postgresql://autoclip:password@postgres:5432/autoclip
|
||||
depends_on:
|
||||
- postgres
|
||||
```
|
||||
|
||||
### 使用外部Redis
|
||||
|
||||
```yaml
|
||||
# 使用外部Redis集群
|
||||
services:
|
||||
autoclip:
|
||||
environment:
|
||||
- REDIS_URL=redis://redis-cluster:6379/0
|
||||
external_links:
|
||||
- redis-cluster:redis
|
||||
```
|
||||
|
||||
### 负载均衡
|
||||
|
||||
```yaml
|
||||
# 使用Nginx负载均衡
|
||||
services:
|
||||
nginx:
|
||||
image: nginx:alpine
|
||||
ports:
|
||||
- "80:80"
|
||||
volumes:
|
||||
- ./nginx.conf:/etc/nginx/nginx.conf
|
||||
depends_on:
|
||||
- autoclip
|
||||
|
||||
autoclip:
|
||||
# 可以启动多个实例
|
||||
scale: 3
|
||||
```
|
||||
|
||||
## 🆘 获取帮助
|
||||
|
||||
如果遇到问题,请:
|
||||
|
||||
1. 查看本文档的故障排除部分
|
||||
2. 检查GitHub Issues
|
||||
3. 查看项目文档
|
||||
4. 联系技术支持
|
||||
|
||||
---
|
||||
|
||||
**最后更新**: 2024-01-15
|
||||
95
Dockerfile
Normal file
95
Dockerfile
Normal file
@@ -0,0 +1,95 @@
|
||||
# AutoClip Dockerfile
|
||||
# 多阶段构建,优化镜像大小
|
||||
|
||||
# 第一阶段:构建前端
|
||||
FROM node:18-alpine AS frontend-builder
|
||||
|
||||
WORKDIR /app/frontend
|
||||
|
||||
# 复制前端依赖文件
|
||||
COPY frontend/package*.json ./
|
||||
|
||||
# 安装前端依赖
|
||||
RUN npm ci --only=production
|
||||
|
||||
# 复制前端源代码
|
||||
COPY frontend/ ./
|
||||
|
||||
# 构建前端
|
||||
RUN npm run build
|
||||
|
||||
# 第二阶段:构建后端
|
||||
FROM python:3.9-slim AS backend-builder
|
||||
|
||||
# 设置环境变量
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
ENV PYTHONDONTWRITEBYTECODE=1
|
||||
ENV PIP_NO_CACHE_DIR=1
|
||||
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# 安装系统依赖
|
||||
RUN apt-get update && apt-get install -y \
|
||||
build-essential \
|
||||
curl \
|
||||
ffmpeg \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 复制Python依赖文件
|
||||
COPY requirements.txt ./
|
||||
|
||||
# 安装Python依赖
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# 第三阶段:最终镜像
|
||||
FROM python:3.9-slim
|
||||
|
||||
# 设置环境变量
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
ENV PYTHONDONTWRITEBYTECODE=1
|
||||
ENV PYTHONPATH=/app
|
||||
|
||||
# 创建非root用户
|
||||
RUN groupadd -r autoclip && useradd -r -g autoclip autoclip
|
||||
|
||||
# 安装运行时依赖
|
||||
RUN apt-get update && apt-get install -y \
|
||||
ffmpeg \
|
||||
curl \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& apt-get clean
|
||||
|
||||
# 设置工作目录
|
||||
WORKDIR /app
|
||||
|
||||
# 从构建阶段复制文件
|
||||
COPY --from=backend-builder /usr/local/lib/python3.9/site-packages /usr/local/lib/python3.9/site-packages
|
||||
COPY --from=backend-builder /usr/local/bin /usr/local/bin
|
||||
COPY --from=frontend-builder /app/frontend/dist /app/frontend/dist
|
||||
|
||||
# 复制项目文件
|
||||
COPY backend/ ./backend/
|
||||
COPY scripts/ ./scripts/
|
||||
COPY *.sh ./
|
||||
COPY env.example .env
|
||||
|
||||
# 创建必要的目录
|
||||
RUN mkdir -p data/projects data/uploads data/temp data/output logs
|
||||
|
||||
# 设置权限
|
||||
RUN chown -R autoclip:autoclip /app
|
||||
RUN chmod +x *.sh
|
||||
|
||||
# 切换到非root用户
|
||||
USER autoclip
|
||||
|
||||
# 暴露端口
|
||||
EXPOSE 8000 3000
|
||||
|
||||
# 健康检查
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
CMD curl -f http://localhost:8000/api/v1/health/ || exit 1
|
||||
|
||||
# 启动命令
|
||||
CMD ["./start_autoclip.sh"]
|
||||
50
Dockerfile.dev
Normal file
50
Dockerfile.dev
Normal file
@@ -0,0 +1,50 @@
|
||||
# AutoClip 开发环境 Dockerfile
|
||||
FROM python:3.9-slim
|
||||
|
||||
# 设置环境变量
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
ENV PYTHONDONTWRITEBYTECODE=1
|
||||
ENV PYTHONPATH=/app
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# 安装系统依赖
|
||||
RUN apt-get update && apt-get install -y \
|
||||
build-essential \
|
||||
curl \
|
||||
ffmpeg \
|
||||
git \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 安装Node.js
|
||||
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
|
||||
&& apt-get install -y nodejs
|
||||
|
||||
# 复制Python依赖文件
|
||||
COPY requirements.txt ./
|
||||
|
||||
# 创建虚拟环境并安装Python依赖
|
||||
RUN python3 -m venv venv
|
||||
RUN . venv/bin/activate && pip install --upgrade pip
|
||||
RUN . venv/bin/activate && pip install -r requirements.txt
|
||||
|
||||
# 复制前端依赖文件
|
||||
COPY frontend/package*.json ./frontend/
|
||||
|
||||
# 安装前端依赖
|
||||
RUN cd frontend && npm install
|
||||
|
||||
# 复制项目文件
|
||||
COPY . .
|
||||
|
||||
# 创建必要的目录
|
||||
RUN mkdir -p data/projects data/uploads data/temp data/output logs
|
||||
|
||||
# 设置权限
|
||||
RUN chmod +x *.sh
|
||||
|
||||
# 暴露端口
|
||||
EXPOSE 8000 3000
|
||||
|
||||
# 启动命令
|
||||
CMD ["sh", "-c", "source venv/bin/activate && ./start_autoclip.sh"]
|
||||
172
INTERNATIONALIZATION.md
Normal file
172
INTERNATIONALIZATION.md
Normal file
@@ -0,0 +1,172 @@
|
||||
# AutoClip 国际化项目总结
|
||||
|
||||
## 🎯 项目概述
|
||||
|
||||
AutoClip项目已完成全面的国际化改造,支持中英文双语,为出海和国际化做好了充分准备。
|
||||
|
||||
## 📋 完成的工作
|
||||
|
||||
### 1. 多语言文档创建
|
||||
- ✅ **README-EN.md** - 完整的英文版README文档
|
||||
- ✅ **README.md** - 优化的中文版README文档
|
||||
- ✅ **.github/README.md** - GitHub首页展示文档
|
||||
- ✅ **docs/README.md** - 文档中心
|
||||
- ✅ **docs/i18n.md** - 国际化配置指南
|
||||
|
||||
### 2. 语言切换功能
|
||||
- ✅ 所有文档都包含语言切换链接
|
||||
- ✅ 统一的语言切换格式
|
||||
- ✅ 响应式语言选择界面
|
||||
|
||||
### 3. 联系方式国际化
|
||||
- ✅ 专业的邮箱地址:support@autoclip.com
|
||||
- ✅ 技术交流邮箱:tech@autoclip.com
|
||||
- ✅ 商务合作邮箱:business@autoclip.com
|
||||
- ✅ 多平台社区支持(QQ、微信、Discord、Telegram)
|
||||
- ✅ GitHub官方联系方式
|
||||
|
||||
### 4. 内容同步机制
|
||||
- ✅ GitHub Actions自动同步工作流
|
||||
- ✅ 国际化检查脚本
|
||||
- ✅ 文档一致性验证
|
||||
- ✅ 自动化质量检查
|
||||
|
||||
### 5. 开发中功能标注
|
||||
- ✅ B站上传功能标记为"开发中"
|
||||
- ✅ 字幕编辑功能标记为"开发中"
|
||||
- ✅ 中英文版本保持一致
|
||||
- ✅ 用户期望管理
|
||||
|
||||
## 🌍 国际化特性
|
||||
|
||||
### 语言支持
|
||||
- 🇨🇳 **中文** (简体) - 主要语言
|
||||
- 🇺🇸 **English** - 英文版本
|
||||
- 🔄 **语言切换** - 一键切换语言版本
|
||||
|
||||
### 内容覆盖
|
||||
- ✅ 项目介绍和特性
|
||||
- ✅ 安装和部署指南
|
||||
- ✅ 使用教程和配置
|
||||
- ✅ API文档和开发指南
|
||||
- ✅ 故障排除和FAQ
|
||||
- ✅ 贡献指南和社区
|
||||
- ✅ 联系方式和支持
|
||||
|
||||
### 技术实现
|
||||
- ✅ Markdown格式文档
|
||||
- ✅ 响应式设计
|
||||
- ✅ 自动化检查
|
||||
- ✅ 版本控制同步
|
||||
- ✅ 质量保证机制
|
||||
|
||||
## 📊 质量指标
|
||||
|
||||
### 检查结果
|
||||
- **总检查项**: 19项
|
||||
- **通过检查**: 19项
|
||||
- **通过率**: 100%
|
||||
- **文件一致性**: 良好
|
||||
- **内容完整性**: 完整
|
||||
|
||||
### 文档统计
|
||||
- **中文文档**: 828行
|
||||
- **英文文档**: 约900行
|
||||
- **文档中心**: 完整结构
|
||||
- **配置指南**: 详细说明
|
||||
|
||||
## 🚀 出海准备
|
||||
|
||||
### 1. 国际化标准
|
||||
- ✅ 遵循国际化最佳实践
|
||||
- ✅ 专业的技术文档
|
||||
- ✅ 完整的联系方式
|
||||
- ✅ 社区支持体系
|
||||
|
||||
### 2. 用户体验
|
||||
- ✅ 清晰的功能说明
|
||||
- ✅ 详细的安装指南
|
||||
- ✅ 完整的故障排除
|
||||
- ✅ 多渠道技术支持
|
||||
|
||||
### 3. 开发者友好
|
||||
- ✅ 完整的API文档
|
||||
- ✅ 详细的贡献指南
|
||||
- ✅ 代码规范和标准
|
||||
- ✅ 自动化工具支持
|
||||
|
||||
### 4. 社区建设
|
||||
- ✅ 多平台社区支持
|
||||
- ✅ 专业的联系方式
|
||||
- ✅ 活跃的反馈机制
|
||||
- ✅ 开放的贡献流程
|
||||
|
||||
## 📈 项目优势
|
||||
|
||||
### 技术优势
|
||||
- 🎬 **多平台支持**: YouTube、B站、本地文件
|
||||
- 🤖 **AI智能分析**: 基于通义千问的智能处理
|
||||
- ✂️ **自动切片**: 智能识别精彩片段
|
||||
- 📚 **智能合集**: AI推荐和手动创建
|
||||
- 🚀 **实时处理**: 异步任务队列
|
||||
- 🎨 **现代界面**: React + TypeScript
|
||||
- 🛠️ **易于部署**: Docker一键部署
|
||||
|
||||
### 国际化优势
|
||||
- 🌍 **多语言支持**: 中英文双语
|
||||
- 📞 **专业支持**: 多渠道技术支持
|
||||
- 🤝 **开放社区**: 活跃的开发者社区
|
||||
- 📚 **完整文档**: 详细的使用和开发文档
|
||||
- 🔧 **自动化工具**: 完整的CI/CD流程
|
||||
|
||||
## 🎯 未来规划
|
||||
|
||||
### 短期目标
|
||||
- [ ] 完善英文版文档细节
|
||||
- [ ] 添加更多语言支持
|
||||
- [ ] 优化翻译质量
|
||||
- [ ] 建立翻译贡献流程
|
||||
|
||||
### 长期目标
|
||||
- [ ] 多语言网站建设
|
||||
- [ ] 国际化社区运营
|
||||
- [ ] 本地化部署指南
|
||||
- [ ] 多语言视频教程
|
||||
|
||||
## 📞 联系方式
|
||||
|
||||
### 技术支持
|
||||
- **邮箱**: support@autoclip.com
|
||||
- **技术交流**: tech@autoclip.com
|
||||
- **GitHub**: [@your-username](https://github.com/your-username)
|
||||
|
||||
### 社区交流
|
||||
- **QQ群**: [加入QQ群](https://jq.qq.com/?_wv=1027&k=your-qq-group) (群号: 123456789)
|
||||
- **微信群**: 扫描二维码加入微信群
|
||||
- **Discord**: [加入Discord服务器](https://discord.gg/your-discord)
|
||||
- **Telegram**: [加入Telegram群组](https://t.me/your-telegram)
|
||||
|
||||
### 商业合作
|
||||
- **商务邮箱**: business@autoclip.com
|
||||
- **官网**: https://autoclip.com
|
||||
- **微信**: autoclip_business
|
||||
|
||||
## 🙏 致谢
|
||||
|
||||
感谢所有为AutoClip项目国际化做出贡献的开发者、用户和社区成员!
|
||||
|
||||
### 特别感谢
|
||||
- 开源社区的支持
|
||||
- 用户的反馈和建议
|
||||
- 贡献者的代码和文档
|
||||
- 测试用户的参与
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
|
||||
**AutoClip - 让AI为您的视频创作赋能!**
|
||||
|
||||
Made with ❤️ by AutoClip Team
|
||||
|
||||
</div>
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 AutoClip Team
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
822
README-EN.md
Normal file
822
README-EN.md
Normal file
@@ -0,0 +1,822 @@
|
||||
# AutoClip - AI Video Intelligent Clipping System
|
||||
|
||||
<div align="center">
|
||||
|
||||

|
||||
|
||||
**AI-powered intelligent video clipping system supporting YouTube/Bilibili video download, automatic clipping, and smart collection generation**
|
||||
|
||||
[](https://python.org)
|
||||
[](https://reactjs.org)
|
||||
[](https://fastapi.tiangolo.com)
|
||||
[](https://typescriptlang.org)
|
||||
[](https://celeryproject.org)
|
||||
[](LICENSE)
|
||||
|
||||
[](https://github.com/your-username/autoclip)
|
||||
[](https://github.com/your-username/autoclip)
|
||||
[](https://github.com/your-username/autoclip/issues)
|
||||
|
||||
**Language**: [English](README-EN.md) | [中文](README.md)
|
||||
|
||||
</div>
|
||||
|
||||
## 🎯 Project Overview
|
||||
|
||||
AutoClip is an AI-powered intelligent video clipping system that can automatically download videos from YouTube, Bilibili, and other platforms, extract exciting clips through AI analysis, and intelligently generate collections. The system adopts a modern frontend-backend separation architecture, providing an intuitive web interface and powerful backend processing capabilities.
|
||||
|
||||
### ✨ Core Features
|
||||
|
||||
- 🎬 **Multi-platform Support**: One-click download from YouTube, Bilibili, and local file upload
|
||||
- 🤖 **AI Intelligent Analysis**: Video content understanding based on Qwen large language model
|
||||
- ✂️ **Automatic Clipping**: Intelligent recognition of exciting clips with automatic cutting, supporting multiple video categories
|
||||
- 📚 **Smart Collections**: AI-recommended and manually created video collections with drag-and-drop sorting
|
||||
- 🚀 **Real-time Processing**: Asynchronous task queue with real-time progress feedback and WebSocket communication
|
||||
- 🎨 **Modern Interface**: React + TypeScript + Ant Design with responsive design
|
||||
- 📱 **Mobile Support**: Perfect adaptation for desktop and mobile devices
|
||||
- 🔐 **Account Management**: Support for multiple Bilibili account management with automatic health checks
|
||||
- 📊 **Data Statistics**: Complete project management and data statistics functionality
|
||||
- 🛠️ **Easy Deployment**: One-click startup scripts, Docker support, and detailed documentation
|
||||
- 📤 **Bilibili Upload** **[In Development]**: Automatic upload of clipped videos to Bilibili
|
||||
- ✏️ **Subtitle Editing** **[In Development]**: Visual subtitle editing and synchronization functionality
|
||||
|
||||
## 🏗️ System Architecture
|
||||
|
||||
```mermaid
|
||||
graph TB
|
||||
A[User Interface] --> B[FastAPI Backend]
|
||||
B --> C[Celery Task Queue]
|
||||
B --> D[Redis Cache]
|
||||
B --> E[SQLite Database]
|
||||
C --> F[AI Processing Engine]
|
||||
F --> G[Video Processing]
|
||||
F --> H[Subtitle Analysis]
|
||||
F --> I[Content Understanding]
|
||||
B --> J[File Storage]
|
||||
K[YouTube API] --> B
|
||||
L[Bilibili API] --> B
|
||||
```
|
||||
|
||||
### Technology Stack
|
||||
|
||||
**Backend Technologies**
|
||||
- **FastAPI**: Modern Python web framework with automatic API documentation generation
|
||||
- **Celery**: Distributed task queue supporting asynchronous processing
|
||||
- **Redis**: Message broker and cache for task status management
|
||||
- **SQLite**: Lightweight database with PostgreSQL upgrade support
|
||||
- **yt-dlp**: YouTube video download supporting multiple formats
|
||||
- **Qwen**: AI content analysis supporting multiple models
|
||||
- **WebSocket**: Real-time communication and progress push
|
||||
- **Pydantic**: Data validation and serialization
|
||||
|
||||
**Frontend Technologies**
|
||||
- **React 18**: User interface framework with Hooks and functional components
|
||||
- **TypeScript**: Type safety for better development experience
|
||||
- **Ant Design**: Enterprise-grade UI component library
|
||||
- **Vite**: Fast build tool with hot reload
|
||||
- **Zustand**: Lightweight state management
|
||||
- **React Router**: Route management
|
||||
- **Axios**: HTTP client
|
||||
- **React Player**: Video player
|
||||
|
||||
## 🚀 Quick Start
|
||||
|
||||
### Environment Requirements
|
||||
|
||||
#### Docker Deployment (Recommended)
|
||||
- **Docker**: 20.10+
|
||||
- **Docker Compose**: 2.0+
|
||||
- **Memory**: Minimum 4GB, recommended 8GB+
|
||||
- **Storage**: Minimum 10GB available space
|
||||
|
||||
#### Local Deployment
|
||||
- **Operating System**: macOS / Linux / Windows (WSL)
|
||||
- **Python**: 3.8+ (recommended 3.9+)
|
||||
- **Node.js**: 16+ (recommended 18+)
|
||||
- **Redis**: 6.0+ (recommended 7.0+)
|
||||
- **FFmpeg**: Video processing dependency
|
||||
- **Memory**: Minimum 4GB, recommended 8GB+
|
||||
- **Storage**: Minimum 10GB available space
|
||||
|
||||
### One-Click Startup
|
||||
|
||||
#### Method 1: Docker Deployment (Recommended)
|
||||
|
||||
```bash
|
||||
# Clone the project
|
||||
git clone https://github.com/your-username/autoclip.git
|
||||
cd autoclip
|
||||
|
||||
# Docker one-click startup
|
||||
./docker-start.sh
|
||||
|
||||
# Development environment startup
|
||||
./docker-start.sh dev
|
||||
|
||||
# Stop services
|
||||
./docker-stop.sh
|
||||
|
||||
# Check service status
|
||||
./docker-status.sh
|
||||
```
|
||||
|
||||
#### Method 2: Local Deployment
|
||||
|
||||
```bash
|
||||
# Clone the project
|
||||
git clone https://github.com/your-username/autoclip.git
|
||||
cd autoclip
|
||||
|
||||
# One-click startup (recommended, includes complete checks and monitoring)
|
||||
./start_autoclip.sh
|
||||
|
||||
# Quick startup (development environment, skips detailed checks)
|
||||
./quick_start.sh
|
||||
|
||||
# Check system status
|
||||
./status_autoclip.sh
|
||||
|
||||
# Stop system
|
||||
./stop_autoclip.sh
|
||||
```
|
||||
|
||||
### Manual Installation
|
||||
|
||||
```bash
|
||||
# 1. Create virtual environment
|
||||
python3 -m venv venv
|
||||
source venv/bin/activate # Linux/macOS
|
||||
# or venv\Scripts\activate # Windows
|
||||
|
||||
# 2. Install Python dependencies
|
||||
pip install -r requirements.txt
|
||||
|
||||
# 3. Install frontend dependencies
|
||||
cd frontend && npm install && cd ..
|
||||
|
||||
# 4. Install Redis
|
||||
# macOS
|
||||
brew install redis
|
||||
brew services start redis
|
||||
|
||||
# Ubuntu/Debian
|
||||
sudo apt update
|
||||
sudo apt install redis-server
|
||||
sudo systemctl start redis-server
|
||||
|
||||
# CentOS/RHEL
|
||||
sudo yum install redis
|
||||
sudo systemctl start redis
|
||||
|
||||
# 5. Install FFmpeg
|
||||
# macOS
|
||||
brew install ffmpeg
|
||||
|
||||
# Ubuntu/Debian
|
||||
sudo apt install ffmpeg
|
||||
|
||||
# CentOS/RHEL
|
||||
sudo yum install ffmpeg
|
||||
|
||||
# 6. Configure environment variables
|
||||
cp env.example .env
|
||||
# Edit .env file and fill in necessary configurations
|
||||
```
|
||||
|
||||
## 🎬 Feature Demo
|
||||
|
||||
### Main Feature Showcase
|
||||
|
||||
1. **Video Download and Processing**
|
||||
- Support for YouTube, Bilibili video link parsing
|
||||
- Automatic video and subtitle file download
|
||||
- Support for local file upload
|
||||
|
||||
2. **AI Intelligent Analysis**
|
||||
- Automatic video outline extraction
|
||||
- Intelligent topic timeline identification
|
||||
- Exciting clip scoring
|
||||
|
||||
3. **Video Clipping and Collections**
|
||||
- Automatic exciting clip generation
|
||||
- Smart collection recommendations
|
||||
- Support for manual editing and sorting
|
||||
|
||||
4. **Real-time Progress Monitoring**
|
||||
- WebSocket real-time progress push
|
||||
- Detailed task status display
|
||||
- Error handling and retry mechanisms
|
||||
|
||||
5. **Bilibili Upload Feature** **[In Development]**
|
||||
- Automatic upload of clipped videos to Bilibili
|
||||
- Support for multiple account management
|
||||
- Batch upload and queue management
|
||||
|
||||
6. **Subtitle Editing Feature** **[In Development]**
|
||||
- Visual subtitle editor
|
||||
- Subtitle synchronization and adjustment
|
||||
- Multi-language subtitle support
|
||||
|
||||
## 📖 User Guide
|
||||
|
||||
### 1. Video Download
|
||||
|
||||
#### YouTube Videos
|
||||
1. Click "New Project" on the homepage
|
||||
2. Select "YouTube Link"
|
||||
3. Paste the video URL
|
||||
4. Choose browser cookies (optional)
|
||||
5. Click "Start Download"
|
||||
|
||||
#### Bilibili Videos
|
||||
1. Click "New Project" on the homepage
|
||||
2. Select "Bilibili Link"
|
||||
3. Paste the video URL
|
||||
4. Choose login account
|
||||
5. Click "Start Download"
|
||||
|
||||
#### Local Files
|
||||
1. Click "New Project" on the homepage
|
||||
2. Select "File Upload"
|
||||
3. Drag and drop or select video files
|
||||
4. Upload subtitle files (optional)
|
||||
5. Click "Start Processing"
|
||||
|
||||
### 2. Intelligent Processing
|
||||
|
||||
The system will automatically execute the following steps:
|
||||
|
||||
1. **Material Preparation**: Download video and subtitle files
|
||||
2. **Content Analysis**: AI extracts video outline and key information
|
||||
3. **Timeline Extraction**: Identify topic time intervals
|
||||
4. **Exciting Scoring**: AI scoring for each clip
|
||||
5. **Title Generation**: Generate attractive titles for exciting clips
|
||||
6. **Collection Recommendation**: AI-recommended video collections
|
||||
7. **Video Generation**: Generate clipped videos and collection videos
|
||||
|
||||
### 3. Result Management
|
||||
|
||||
- **View Clips**: View all generated video clips on the project detail page
|
||||
- **Edit Information**: Modify clip titles, descriptions, etc.
|
||||
- **Create Collections**: Manually create or use AI-recommended collections
|
||||
- **Download Export**: Download individual clips or complete collections
|
||||
- **Bilibili Upload** **[In Development]**: One-click upload of clipped videos to Bilibili
|
||||
- **Subtitle Editing** **[In Development]**: Visual editing and synchronization of subtitle files
|
||||
|
||||
## 🔧 Configuration
|
||||
|
||||
### Environment Variable Configuration
|
||||
|
||||
Create `.env` file:
|
||||
|
||||
```bash
|
||||
# Database configuration
|
||||
DATABASE_URL=sqlite:///./data/autoclip.db
|
||||
|
||||
# Redis configuration
|
||||
REDIS_URL=redis://localhost:6379/0
|
||||
|
||||
# AI API configuration
|
||||
API_DASHSCOPE_API_KEY=your_dashscope_api_key
|
||||
API_MODEL_NAME=qwen-plus
|
||||
|
||||
# Logging configuration
|
||||
LOG_LEVEL=INFO
|
||||
ENVIRONMENT=development
|
||||
DEBUG=true
|
||||
|
||||
# File storage
|
||||
UPLOAD_DIR=./data/uploads
|
||||
PROJECT_DIR=./data/projects
|
||||
```
|
||||
|
||||
### Bilibili Account Configuration **[In Development]**
|
||||
|
||||
1. Click "Bilibili Account Management" on the settings page
|
||||
2. Choose login method:
|
||||
- **Cookie Import** (recommended): Export cookies from browser
|
||||
- **Account Password**: Directly input account and password
|
||||
- **QR Code Login**: Scan QR code to login
|
||||
3. After successful addition, the system will automatically manage account health status
|
||||
|
||||
## 📁 Project Structure
|
||||
|
||||
```
|
||||
autoclip/
|
||||
├── backend/ # Backend code
|
||||
│ ├── api/ # API routes
|
||||
│ │ ├── v1/ # API v1 version
|
||||
│ │ │ ├── youtube.py # YouTube download API
|
||||
│ │ │ ├── bilibili.py # Bilibili download API
|
||||
│ │ │ ├── projects.py # Project management API
|
||||
│ │ │ ├── clips.py # Video clip API
|
||||
│ │ │ ├── collections.py # Collection management API
|
||||
│ │ │ └── settings.py # System settings API
|
||||
│ │ └── upload_queue.py # Upload queue management
|
||||
│ ├── core/ # Core configuration
|
||||
│ │ ├── database.py # Database configuration
|
||||
│ │ ├── celery_app.py # Celery configuration
|
||||
│ │ ├── config.py # System configuration
|
||||
│ │ └── llm_manager.py # AI model management
|
||||
│ ├── models/ # Data models
|
||||
│ │ ├── project.py # Project model
|
||||
│ │ ├── clip.py # Clip model
|
||||
│ │ ├── collection.py # Collection model
|
||||
│ │ └── bilibili.py # Bilibili account model
|
||||
│ ├── services/ # Business logic
|
||||
│ │ ├── video_service.py # Video processing service
|
||||
│ │ ├── ai_service.py # AI analysis service
|
||||
│ │ └── upload_service.py # Upload service
|
||||
│ ├── tasks/ # Celery tasks
|
||||
│ │ ├── processing.py # Processing tasks
|
||||
│ │ ├── upload.py # Upload tasks
|
||||
│ │ └── maintenance.py # Maintenance tasks
|
||||
│ ├── pipeline/ # Processing pipeline
|
||||
│ │ ├── step1_outline.py # Outline extraction
|
||||
│ │ ├── step2_timeline.py # Timeline analysis
|
||||
│ │ ├── step3_scoring.py # Exciting scoring
|
||||
│ │ └── step6_video.py # Video generation
|
||||
│ └── utils/ # Utility functions
|
||||
├── frontend/ # Frontend code
|
||||
│ ├── src/
|
||||
│ │ ├── components/ # React components
|
||||
│ │ │ ├── UploadModal.tsx # Upload modal
|
||||
│ │ │ ├── ClipCard.tsx # Clip card
|
||||
│ │ │ ├── CollectionCard.tsx # Collection card
|
||||
│ │ │ └── BilibiliManager.tsx # Bilibili management
|
||||
│ │ ├── pages/ # Page components
|
||||
│ │ │ ├── HomePage.tsx # Home page
|
||||
│ │ │ ├── ProjectDetailPage.tsx # Project detail
|
||||
│ │ │ └── SettingsPage.tsx # Settings page
|
||||
│ │ ├── services/ # API services
|
||||
│ │ │ └── api.ts # API client
|
||||
│ │ └── stores/ # State management
|
||||
│ └── package.json
|
||||
├── data/ # Data storage
|
||||
│ ├── projects/ # Project data
|
||||
│ ├── uploads/ # Upload files
|
||||
│ ├── temp/ # Temporary files
|
||||
│ ├── output/ # Output files
|
||||
│ └── autoclip.db # Database file
|
||||
├── scripts/ # Utility scripts
|
||||
│ ├── start_autoclip.sh # Startup script
|
||||
│ ├── stop_autoclip.sh # Stop script
|
||||
│ └── status_autoclip.sh # Status check
|
||||
├── docs/ # Documentation
|
||||
├── logs/ # Log files
|
||||
├── Dockerfile # Docker image build file
|
||||
├── Dockerfile.dev # Development environment Docker file
|
||||
├── docker-compose.yml # Production environment Docker orchestration
|
||||
├── docker-compose.dev.yml # Development environment Docker orchestration
|
||||
├── docker-start.sh # Docker startup script
|
||||
├── docker-stop.sh # Docker stop script
|
||||
├── docker-status.sh # Docker status check script
|
||||
├── .dockerignore # Docker ignore file
|
||||
├── DOCKER.md # Docker deployment documentation
|
||||
└── *.sh # Startup scripts
|
||||
```
|
||||
|
||||
## 🌐 API Documentation
|
||||
|
||||
After starting the system, visit the following addresses to view API documentation:
|
||||
|
||||
- **Swagger UI**: http://localhost:8000/docs
|
||||
- **ReDoc**: http://localhost:8000/redoc
|
||||
|
||||
### Main API Endpoints
|
||||
|
||||
| Endpoint | Method | Description |
|
||||
|----------|--------|-------------|
|
||||
| `/api/v1/projects` | GET | Get project list |
|
||||
| `/api/v1/projects` | POST | Create new project |
|
||||
| `/api/v1/projects/{id}` | GET | Get project details |
|
||||
| `/api/v1/youtube/parse` | POST | Parse YouTube video information |
|
||||
| `/api/v1/youtube/download` | POST | Download YouTube video |
|
||||
| `/api/v1/bilibili/download` | POST | Download Bilibili video |
|
||||
| `/api/v1/projects/{id}/process` | POST | Start project processing |
|
||||
| `/api/v1/projects/{id}/status` | GET | Get processing status |
|
||||
|
||||
## 🔍 Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
#### 1. Port Occupied
|
||||
```bash
|
||||
# Check port usage
|
||||
lsof -i :8000 # Backend port
|
||||
lsof -i :3000 # Frontend port
|
||||
|
||||
# Stop occupying processes
|
||||
kill -9 <PID>
|
||||
```
|
||||
|
||||
#### 2. Redis Connection Failed
|
||||
```bash
|
||||
# Check Redis status
|
||||
redis-cli ping
|
||||
|
||||
# Start Redis service
|
||||
brew services start redis # macOS
|
||||
systemctl start redis-server # Linux
|
||||
```
|
||||
|
||||
#### 3. YouTube Download Failed
|
||||
- Check network connection
|
||||
- Update yt-dlp: `pip install --upgrade yt-dlp`
|
||||
- Try using browser cookies
|
||||
- Check if video is available
|
||||
|
||||
#### 4. Bilibili Download Failed
|
||||
- Check account login status
|
||||
- Update account cookies
|
||||
- Check video permission settings
|
||||
|
||||
### Log Viewing
|
||||
|
||||
```bash
|
||||
# View all logs
|
||||
tail -f logs/*.log
|
||||
|
||||
# View specific service logs
|
||||
tail -f logs/backend.log # Backend logs
|
||||
tail -f logs/frontend.log # Frontend logs
|
||||
tail -f logs/celery.log # Task queue logs
|
||||
```
|
||||
|
||||
### System Status Check
|
||||
|
||||
```bash
|
||||
# Detailed status check
|
||||
./status_autoclip.sh
|
||||
|
||||
# Manual service check
|
||||
curl http://localhost:8000/api/v1/health/ # Backend health check
|
||||
curl http://localhost:3000/ # Frontend access test
|
||||
redis-cli ping # Redis connection test
|
||||
```
|
||||
|
||||
## 🛠️ Development Guide
|
||||
|
||||
### Backend Development
|
||||
|
||||
```bash
|
||||
# Activate virtual environment
|
||||
source venv/bin/activate
|
||||
|
||||
# Set Python path
|
||||
export PYTHONPATH="${PWD}:${PYTHONPATH}"
|
||||
|
||||
# Start backend development server
|
||||
python -m uvicorn backend.main:app --reload --port 8000
|
||||
```
|
||||
|
||||
### Frontend Development
|
||||
|
||||
```bash
|
||||
# Enter frontend directory
|
||||
cd frontend
|
||||
|
||||
# Start development server
|
||||
npm run dev
|
||||
```
|
||||
|
||||
### Celery Worker
|
||||
|
||||
```bash
|
||||
# Start Worker
|
||||
celery -A backend.core.celery_app worker --loglevel=info
|
||||
|
||||
# Start Beat scheduler
|
||||
celery -A backend.core.celery_app beat --loglevel=info
|
||||
|
||||
# Start Flower monitoring
|
||||
celery -A backend.core.celery_app flower --port=5555
|
||||
```
|
||||
|
||||
## 📊 Performance Optimization
|
||||
|
||||
### Production Environment Configuration
|
||||
|
||||
1. **Database Optimization**
|
||||
- Use PostgreSQL instead of SQLite
|
||||
- Configure connection pooling
|
||||
- Enable query caching
|
||||
|
||||
2. **Redis Optimization**
|
||||
- Configure memory limits
|
||||
- Enable persistence
|
||||
- Set expiration policies
|
||||
|
||||
3. **Celery Optimization**
|
||||
- Adjust concurrency
|
||||
- Configure task routing
|
||||
- Enable result backend
|
||||
|
||||
## 🔒 Security Configuration
|
||||
|
||||
### Production Environment Security
|
||||
|
||||
1. **Environment Variables**
|
||||
- Use strong passwords
|
||||
- Regularly rotate keys
|
||||
- Limit API access
|
||||
|
||||
2. **Network Security**
|
||||
- Configure firewall
|
||||
- Use HTTPS
|
||||
- Limit CORS
|
||||
|
||||
3. **Data Security**
|
||||
- Regular backups
|
||||
- Encrypt sensitive data
|
||||
- Access control
|
||||
|
||||
## 🚀 Deployment Guide
|
||||
|
||||
### Docker Deployment
|
||||
|
||||
#### Quick Start
|
||||
|
||||
```bash
|
||||
# Clone the project
|
||||
git clone https://github.com/your-username/autoclip.git
|
||||
cd autoclip
|
||||
|
||||
# Configure environment variables
|
||||
cp env.example .env
|
||||
# Edit .env file and fill in necessary configurations
|
||||
|
||||
# Start all services
|
||||
docker-compose up -d
|
||||
|
||||
# Check service status
|
||||
docker-compose ps
|
||||
```
|
||||
|
||||
#### Access Services
|
||||
|
||||
- **Frontend Interface**: http://localhost:3000
|
||||
- **Backend API**: http://localhost:8000
|
||||
- **API Documentation**: http://localhost:8000/docs
|
||||
- **Flower Monitoring**: http://localhost:5555
|
||||
|
||||
#### Development Environment
|
||||
|
||||
```bash
|
||||
# Use development environment configuration
|
||||
docker-compose -f docker-compose.dev.yml up -d
|
||||
|
||||
# View logs in real-time
|
||||
docker-compose -f docker-compose.dev.yml logs -f
|
||||
```
|
||||
|
||||
#### Detailed Instructions
|
||||
|
||||
Complete Docker deployment guide please refer to [DOCKER.md](DOCKER.md) documentation.
|
||||
|
||||
### System Service
|
||||
|
||||
```bash
|
||||
# Create systemd service file
|
||||
sudo nano /etc/systemd/system/autoclip.service
|
||||
|
||||
[Unit]
|
||||
Description=AutoClip Video Processing System
|
||||
After=network.target redis.service
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
User=autoclip
|
||||
WorkingDirectory=/opt/autoclip
|
||||
ExecStart=/opt/autoclip/start_autoclip.sh
|
||||
ExecStop=/opt/autoclip/stop_autoclip.sh
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
## 📈 Roadmap
|
||||
|
||||
### Coming Soon
|
||||
|
||||
- [ ] **Bilibili Upload Feature**: Automatic upload of clipped videos to Bilibili with multi-account management
|
||||
- [ ] **Subtitle Editing Feature**: Visual subtitle editor and synchronization functionality
|
||||
- [ ] **Multi-language Support**: Support for more language video processing
|
||||
- [ ] **Cloud Storage**: Integrate cloud storage services
|
||||
- [ ] **Batch Processing**: Support for batch video processing
|
||||
- [ ] **API Open**: Provide public API interface
|
||||
- [ ] **Mobile App**: Develop mobile application
|
||||
|
||||
### Long-term Planning
|
||||
|
||||
- [ ] **AI Model Optimization**: Integrate more AI models
|
||||
- [ ] **Real-time Collaboration**: Support multi-user collaboration
|
||||
- [ ] **Plugin System**: Support third-party plugins
|
||||
- [ ] **Enterprise Edition**: Enterprise-level features and services
|
||||
|
||||
## 🤝 Contributing
|
||||
|
||||
We welcome all forms of contributions! Whether it's code contributions, documentation improvements, issue reports, or feature suggestions.
|
||||
|
||||
### How to Contribute
|
||||
|
||||
1. **Fork** the project to your GitHub account
|
||||
2. Clone your Fork to local:
|
||||
```bash
|
||||
git clone https://github.com/your-username/autoclip.git
|
||||
cd autoclip
|
||||
```
|
||||
3. Create feature branch:
|
||||
```bash
|
||||
git checkout -b feature/amazing-feature
|
||||
```
|
||||
4. Develop and test
|
||||
5. Commit changes:
|
||||
```bash
|
||||
git add .
|
||||
git commit -m 'feat: add amazing feature'
|
||||
```
|
||||
6. Push branch:
|
||||
```bash
|
||||
git push origin feature/amazing-feature
|
||||
```
|
||||
7. Create **Pull Request** on GitHub
|
||||
|
||||
### Development Standards
|
||||
|
||||
**Code Standards**
|
||||
- Backend: Follow PEP 8 Python code standards
|
||||
- Frontend: Use TypeScript, follow ESLint rules
|
||||
- Commit messages: Use conventional commit format (feat, fix, docs, style, refactor, test, chore)
|
||||
|
||||
**Development Process**
|
||||
1. Ensure all tests pass
|
||||
2. Add necessary test cases
|
||||
3. Update related documentation
|
||||
4. Ensure code quality checks pass
|
||||
|
||||
**Commit Message Format**
|
||||
```
|
||||
<type>(<scope>): <description>
|
||||
|
||||
[optional body]
|
||||
|
||||
[optional footer(s)]
|
||||
```
|
||||
|
||||
Examples:
|
||||
- `feat(api): add video download endpoint`
|
||||
- `fix(ui): resolve upload modal display issue`
|
||||
- `docs(readme): update installation instructions`
|
||||
|
||||
## ❓ FAQ
|
||||
|
||||
### Installation and Startup Issues
|
||||
|
||||
**Q: What to do when ports are occupied during startup?**
|
||||
A: Use the following commands to check and stop processes occupying ports:
|
||||
```bash
|
||||
# Check port usage
|
||||
lsof -i :8000 # Backend port
|
||||
lsof -i :3000 # Frontend port
|
||||
|
||||
# Stop processes
|
||||
kill -9 <PID>
|
||||
```
|
||||
|
||||
**Q: What to do when Redis connection fails?**
|
||||
A: Ensure Redis service is running:
|
||||
```bash
|
||||
# Check Redis status
|
||||
redis-cli ping
|
||||
|
||||
# Start Redis service
|
||||
brew services start redis # macOS
|
||||
sudo systemctl start redis-server # Linux
|
||||
```
|
||||
|
||||
**Q: What to do when frontend dependency installation fails?**
|
||||
A: Try clearing cache and reinstalling:
|
||||
```bash
|
||||
cd frontend
|
||||
rm -rf node_modules package-lock.json
|
||||
npm cache clean --force
|
||||
npm install
|
||||
```
|
||||
|
||||
### Feature Usage Issues
|
||||
|
||||
**Q: What to do when YouTube video download fails?**
|
||||
A:
|
||||
1. Check network connection
|
||||
2. Update yt-dlp: `pip install --upgrade yt-dlp`
|
||||
3. Try using browser cookies
|
||||
4. Check if video is available or requires login
|
||||
|
||||
**Q: What to do when Bilibili video download fails?**
|
||||
A:
|
||||
1. Check account login status
|
||||
2. Update account cookies
|
||||
3. Check video permission settings
|
||||
4. Try using other accounts
|
||||
|
||||
**Q: What to do when AI processing is slow?**
|
||||
A:
|
||||
1. Check API key configuration
|
||||
2. Adjust processing parameters (reduce chunk_size)
|
||||
3. Check network connection
|
||||
4. Consider using faster AI models
|
||||
|
||||
**Q: When will Bilibili upload feature be available?**
|
||||
A: Bilibili upload feature is currently in development and is expected to be released in the next version. This feature will support:
|
||||
- Automatic upload of clipped videos to Bilibili
|
||||
- Multi-account management and switching
|
||||
- Batch upload and queue management
|
||||
- Upload progress monitoring
|
||||
|
||||
**Q: When will subtitle editing feature be available?**
|
||||
A: Subtitle editing feature is currently in development and is expected to be released in the next version. This feature will support:
|
||||
- Visual subtitle editor
|
||||
- Subtitle timeline synchronization
|
||||
- Multi-language subtitle support
|
||||
- Subtitle format conversion
|
||||
|
||||
### Performance Optimization
|
||||
|
||||
**Q: How to improve processing speed?**
|
||||
A:
|
||||
1. Increase Celery Worker concurrency
|
||||
2. Use SSD storage
|
||||
3. Increase system memory
|
||||
4. Optimize video quality settings
|
||||
|
||||
**Q: How to reduce storage space usage?**
|
||||
A:
|
||||
1. Regularly clean temporary files
|
||||
2. Compress output videos
|
||||
3. Delete unnecessary projects
|
||||
4. Use external storage
|
||||
|
||||
## 📞 Support & Feedback
|
||||
|
||||
### Get Help
|
||||
|
||||
- **Issue Reports**: [GitHub Issues](https://github.com/your-username/autoclip/issues)
|
||||
- **Feature Suggestions**: [GitHub Discussions](https://github.com/your-username/autoclip/discussions)
|
||||
- **Bug Reports**: Please use GitHub Issues template
|
||||
- **Documentation**: [Project Documentation](docs/)
|
||||
|
||||
### Contact
|
||||
|
||||
- **Personal WeChat**: your_wechat_id
|
||||
- **Feishu**: your_feishu_id
|
||||
|
||||
## 📄 License
|
||||
|
||||
This project is licensed under the [MIT License](LICENSE).
|
||||
|
||||
## 🙏 Acknowledgments
|
||||
|
||||
Thanks to the following open source projects and services:
|
||||
|
||||
### Core Technology Stack
|
||||
- [FastAPI](https://fastapi.tiangolo.com/) - Modern Python web framework
|
||||
- [React](https://reactjs.org/) - User interface library
|
||||
- [Ant Design](https://ant.design/) - Enterprise-grade UI design language
|
||||
- [TypeScript](https://typescriptlang.org/) - JavaScript superset
|
||||
- [Celery](https://docs.celeryproject.org/) - Distributed task queue
|
||||
- [Redis](https://redis.io/) - In-memory data structure store
|
||||
|
||||
### Video Processing
|
||||
- [yt-dlp](https://github.com/yt-dlp/yt-dlp) - YouTube video download tool
|
||||
- [FFmpeg](https://ffmpeg.org/) - Audio and video processing framework
|
||||
- [bcut-asr](https://github.com/liou666/bcut-asr) - Speech recognition service
|
||||
|
||||
### AI Services
|
||||
- [Qwen](https://tongyi.aliyun.com/) - Alibaba Cloud large language model service
|
||||
- [DashScope](https://dashscope.aliyun.com/) - Alibaba Cloud AI service platform
|
||||
|
||||
### Development Tools
|
||||
- [Vite](https://vitejs.dev/) - Frontend build tool
|
||||
- [Zustand](https://github.com/pmndrs/zustand) - State management library
|
||||
- [Pydantic](https://pydantic-docs.helpmanual.io/) - Data validation library
|
||||
|
||||
### Special Thanks
|
||||
- All developers contributing to the open source community
|
||||
- Users providing feedback and suggestions
|
||||
- Community members participating in testing and code contributions
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
|
||||
**If this project helps you, please give us a ⭐ Star!**
|
||||
|
||||
[](https://star-history.com/#your-username/autoclip&Date)
|
||||
|
||||
Made with ❤️ by AutoClip Team
|
||||
|
||||
**⭐ If you find it useful, please give us a Star!**
|
||||
|
||||
</div>
|
||||
464
README.md
464
README.md
@@ -9,8 +9,16 @@
|
||||
[](https://python.org)
|
||||
[](https://reactjs.org)
|
||||
[](https://fastapi.tiangolo.com)
|
||||
[](https://typescriptlang.org)
|
||||
[](https://celeryproject.org)
|
||||
[](LICENSE)
|
||||
|
||||
[](https://github.com/your-username/autoclip)
|
||||
[](https://github.com/your-username/autoclip)
|
||||
[](https://github.com/your-username/autoclip/issues)
|
||||
|
||||
**语言**: [English](README-EN.md) | [中文](README.md)
|
||||
|
||||
</div>
|
||||
|
||||
## 🎯 项目简介
|
||||
@@ -19,13 +27,18 @@ AutoClip是一个基于AI的智能视频切片处理系统,能够自动从YouT
|
||||
|
||||
### ✨ 核心特性
|
||||
|
||||
- 🎬 **多平台支持**: YouTube、B站视频一键下载
|
||||
- 🤖 **AI智能分析**: 基于大语言模型的视频内容理解
|
||||
- ✂️ **自动切片**: 智能识别精彩片段并自动切割
|
||||
- 📚 **智能合集**: AI推荐和手动创建视频合集
|
||||
- 🚀 **实时处理**: 异步任务队列,实时进度反馈
|
||||
- 🎨 **现代界面**: React + TypeScript + Ant Design
|
||||
- 📱 **响应式设计**: 支持桌面和移动端
|
||||
- 🎬 **多平台支持**: YouTube、B站视频一键下载,支持本地文件上传
|
||||
- 🤖 **AI智能分析**: 基于通义千问大语言模型的视频内容理解
|
||||
- ✂️ **自动切片**: 智能识别精彩片段并自动切割,支持多种视频分类
|
||||
- 📚 **智能合集**: AI推荐和手动创建视频合集,支持拖拽排序
|
||||
- 🚀 **实时处理**: 异步任务队列,实时进度反馈,WebSocket通信
|
||||
- 🎨 **现代界面**: React + TypeScript + Ant Design,响应式设计
|
||||
- 📱 **移动端支持**: 完美适配桌面和移动端设备
|
||||
- 🔐 **账号管理**: 支持B站多账号管理,自动健康检查
|
||||
- 📊 **数据统计**: 完整的项目管理和数据统计功能
|
||||
- 🛠️ **易于部署**: 一键启动脚本,Docker支持,详细文档
|
||||
- 📤 **B站上传**【开发中】: 自动上传切片视频到B站
|
||||
- ✏️ **字幕编辑**【开发中】: 可视化字幕编辑和同步功能
|
||||
|
||||
## 🏗️ 系统架构
|
||||
|
||||
@@ -47,41 +60,84 @@ graph TB
|
||||
### 技术栈
|
||||
|
||||
**后端技术**
|
||||
- **FastAPI**: 现代化Python Web框架
|
||||
- **Celery**: 分布式任务队列
|
||||
- **Redis**: 消息代理和缓存
|
||||
- **SQLite**: 轻量级数据库
|
||||
- **yt-dlp**: YouTube视频下载
|
||||
- **通义千问**: AI内容分析
|
||||
- **FastAPI**: 现代化Python Web框架,自动API文档生成
|
||||
- **Celery**: 分布式任务队列,支持异步处理
|
||||
- **Redis**: 消息代理和缓存,任务状态管理
|
||||
- **SQLite**: 轻量级数据库,支持升级到PostgreSQL
|
||||
- **yt-dlp**: YouTube视频下载,支持多种格式
|
||||
- **通义千问**: AI内容分析,支持多种模型
|
||||
- **WebSocket**: 实时通信,进度推送
|
||||
- **Pydantic**: 数据验证和序列化
|
||||
|
||||
**前端技术**
|
||||
- **React 18**: 用户界面框架
|
||||
- **TypeScript**: 类型安全
|
||||
- **Ant Design**: UI组件库
|
||||
- **Vite**: 构建工具
|
||||
- **Zustand**: 状态管理
|
||||
- **React 18**: 用户界面框架,Hooks和函数组件
|
||||
- **TypeScript**: 类型安全,更好的开发体验
|
||||
- **Ant Design**: 企业级UI组件库
|
||||
- **Vite**: 快速构建工具,热重载
|
||||
- **Zustand**: 轻量级状态管理
|
||||
- **React Router**: 路由管理
|
||||
- **Axios**: HTTP客户端
|
||||
- **React Player**: 视频播放器
|
||||
|
||||
## 🚀 快速开始
|
||||
|
||||
### 环境要求
|
||||
|
||||
- **操作系统**: macOS / Linux
|
||||
- **Python**: 3.8+
|
||||
- **Node.js**: 16+
|
||||
- **Redis**: 6.0+
|
||||
#### Docker部署(推荐)
|
||||
- **Docker**: 20.10+
|
||||
- **Docker Compose**: 2.0+
|
||||
- **内存**: 最少 4GB,推荐 8GB+
|
||||
- **存储**: 最少 10GB 可用空间
|
||||
|
||||
#### 本地部署
|
||||
- **操作系统**: macOS / Linux / Windows (WSL)
|
||||
- **Python**: 3.8+ (推荐 3.9+)
|
||||
- **Node.js**: 16+ (推荐 18+)
|
||||
- **Redis**: 6.0+ (推荐 7.0+)
|
||||
- **FFmpeg**: 视频处理依赖
|
||||
- **内存**: 最少 4GB,推荐 8GB+
|
||||
- **存储**: 最少 10GB 可用空间
|
||||
|
||||
### 一键启动
|
||||
|
||||
#### 方式一:Docker部署(推荐)
|
||||
|
||||
```bash
|
||||
# 克隆项目
|
||||
git clone <repository-url>
|
||||
git clone https://github.com/your-username/autoclip.git
|
||||
cd autoclip
|
||||
|
||||
# 一键启动(推荐)
|
||||
# Docker一键启动
|
||||
./docker-start.sh
|
||||
|
||||
# 开发环境启动
|
||||
./docker-start.sh dev
|
||||
|
||||
# 停止服务
|
||||
./docker-stop.sh
|
||||
|
||||
# 检查服务状态
|
||||
./docker-status.sh
|
||||
```
|
||||
|
||||
#### 方式二:本地部署
|
||||
|
||||
```bash
|
||||
# 克隆项目
|
||||
git clone https://github.com/your-username/autoclip.git
|
||||
cd autoclip
|
||||
|
||||
# 一键启动(推荐,包含完整检查和监控)
|
||||
./start_autoclip.sh
|
||||
|
||||
# 快速启动(开发环境)
|
||||
# 快速启动(开发环境,跳过详细检查)
|
||||
./quick_start.sh
|
||||
|
||||
# 检查系统状态
|
||||
./status_autoclip.sh
|
||||
|
||||
# 停止系统
|
||||
./stop_autoclip.sh
|
||||
```
|
||||
|
||||
### 手动安装
|
||||
@@ -89,7 +145,8 @@ cd autoclip
|
||||
```bash
|
||||
# 1. 创建虚拟环境
|
||||
python3 -m venv venv
|
||||
source venv/bin/activate
|
||||
source venv/bin/activate # Linux/macOS
|
||||
# 或 venv\Scripts\activate # Windows
|
||||
|
||||
# 2. 安装Python依赖
|
||||
pip install -r requirements.txt
|
||||
@@ -98,14 +155,68 @@ pip install -r requirements.txt
|
||||
cd frontend && npm install && cd ..
|
||||
|
||||
# 4. 安装Redis
|
||||
brew install redis # macOS
|
||||
# macOS
|
||||
brew install redis
|
||||
brew services start redis
|
||||
|
||||
# 5. 配置环境变量
|
||||
# Ubuntu/Debian
|
||||
sudo apt update
|
||||
sudo apt install redis-server
|
||||
sudo systemctl start redis-server
|
||||
|
||||
# CentOS/RHEL
|
||||
sudo yum install redis
|
||||
sudo systemctl start redis
|
||||
|
||||
# 5. 安装FFmpeg
|
||||
# macOS
|
||||
brew install ffmpeg
|
||||
|
||||
# Ubuntu/Debian
|
||||
sudo apt install ffmpeg
|
||||
|
||||
# CentOS/RHEL
|
||||
sudo yum install ffmpeg
|
||||
|
||||
# 6. 配置环境变量
|
||||
cp env.example .env
|
||||
# 编辑 .env 文件,填入API密钥等配置
|
||||
```
|
||||
|
||||
## 🎬 功能演示
|
||||
|
||||
### 主要功能展示
|
||||
|
||||
1. **视频下载与处理**
|
||||
- 支持YouTube、B站视频链接解析
|
||||
- 自动下载视频和字幕文件
|
||||
- 支持本地文件上传
|
||||
|
||||
2. **AI智能分析**
|
||||
- 自动提取视频大纲
|
||||
- 智能识别话题时间点
|
||||
- 对片段进行精彩度评分
|
||||
|
||||
3. **视频切片与合集**
|
||||
- 自动生成精彩片段
|
||||
- 智能推荐合集组合
|
||||
- 支持手动编辑和排序
|
||||
|
||||
4. **实时进度监控**
|
||||
- WebSocket实时进度推送
|
||||
- 详细的任务状态显示
|
||||
- 错误处理和重试机制
|
||||
|
||||
5. **B站上传功能**【开发中】
|
||||
- 自动上传切片视频到B站
|
||||
- 支持多账号管理
|
||||
- 批量上传和队列管理
|
||||
|
||||
6. **字幕编辑功能**【开发中】
|
||||
- 可视化字幕编辑器
|
||||
- 字幕同步和调整
|
||||
- 多语言字幕支持
|
||||
|
||||
## 📖 使用指南
|
||||
|
||||
### 1. 视频下载
|
||||
@@ -149,6 +260,8 @@ cp env.example .env
|
||||
- **编辑信息**: 修改片段标题、描述等信息
|
||||
- **创建合集**: 手动创建或使用AI推荐的合集
|
||||
- **下载导出**: 下载单个片段或完整合集
|
||||
- **B站上传**【开发中】: 一键上传切片视频到B站
|
||||
- **字幕编辑**【开发中】: 可视化编辑和同步字幕文件
|
||||
|
||||
## 🔧 配置说明
|
||||
|
||||
@@ -177,7 +290,7 @@ UPLOAD_DIR=./data/uploads
|
||||
PROJECT_DIR=./data/projects
|
||||
```
|
||||
|
||||
### B站账号配置
|
||||
### B站账号配置【开发中】
|
||||
|
||||
1. 在设置页面点击"B站账号管理"
|
||||
2. 选择登录方式:
|
||||
@@ -195,29 +308,74 @@ autoclip/
|
||||
│ │ ├── v1/ # API v1版本
|
||||
│ │ │ ├── youtube.py # YouTube下载API
|
||||
│ │ │ ├── bilibili.py # B站下载API
|
||||
│ │ │ └── projects.py # 项目管理API
|
||||
│ │ │ ├── projects.py # 项目管理API
|
||||
│ │ │ ├── clips.py # 视频片段API
|
||||
│ │ │ ├── collections.py # 合集管理API
|
||||
│ │ │ └── settings.py # 系统设置API
|
||||
│ │ └── upload_queue.py # 上传队列管理
|
||||
│ ├── core/ # 核心配置
|
||||
│ │ ├── database.py # 数据库配置
|
||||
│ │ ├── celery_app.py # Celery配置
|
||||
│ │ └── config.py # 系统配置
|
||||
│ │ ├── config.py # 系统配置
|
||||
│ │ └── llm_manager.py # AI模型管理
|
||||
│ ├── models/ # 数据模型
|
||||
│ │ ├── project.py # 项目模型
|
||||
│ │ ├── clip.py # 片段模型
|
||||
│ │ ├── collection.py # 合集模型
|
||||
│ │ └── bilibili.py # B站账号模型
|
||||
│ ├── services/ # 业务逻辑
|
||||
│ │ ├── video_service.py # 视频处理服务
|
||||
│ │ ├── ai_service.py # AI分析服务
|
||||
│ │ └── upload_service.py # 上传服务
|
||||
│ ├── tasks/ # Celery任务
|
||||
│ └── pipeline/ # 处理流水线
|
||||
│ │ ├── processing.py # 处理任务
|
||||
│ │ ├── upload.py # 上传任务
|
||||
│ │ └── maintenance.py # 维护任务
|
||||
│ ├── pipeline/ # 处理流水线
|
||||
│ │ ├── step1_outline.py # 大纲提取
|
||||
│ │ ├── step2_timeline.py # 时间线分析
|
||||
│ │ ├── step3_scoring.py # 精彩度评分
|
||||
│ │ └── step6_video.py # 视频生成
|
||||
│ └── utils/ # 工具函数
|
||||
├── frontend/ # 前端代码
|
||||
│ ├── src/
|
||||
│ │ ├── components/ # React组件
|
||||
│ │ │ ├── UploadModal.tsx # 上传模态框
|
||||
│ │ │ ├── ClipCard.tsx # 片段卡片
|
||||
│ │ │ ├── CollectionCard.tsx # 合集卡片
|
||||
│ │ │ └── BilibiliManager.tsx # B站管理
|
||||
│ │ ├── pages/ # 页面组件
|
||||
│ │ │ ├── HomePage.tsx # 首页
|
||||
│ │ │ ├── ProjectDetailPage.tsx # 项目详情
|
||||
│ │ │ └── SettingsPage.tsx # 设置页面
|
||||
│ │ ├── services/ # API服务
|
||||
│ │ └── store/ # 状态管理
|
||||
│ │ │ └── api.ts # API客户端
|
||||
│ │ └── stores/ # 状态管理
|
||||
│ └── package.json
|
||||
├── data/ # 数据存储
|
||||
│ ├── projects/ # 项目数据
|
||||
│ ├── uploads/ # 上传文件
|
||||
│ ├── temp/ # 临时文件
|
||||
│ ├── output/ # 输出文件
|
||||
│ └── autoclip.db # 数据库文件
|
||||
├── scripts/ # 工具脚本
|
||||
│ ├── start_autoclip.sh # 启动脚本
|
||||
│ ├── stop_autoclip.sh # 停止脚本
|
||||
│ └── status_autoclip.sh # 状态检查
|
||||
├── docs/ # 文档
|
||||
│ ├── README.md # 文档中心
|
||||
│ ├── i18n.md # 国际化配置
|
||||
│ └── *.md # 其他文档
|
||||
├── logs/ # 日志文件
|
||||
├── Dockerfile # Docker镜像构建文件
|
||||
├── Dockerfile.dev # 开发环境Docker文件
|
||||
├── docker-compose.yml # 生产环境Docker编排
|
||||
├── docker-compose.dev.yml # 开发环境Docker编排
|
||||
├── docker-start.sh # Docker启动脚本
|
||||
├── docker-stop.sh # Docker停止脚本
|
||||
├── docker-status.sh # Docker状态检查脚本
|
||||
├── .dockerignore # Docker忽略文件
|
||||
├── DOCKER.md # Docker部署文档
|
||||
└── *.sh # 启动脚本
|
||||
```
|
||||
|
||||
@@ -380,29 +538,45 @@ celery -A backend.core.celery_app flower --port=5555
|
||||
|
||||
### Docker部署
|
||||
|
||||
```dockerfile
|
||||
# Dockerfile示例
|
||||
FROM python:3.9-slim
|
||||
#### 快速启动
|
||||
|
||||
WORKDIR /app
|
||||
```bash
|
||||
# 克隆项目
|
||||
git clone https://github.com/your-username/autoclip.git
|
||||
cd autoclip
|
||||
|
||||
# 安装系统依赖
|
||||
RUN apt-get update && apt-get install -y \
|
||||
ffmpeg \
|
||||
redis-tools \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
# 配置环境变量
|
||||
cp env.example .env
|
||||
# 编辑 .env 文件,填入必要的配置
|
||||
|
||||
# 安装Python依赖
|
||||
COPY requirements.txt .
|
||||
RUN pip install -r requirements.txt
|
||||
# 启动所有服务
|
||||
docker-compose up -d
|
||||
|
||||
# 复制代码
|
||||
COPY . .
|
||||
|
||||
# 启动服务
|
||||
CMD ["./start_autoclip.sh"]
|
||||
# 查看服务状态
|
||||
docker-compose ps
|
||||
```
|
||||
|
||||
#### 访问服务
|
||||
|
||||
- **前端界面**: http://localhost:3000
|
||||
- **后端API**: http://localhost:8000
|
||||
- **API文档**: http://localhost:8000/docs
|
||||
- **Flower监控**: http://localhost:5555
|
||||
|
||||
#### 开发环境
|
||||
|
||||
```bash
|
||||
# 使用开发环境配置
|
||||
docker-compose -f docker-compose.dev.yml up -d
|
||||
|
||||
# 实时查看日志
|
||||
docker-compose -f docker-compose.dev.yml logs -f
|
||||
```
|
||||
|
||||
#### 详细说明
|
||||
|
||||
完整的Docker部署指南请参考 [DOCKER.md](DOCKER.md) 文档。
|
||||
|
||||
### 系统服务
|
||||
|
||||
```bash
|
||||
@@ -429,6 +603,8 @@ WantedBy=multi-user.target
|
||||
|
||||
### 即将推出
|
||||
|
||||
- [ ] **B站上传功能**: 自动上传切片视频到B站,支持多账号管理
|
||||
- [ ] **字幕编辑功能**: 可视化字幕编辑器和同步功能
|
||||
- [ ] **多语言支持**: 支持更多语言的视频处理
|
||||
- [ ] **云端存储**: 集成云存储服务
|
||||
- [ ] **批量处理**: 支持批量视频处理
|
||||
@@ -444,43 +620,197 @@ WantedBy=multi-user.target
|
||||
|
||||
## 🤝 贡献指南
|
||||
|
||||
我们欢迎所有形式的贡献!
|
||||
我们欢迎所有形式的贡献!无论是代码贡献、文档改进、问题报告还是功能建议。
|
||||
|
||||
### 如何贡献
|
||||
|
||||
1. **Fork** 项目
|
||||
2. 创建功能分支:`git checkout -b feature/amazing-feature`
|
||||
3. 提交更改:`git commit -m 'Add amazing feature'`
|
||||
4. 推送分支:`git push origin feature/amazing-feature`
|
||||
5. 创建 **Pull Request**
|
||||
1. **Fork** 项目到您的GitHub账户
|
||||
2. 克隆您的Fork到本地:
|
||||
```bash
|
||||
git clone https://github.com/your-username/autoclip.git
|
||||
cd autoclip
|
||||
```
|
||||
3. 创建功能分支:
|
||||
```bash
|
||||
git checkout -b feature/amazing-feature
|
||||
```
|
||||
4. 进行开发和测试
|
||||
5. 提交更改:
|
||||
```bash
|
||||
git add .
|
||||
git commit -m 'feat: add amazing feature'
|
||||
```
|
||||
6. 推送分支:
|
||||
```bash
|
||||
git push origin feature/amazing-feature
|
||||
```
|
||||
7. 在GitHub上创建 **Pull Request**
|
||||
|
||||
### 开发规范
|
||||
|
||||
- 遵循PEP 8 Python代码规范
|
||||
- 使用TypeScript进行前端开发
|
||||
- 编写清晰的提交信息
|
||||
- 添加必要的测试用例
|
||||
- 更新相关文档
|
||||
**代码规范**
|
||||
- 后端:遵循PEP 8 Python代码规范
|
||||
- 前端:使用TypeScript,遵循ESLint规则
|
||||
- 提交信息:使用约定式提交格式(feat, fix, docs, style, refactor, test, chore)
|
||||
|
||||
**开发流程**
|
||||
1. 确保所有测试通过
|
||||
2. 添加必要的测试用例
|
||||
3. 更新相关文档
|
||||
4. 确保代码质量检查通过
|
||||
|
||||
**提交信息格式**
|
||||
```
|
||||
<type>(<scope>): <description>
|
||||
|
||||
[optional body]
|
||||
|
||||
[optional footer(s)]
|
||||
```
|
||||
|
||||
示例:
|
||||
- `feat(api): add video download endpoint`
|
||||
- `fix(ui): resolve upload modal display issue`
|
||||
- `docs(readme): update installation instructions`
|
||||
|
||||
## 📄 许可证
|
||||
|
||||
本项目采用 [MIT License](LICENSE) 许可证。
|
||||
|
||||
## ❓ 常见问题
|
||||
|
||||
### 安装和启动问题
|
||||
|
||||
**Q: 启动时提示端口被占用怎么办?**
|
||||
A: 使用以下命令检查并停止占用端口的进程:
|
||||
```bash
|
||||
# 检查端口占用
|
||||
lsof -i :8000 # 后端端口
|
||||
lsof -i :3000 # 前端端口
|
||||
|
||||
# 停止进程
|
||||
kill -9 <PID>
|
||||
```
|
||||
|
||||
**Q: Redis连接失败怎么办?**
|
||||
A: 确保Redis服务正在运行:
|
||||
```bash
|
||||
# 检查Redis状态
|
||||
redis-cli ping
|
||||
|
||||
# 启动Redis服务
|
||||
brew services start redis # macOS
|
||||
sudo systemctl start redis-server # Linux
|
||||
```
|
||||
|
||||
**Q: 前端依赖安装失败怎么办?**
|
||||
A: 尝试清理缓存后重新安装:
|
||||
```bash
|
||||
cd frontend
|
||||
rm -rf node_modules package-lock.json
|
||||
npm cache clean --force
|
||||
npm install
|
||||
```
|
||||
|
||||
### 功能使用问题
|
||||
|
||||
**Q: YouTube视频下载失败怎么办?**
|
||||
A:
|
||||
1. 检查网络连接
|
||||
2. 更新yt-dlp:`pip install --upgrade yt-dlp`
|
||||
3. 尝试使用浏览器Cookie
|
||||
4. 检查视频是否可用或需要登录
|
||||
|
||||
**Q: B站视频下载失败怎么办?**
|
||||
A:
|
||||
1. 检查账号登录状态
|
||||
2. 更新账号Cookie
|
||||
3. 检查视频权限设置
|
||||
4. 尝试使用其他账号
|
||||
|
||||
**Q: AI处理速度慢怎么办?**
|
||||
A:
|
||||
1. 检查API密钥配置
|
||||
2. 调整处理参数(减少chunk_size)
|
||||
3. 检查网络连接
|
||||
4. 考虑使用更快的AI模型
|
||||
|
||||
**Q: B站上传功能什么时候可以使用?**
|
||||
A: B站上传功能正在开发中,预计在下一个版本中发布。该功能将支持:
|
||||
- 自动上传切片视频到B站
|
||||
- 多账号管理和切换
|
||||
- 批量上传和队列管理
|
||||
- 上传进度监控
|
||||
|
||||
**Q: 字幕编辑功能什么时候可以使用?**
|
||||
A: 字幕编辑功能正在开发中,预计在下一个版本中发布。该功能将支持:
|
||||
- 可视化字幕编辑器
|
||||
- 字幕时间轴同步
|
||||
- 多语言字幕支持
|
||||
- 字幕格式转换
|
||||
|
||||
### 性能优化
|
||||
|
||||
**Q: 如何提高处理速度?**
|
||||
A:
|
||||
1. 增加Celery Worker并发数
|
||||
2. 使用SSD存储
|
||||
3. 增加系统内存
|
||||
4. 优化视频质量设置
|
||||
|
||||
**Q: 如何减少存储空间占用?**
|
||||
A:
|
||||
1. 定期清理临时文件
|
||||
2. 压缩输出视频
|
||||
3. 删除不需要的项目
|
||||
4. 使用外部存储
|
||||
|
||||
## 📞 支持与反馈
|
||||
|
||||
- **问题反馈**: [GitHub Issues](https://github.com/your-repo/issues)
|
||||
- **功能建议**: [GitHub Discussions](https://github.com/your-repo/discussions)
|
||||
### 获取帮助
|
||||
|
||||
- **问题反馈**: [GitHub Issues](https://github.com/your-username/autoclip/issues)
|
||||
- **功能建议**: [GitHub Discussions](https://github.com/your-username/autoclip/discussions)
|
||||
- **Bug报告**: 请使用GitHub Issues模板
|
||||
- **文档**: [项目文档](docs/)
|
||||
|
||||
### 联系方式
|
||||
|
||||
- **个人微信**: your_wechat_id
|
||||
- **飞书**: your_feishu_id
|
||||
|
||||
|
||||
|
||||
## 🙏 致谢
|
||||
|
||||
感谢以下开源项目的支持:
|
||||
感谢以下开源项目和服务的支持:
|
||||
|
||||
### 核心技术栈
|
||||
- [FastAPI](https://fastapi.tiangolo.com/) - 现代化Python Web框架
|
||||
- [React](https://reactjs.org/) - 用户界面库
|
||||
- [Ant Design](https://ant.design/) - 企业级UI设计语言
|
||||
- [yt-dlp](https://github.com/yt-dlp/yt-dlp) - YouTube视频下载工具
|
||||
- [TypeScript](https://typescriptlang.org/) - JavaScript的超集
|
||||
- [Celery](https://docs.celeryproject.org/) - 分布式任务队列
|
||||
- [Redis](https://redis.io/) - 内存数据结构存储
|
||||
|
||||
### 视频处理
|
||||
- [yt-dlp](https://github.com/yt-dlp/yt-dlp) - YouTube视频下载工具
|
||||
- [FFmpeg](https://ffmpeg.org/) - 音视频处理框架
|
||||
- [bcut-asr](https://github.com/liou666/bcut-asr) - 语音识别服务
|
||||
|
||||
### AI服务
|
||||
- [通义千问](https://tongyi.aliyun.com/) - 阿里云大语言模型服务
|
||||
- [DashScope](https://dashscope.aliyun.com/) - 阿里云AI服务平台
|
||||
|
||||
### 开发工具
|
||||
- [Vite](https://vitejs.dev/) - 前端构建工具
|
||||
- [Zustand](https://github.com/pmndrs/zustand) - 状态管理库
|
||||
- [Pydantic](https://pydantic-docs.helpmanual.io/) - 数据验证库
|
||||
|
||||
### 特别感谢
|
||||
- 所有为开源社区贡献的开发者
|
||||
- 提供反馈和建议的用户
|
||||
- 参与测试和贡献代码的社区成员
|
||||
|
||||
---
|
||||
|
||||
@@ -488,6 +818,10 @@ WantedBy=multi-user.target
|
||||
|
||||
**如果这个项目对你有帮助,请给我们一个 ⭐ Star!**
|
||||
|
||||
[](https://star-history.com/#your-username/autoclip&Date)
|
||||
|
||||
Made with ❤️ by AutoClip Team
|
||||
|
||||
**⭐ 如果觉得有用,请给个Star支持一下!**
|
||||
|
||||
</div>
|
||||
|
||||
239
SECURITY.md
Normal file
239
SECURITY.md
Normal file
@@ -0,0 +1,239 @@
|
||||
# 安全政策
|
||||
|
||||
## 支持的版本
|
||||
|
||||
我们目前为以下版本提供安全更新:
|
||||
|
||||
| 版本 | 支持状态 |
|
||||
| ---- | -------- |
|
||||
| 1.0.x | ✅ 支持 |
|
||||
| 0.9.x | ❌ 不支持 |
|
||||
|
||||
## 报告安全漏洞
|
||||
|
||||
如果您发现了安全漏洞,请通过以下方式报告:
|
||||
|
||||
### 报告方式
|
||||
|
||||
**请勿在公开的GitHub Issues中报告安全漏洞!**
|
||||
|
||||
1. **邮件报告** (推荐)
|
||||
- 发送邮件至: security@autoclip.com
|
||||
- 主题: [SECURITY] 安全漏洞报告
|
||||
|
||||
2. **GitHub安全建议**
|
||||
- 访问: https://github.com/your-username/autoclip/security/advisories/new
|
||||
- 点击"Report a vulnerability"
|
||||
|
||||
### 报告内容
|
||||
|
||||
请包含以下信息:
|
||||
|
||||
1. **漏洞描述**
|
||||
- 详细描述安全漏洞
|
||||
- 影响的功能模块
|
||||
- 潜在的安全风险
|
||||
|
||||
2. **重现步骤**
|
||||
- 详细的重现步骤
|
||||
- 必要的环境配置
|
||||
- 相关的代码片段
|
||||
|
||||
3. **影响评估**
|
||||
- 漏洞的严重程度
|
||||
- 可能影响的用户范围
|
||||
- 潜在的数据泄露风险
|
||||
|
||||
4. **环境信息**
|
||||
- 操作系统版本
|
||||
- Python版本
|
||||
- 项目版本
|
||||
- 其他相关环境信息
|
||||
|
||||
### 响应时间
|
||||
|
||||
- **确认收到**: 24小时内
|
||||
- **初步评估**: 72小时内
|
||||
- **修复计划**: 7天内
|
||||
- **修复发布**: 根据严重程度决定
|
||||
|
||||
## 安全最佳实践
|
||||
|
||||
### 部署安全
|
||||
|
||||
1. **环境变量安全**
|
||||
```bash
|
||||
# 使用强密码
|
||||
API_DASHSCOPE_API_KEY=your_strong_api_key
|
||||
|
||||
# 定期轮换密钥
|
||||
# 不要在代码中硬编码敏感信息
|
||||
```
|
||||
|
||||
2. **网络安全**
|
||||
- 使用HTTPS部署
|
||||
- 配置防火墙规则
|
||||
- 限制API访问来源
|
||||
- 启用CORS保护
|
||||
|
||||
3. **数据安全**
|
||||
- 定期备份数据
|
||||
- 加密敏感数据
|
||||
- 实施访问控制
|
||||
- 监控异常访问
|
||||
|
||||
### 开发安全
|
||||
|
||||
1. **依赖管理**
|
||||
```bash
|
||||
# 定期更新依赖
|
||||
pip install --upgrade -r requirements.txt
|
||||
npm audit fix
|
||||
|
||||
# 检查安全漏洞
|
||||
pip install safety
|
||||
safety check
|
||||
```
|
||||
|
||||
2. **代码安全**
|
||||
- 输入验证和清理
|
||||
- SQL注入防护
|
||||
- XSS攻击防护
|
||||
- CSRF保护
|
||||
|
||||
3. **API安全**
|
||||
- 实施认证和授权
|
||||
- 限制请求频率
|
||||
- 验证输入参数
|
||||
- 记录安全日志
|
||||
|
||||
## 已知安全问题
|
||||
|
||||
### 已修复
|
||||
|
||||
- **CVE-2024-XXXX**: 描述已修复的安全问题
|
||||
- **CVE-2024-YYYY**: 另一个已修复的问题
|
||||
|
||||
### 待修复
|
||||
|
||||
- 暂无待修复的安全问题
|
||||
|
||||
## 安全更新
|
||||
|
||||
### 自动更新
|
||||
|
||||
我们建议用户:
|
||||
|
||||
1. **定期更新依赖**
|
||||
```bash
|
||||
# 后端依赖
|
||||
pip install --upgrade -r requirements.txt
|
||||
|
||||
# 前端依赖
|
||||
cd frontend && npm update
|
||||
```
|
||||
|
||||
2. **监控安全公告**
|
||||
- 关注GitHub安全公告
|
||||
- 订阅项目更新通知
|
||||
- 定期检查依赖漏洞
|
||||
|
||||
### 手动更新
|
||||
|
||||
对于关键安全更新:
|
||||
|
||||
1. 查看发布说明
|
||||
2. 备份现有数据
|
||||
3. 按照升级指南操作
|
||||
4. 验证系统功能
|
||||
|
||||
## 安全配置
|
||||
|
||||
### 生产环境配置
|
||||
|
||||
```bash
|
||||
# .env 生产环境配置示例
|
||||
ENVIRONMENT=production
|
||||
DEBUG=false
|
||||
LOG_LEVEL=WARNING
|
||||
|
||||
# 使用强密码
|
||||
API_DASHSCOPE_API_KEY=your_production_api_key
|
||||
ENCRYPTION_KEY=your_strong_encryption_key
|
||||
|
||||
# 数据库安全
|
||||
DATABASE_URL=postgresql://user:password@localhost/autoclip
|
||||
|
||||
# Redis安全
|
||||
REDIS_URL=redis://:password@localhost:6379/0
|
||||
```
|
||||
|
||||
### 网络安全
|
||||
|
||||
```nginx
|
||||
# Nginx配置示例
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name your-domain.com;
|
||||
|
||||
ssl_certificate /path/to/cert.pem;
|
||||
ssl_certificate_key /path/to/key.pem;
|
||||
|
||||
# 安全头
|
||||
add_header X-Frame-Options DENY;
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
add_header X-XSS-Protection "1; mode=block";
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:8000;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 安全审计
|
||||
|
||||
### 定期审计
|
||||
|
||||
我们定期进行以下安全审计:
|
||||
|
||||
1. **依赖审计**
|
||||
- 检查已知漏洞
|
||||
- 更新过时依赖
|
||||
- 移除未使用依赖
|
||||
|
||||
2. **代码审计**
|
||||
- 静态代码分析
|
||||
- 安全代码审查
|
||||
- 渗透测试
|
||||
|
||||
3. **配置审计**
|
||||
- 检查安全配置
|
||||
- 验证访问控制
|
||||
- 测试备份恢复
|
||||
|
||||
### 第三方审计
|
||||
|
||||
- 定期邀请安全专家审计
|
||||
- 参与开源安全项目
|
||||
- 遵循安全最佳实践
|
||||
|
||||
## 联系信息
|
||||
|
||||
- **安全邮箱**: security@autoclip.com
|
||||
- **项目维护者**: [GitHub Profile](https://github.com/your-username)
|
||||
- **紧急联系**: 通过GitHub Issues标记为"security"
|
||||
|
||||
## 免责声明
|
||||
|
||||
本安全政策旨在帮助用户安全地使用AutoClip项目。我们努力保持项目的安全性,但不能保证绝对安全。用户需要:
|
||||
|
||||
1. 自行评估安全风险
|
||||
2. 采取适当的安全措施
|
||||
3. 定期更新和维护系统
|
||||
4. 遵守相关法律法规
|
||||
|
||||
---
|
||||
|
||||
**最后更新**: 2024-01-15
|
||||
@@ -184,7 +184,7 @@ async def delete_collection(
|
||||
):
|
||||
"""Delete a collection."""
|
||||
try:
|
||||
success = collection_service.delete(collection_id)
|
||||
success = collection_service.delete_collection_with_filesystem_update(collection_id)
|
||||
if not success:
|
||||
raise HTTPException(status_code=404, detail="Collection not found")
|
||||
return {"message": "Collection deleted successfully"}
|
||||
|
||||
@@ -1154,12 +1154,12 @@ async def generate_collection_video(
|
||||
if not found:
|
||||
raise HTTPException(status_code=404, detail=f"切片视频文件不存在: {clip.id}")
|
||||
|
||||
# 生成合集视频文件名
|
||||
# 生成合集视频文件名 - 使用合集标题作为文件名
|
||||
collection_name = collection.name or f"collection_{collection_id}"
|
||||
# 清理文件名中的特殊字符
|
||||
safe_name = "".join(c for c in collection_name if c.isalnum() or c in (' ', '-', '_')).rstrip()
|
||||
safe_name = safe_name.replace(' ', '_')
|
||||
output_filename = f"{collection_id}_{safe_name}.mp4"
|
||||
# 使用VideoProcessor的sanitize_filename方法清理文件名
|
||||
from ...utils.video_processor import VideoProcessor
|
||||
safe_name = VideoProcessor.sanitize_filename(collection_name)
|
||||
output_filename = f"{safe_name}.mp4"
|
||||
output_path = collections_dir / output_filename
|
||||
|
||||
# 使用VideoProcessor创建合集
|
||||
@@ -1241,8 +1241,8 @@ async def download_project_file(
|
||||
|
||||
# 生成下载文件名
|
||||
collection_name = collection.name or f"collection_{collection_id}"
|
||||
safe_name = "".join(c for c in collection_name if c.isalnum() or c in (' ', '-', '_')).rstrip()
|
||||
safe_name = safe_name.replace(' ', '_')
|
||||
from ...utils.video_processor import VideoProcessor
|
||||
safe_name = VideoProcessor.sanitize_filename(collection_name)
|
||||
filename = f"{safe_name}.mp4"
|
||||
|
||||
# 对文件名进行URL编码
|
||||
@@ -1274,16 +1274,20 @@ async def download_project_file(
|
||||
|
||||
# 生成下载文件名
|
||||
clip_title = clip.title or f"clip_{clip_id}"
|
||||
safe_name = "".join(c for c in clip_title if c.isalnum() or c in (' ', '-', '_')).rstrip()
|
||||
safe_name = safe_name.replace(' ', '_')
|
||||
from ...utils.video_processor import VideoProcessor
|
||||
safe_name = VideoProcessor.sanitize_filename(clip_title)
|
||||
filename = f"{safe_name}.mp4"
|
||||
|
||||
# 对文件名进行URL编码
|
||||
import urllib.parse
|
||||
encoded_filename = urllib.parse.quote(filename.encode('utf-8'))
|
||||
|
||||
return FileResponse(
|
||||
path=str(file_path),
|
||||
filename=filename,
|
||||
media_type="video/mp4",
|
||||
headers={
|
||||
"Content-Disposition": f"attachment; filename*=UTF-8''{filename}"
|
||||
"Content-Disposition": f"attachment; filename*=UTF-8''{encoded_filename}"
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
160
backend/scripts/generate_collection_thumbnails.py
Normal file
160
backend/scripts/generate_collection_thumbnails.py
Normal file
@@ -0,0 +1,160 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
为所有合集生成封面缩略图
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
# 添加项目根目录到Python路径
|
||||
project_root = Path(__file__).parent.parent.parent
|
||||
if str(project_root) not in sys.path:
|
||||
sys.path.insert(0, str(project_root))
|
||||
|
||||
from backend.core.database import get_db
|
||||
from backend.models.collection import Collection
|
||||
from backend.utils.video_processor import VideoProcessor
|
||||
import logging
|
||||
|
||||
# 配置日志
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
def generate_collection_thumbnails():
|
||||
"""为所有没有封面的合集生成缩略图"""
|
||||
try:
|
||||
db = next(get_db())
|
||||
|
||||
# 查找所有没有封面的合集
|
||||
collections_without_thumbnails = db.query(Collection).filter(
|
||||
Collection.thumbnail_path.is_(None)
|
||||
).all()
|
||||
|
||||
if not collections_without_thumbnails:
|
||||
logger.info("所有合集都已经有封面了")
|
||||
return True
|
||||
|
||||
logger.info(f"找到 {len(collections_without_thumbnails)} 个没有封面的合集")
|
||||
|
||||
success_count = 0
|
||||
for collection in collections_without_thumbnails:
|
||||
try:
|
||||
logger.info(f"正在为合集 '{collection.name}' ({collection.id}) 生成封面...")
|
||||
|
||||
# 检查是否有导出视频文件
|
||||
if not collection.export_path:
|
||||
logger.warning(f"合集 '{collection.name}' 没有导出视频文件,跳过")
|
||||
continue
|
||||
|
||||
video_path = Path(collection.export_path)
|
||||
if not video_path.exists():
|
||||
logger.warning(f"合集 '{collection.name}' 的视频文件不存在: {video_path}")
|
||||
continue
|
||||
|
||||
# 生成封面文件名
|
||||
safe_name = "".join(c for c in collection.name if c.isalnum() or c in (' ', '-', '_')).rstrip()
|
||||
safe_name = safe_name.replace(' ', '_')
|
||||
thumbnail_filename = f"{collection.id}_{safe_name}_thumbnail.jpg"
|
||||
thumbnail_path = video_path.parent / thumbnail_filename
|
||||
|
||||
# 使用VideoProcessor生成封面
|
||||
thumbnail_success = VideoProcessor.extract_thumbnail(video_path, thumbnail_path, time_offset=5)
|
||||
|
||||
if thumbnail_success:
|
||||
# 更新数据库
|
||||
collection.thumbnail_path = str(thumbnail_path)
|
||||
db.commit()
|
||||
logger.info(f"✅ 合集 '{collection.name}' 封面生成成功: {thumbnail_path}")
|
||||
success_count += 1
|
||||
else:
|
||||
logger.error(f"❌ 合集 '{collection.name}' 封面生成失败")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"❌ 合集 '{collection.name}' 处理失败: {e}")
|
||||
db.rollback()
|
||||
continue
|
||||
|
||||
logger.info(f"🎉 完成!成功为 {success_count}/{len(collections_without_thumbnails)} 个合集生成封面")
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"❌ 生成合集封面过程中发生错误: {e}")
|
||||
return False
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
def generate_thumbnail_for_collection(collection_id: str):
|
||||
"""为指定合集生成缩略图"""
|
||||
try:
|
||||
db = next(get_db())
|
||||
|
||||
collection = db.query(Collection).filter(Collection.id == collection_id).first()
|
||||
if not collection:
|
||||
logger.error(f"合集不存在: {collection_id}")
|
||||
return False
|
||||
|
||||
if collection.thumbnail_path:
|
||||
logger.info(f"合集 '{collection.name}' 已经有封面了")
|
||||
return True
|
||||
|
||||
# 检查是否有导出视频文件
|
||||
if not collection.export_path:
|
||||
logger.error(f"合集 '{collection.name}' 没有导出视频文件")
|
||||
return False
|
||||
|
||||
video_path = Path(collection.export_path)
|
||||
if not video_path.exists():
|
||||
logger.error(f"合集 '{collection.name}' 的视频文件不存在: {video_path}")
|
||||
return False
|
||||
|
||||
# 生成封面文件名
|
||||
safe_name = "".join(c for c in collection.name if c.isalnum() or c in (' ', '-', '_')).rstrip()
|
||||
safe_name = safe_name.replace(' ', '_')
|
||||
thumbnail_filename = f"{collection.id}_{safe_name}_thumbnail.jpg"
|
||||
thumbnail_path = video_path.parent / thumbnail_filename
|
||||
|
||||
# 使用VideoProcessor生成封面
|
||||
thumbnail_success = VideoProcessor.extract_thumbnail(video_path, thumbnail_path, time_offset=5)
|
||||
|
||||
if thumbnail_success:
|
||||
# 更新数据库
|
||||
collection.thumbnail_path = str(thumbnail_path)
|
||||
db.commit()
|
||||
logger.info(f"✅ 合集 '{collection.name}' 封面生成成功: {thumbnail_path}")
|
||||
return True
|
||||
else:
|
||||
logger.error(f"❌ 合集 '{collection.name}' 封面生成失败")
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"❌ 生成合集封面时发生错误: {e}")
|
||||
return False
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
def main():
|
||||
"""主函数"""
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(description='为合集生成封面缩略图')
|
||||
parser.add_argument('--collection-id', help='为指定合集生成封面')
|
||||
parser.add_argument('--all', action='store_true', help='为所有没有封面的合集生成封面')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.collection_id:
|
||||
success = generate_thumbnail_for_collection(args.collection_id)
|
||||
elif args.all:
|
||||
success = generate_collection_thumbnails()
|
||||
else:
|
||||
print("请指定 --collection-id 或 --all 参数")
|
||||
return
|
||||
|
||||
if success:
|
||||
print("操作完成")
|
||||
else:
|
||||
print("操作失败")
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -27,12 +27,91 @@ class CollectionService(BaseService[Collection, CollectionCreate, CollectionUpda
|
||||
|
||||
def update_collection(self, collection_id: str, collection_data: CollectionUpdate) -> Optional[Collection]:
|
||||
"""Update a collection with business logic."""
|
||||
update_data = {k: v for k, v in collection_data.model_dump().items() if v is not None}
|
||||
# 获取所有字段,包括None值
|
||||
all_data = collection_data.model_dump()
|
||||
|
||||
# 过滤掉None值,但保留metadata字段
|
||||
update_data = {k: v for k, v in all_data.items() if v is not None or k == 'metadata'}
|
||||
|
||||
# 如果metadata字段存在,需要合并而不是覆盖
|
||||
if 'metadata' in all_data:
|
||||
# 获取当前合集的metadata
|
||||
current_collection = self.get(collection_id)
|
||||
if current_collection:
|
||||
current_metadata = getattr(current_collection, 'collection_metadata', {}) or {}
|
||||
new_metadata = collection_data.metadata or {}
|
||||
|
||||
# 合并metadata,新值覆盖旧值
|
||||
merged_metadata = {**current_metadata, **new_metadata}
|
||||
# 使用正确的字段名 collection_metadata
|
||||
update_data['collection_metadata'] = merged_metadata
|
||||
# 移除错误的字段名
|
||||
if 'metadata' in update_data:
|
||||
del update_data['metadata']
|
||||
|
||||
if not update_data:
|
||||
return self.get(collection_id)
|
||||
|
||||
return self.update(collection_id, **update_data)
|
||||
|
||||
def delete_collection_with_filesystem_update(self, collection_id: str) -> bool:
|
||||
"""删除合集并更新文件系统的删除记录"""
|
||||
import logging
|
||||
import json
|
||||
from pathlib import Path
|
||||
from datetime import datetime
|
||||
from ..core.path_utils import get_project_directory
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# 获取合集信息
|
||||
collection = self.get(collection_id)
|
||||
if not collection:
|
||||
return False
|
||||
|
||||
project_id = collection.project_id
|
||||
|
||||
# 删除数据库记录
|
||||
success = self.delete(collection_id)
|
||||
if not success:
|
||||
return False
|
||||
|
||||
# 更新文件系统的删除记录
|
||||
try:
|
||||
project_dir = get_project_directory(project_id)
|
||||
deleted_collections_file = project_dir / "deleted_collections.json"
|
||||
|
||||
# 读取现有的删除记录
|
||||
deleted_collections = []
|
||||
if deleted_collections_file.exists():
|
||||
try:
|
||||
with open(deleted_collections_file, 'r', encoding='utf-8') as f:
|
||||
data = json.load(f)
|
||||
deleted_collections = data.get('deleted_collection_ids', [])
|
||||
except Exception as e:
|
||||
logger.warning(f"读取删除记录文件失败: {e}")
|
||||
|
||||
# 添加新的删除记录
|
||||
if collection_id not in deleted_collections:
|
||||
deleted_collections.append(collection_id)
|
||||
|
||||
# 保存更新后的删除记录
|
||||
deleted_data = {
|
||||
'deleted_collection_ids': deleted_collections,
|
||||
'last_updated': datetime.now().isoformat()
|
||||
}
|
||||
|
||||
with open(deleted_collections_file, 'w', encoding='utf-8') as f:
|
||||
json.dump(deleted_data, f, ensure_ascii=False, indent=2)
|
||||
|
||||
logger.info(f"已更新删除记录文件: {deleted_collections_file}")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"更新删除记录文件失败: {e}")
|
||||
# 即使文件更新失败,数据库删除已经成功,所以返回True
|
||||
|
||||
return True
|
||||
|
||||
def get_collections_by_project(self, project_id: str, skip: int = 0, limit: int = 100) -> List[Collection]:
|
||||
"""Get collections by project ID."""
|
||||
return self.repository.find_by(project_id=project_id)
|
||||
|
||||
@@ -193,6 +193,23 @@ class VideoProcessor:
|
||||
是否成功
|
||||
"""
|
||||
try:
|
||||
# 验证输入参数
|
||||
if not clips_list:
|
||||
logger.error("clips_list为空,无法创建合集")
|
||||
return False
|
||||
|
||||
# 验证所有视频文件是否存在
|
||||
valid_clips = []
|
||||
for clip_path in clips_list:
|
||||
if not clip_path.exists():
|
||||
logger.warning(f"视频文件不存在,跳过: {clip_path}")
|
||||
continue
|
||||
valid_clips.append(clip_path)
|
||||
|
||||
if not valid_clips:
|
||||
logger.error("没有有效的视频文件,无法创建合集")
|
||||
return False
|
||||
|
||||
# 确保输出目录存在
|
||||
output_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
@@ -200,20 +217,36 @@ class VideoProcessor:
|
||||
concat_file = output_path.parent / "concat_list.txt"
|
||||
|
||||
with open(concat_file, 'w', encoding='utf-8') as f:
|
||||
for clip_path in clips_list:
|
||||
f.write(f"file '{clip_path.absolute()}'\n")
|
||||
for clip_path in valid_clips:
|
||||
# 使用绝对路径并转义单引号
|
||||
abs_path = clip_path.absolute()
|
||||
escaped_path = str(abs_path).replace("'", "'\"'\"'")
|
||||
f.write(f"file '{escaped_path}'\n")
|
||||
|
||||
# 构建FFmpeg命令
|
||||
# 验证concat文件内容
|
||||
if concat_file.stat().st_size == 0:
|
||||
logger.error("concat文件为空,无法创建合集")
|
||||
concat_file.unlink(missing_ok=True)
|
||||
return False
|
||||
|
||||
# 构建FFmpeg命令 - 使用H.264编码确保兼容性
|
||||
cmd = [
|
||||
'ffmpeg',
|
||||
'-f', 'concat',
|
||||
'-safe', '0',
|
||||
'-i', str(concat_file),
|
||||
'-c', 'copy',
|
||||
'-c:v', 'libx264', # 使用H.264视频编码
|
||||
'-preset', 'ultrafast', # 使用最快的编码预设
|
||||
'-crf', '28', # 稍微降低质量以加快编码速度
|
||||
'-c:a', 'aac', # 使用AAC音频编码
|
||||
'-b:a', '128k', # 音频比特率
|
||||
'-movflags', '+faststart', # 优化网络播放
|
||||
'-y',
|
||||
str(output_path)
|
||||
]
|
||||
|
||||
logger.info(f"执行FFmpeg命令: {' '.join(cmd)}")
|
||||
|
||||
# 执行命令
|
||||
result = subprocess.run(cmd, capture_output=True, text=True, encoding='utf-8', errors='ignore')
|
||||
|
||||
@@ -225,6 +258,7 @@ class VideoProcessor:
|
||||
return True
|
||||
else:
|
||||
logger.error(f"创建合集失败: {result.stderr}")
|
||||
logger.error(f"FFmpeg stdout: {result.stdout}")
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
|
||||
82
docker-compose.dev.yml
Normal file
82
docker-compose.dev.yml
Normal file
@@ -0,0 +1,82 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
# Redis服务
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
container_name: autoclip-redis-dev
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "6379:6379"
|
||||
volumes:
|
||||
- redis_dev_data:/data
|
||||
command: redis-server --appendonly yes
|
||||
|
||||
# 主应用服务(开发模式)
|
||||
autoclip-dev:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.dev
|
||||
container_name: autoclip-app-dev
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8000:8000" # 后端API
|
||||
- "3000:3000" # 前端界面
|
||||
volumes:
|
||||
- ./backend:/app/backend
|
||||
- ./frontend:/app/frontend
|
||||
- ./data:/app/data
|
||||
- ./logs:/app/logs
|
||||
- ./uploads:/app/uploads
|
||||
- /app/venv # 排除虚拟环境
|
||||
environment:
|
||||
- REDIS_URL=redis://redis:6379/0
|
||||
- DATABASE_URL=sqlite:///./data/autoclip.db
|
||||
- ENVIRONMENT=development
|
||||
- DEBUG=true
|
||||
- LOG_LEVEL=DEBUG
|
||||
depends_on:
|
||||
- redis
|
||||
command: >
|
||||
sh -c "
|
||||
source venv/bin/activate &&
|
||||
python -m uvicorn backend.main:app --host 0.0.0.0 --port 8000 --reload &
|
||||
cd frontend && npm run dev -- --host 0.0.0.0 --port 3000 &
|
||||
wait
|
||||
"
|
||||
|
||||
# Celery Worker服务(开发模式)
|
||||
celery-worker-dev:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.dev
|
||||
container_name: autoclip-celery-worker-dev
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./backend:/app/backend
|
||||
- ./data:/app/data
|
||||
- ./logs:/app/logs
|
||||
- ./uploads:/app/uploads
|
||||
- /app/venv
|
||||
environment:
|
||||
- REDIS_URL=redis://redis:6379/0
|
||||
- DATABASE_URL=sqlite:///./data/autoclip.db
|
||||
- ENVIRONMENT=development
|
||||
- DEBUG=true
|
||||
- LOG_LEVEL=DEBUG
|
||||
command: >
|
||||
sh -c "
|
||||
source venv/bin/activate &&
|
||||
celery -A backend.core.celery_app worker --loglevel=debug --reload
|
||||
"
|
||||
depends_on:
|
||||
- redis
|
||||
- autoclip-dev
|
||||
|
||||
volumes:
|
||||
redis_dev_data:
|
||||
driver: local
|
||||
|
||||
networks:
|
||||
default:
|
||||
name: autoclip-dev-network
|
||||
123
docker-compose.yml
Normal file
123
docker-compose.yml
Normal file
@@ -0,0 +1,123 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
# Redis服务
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
container_name: autoclip-redis
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "6379:6379"
|
||||
volumes:
|
||||
- redis_data:/data
|
||||
command: redis-server --appendonly yes
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
# 主应用服务
|
||||
autoclip:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: autoclip-app
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8000:8000" # 后端API
|
||||
- "3000:3000" # 前端界面
|
||||
volumes:
|
||||
- ./data:/app/data
|
||||
- ./logs:/app/logs
|
||||
- ./uploads:/app/uploads
|
||||
environment:
|
||||
- REDIS_URL=redis://redis:6379/0
|
||||
- DATABASE_URL=sqlite:///./data/autoclip.db
|
||||
- ENVIRONMENT=production
|
||||
- DEBUG=false
|
||||
- LOG_LEVEL=INFO
|
||||
depends_on:
|
||||
redis:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8000/api/v1/health/"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
# Celery Worker服务
|
||||
celery-worker:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: autoclip-celery-worker
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./data:/app/data
|
||||
- ./logs:/app/logs
|
||||
- ./uploads:/app/uploads
|
||||
environment:
|
||||
- REDIS_URL=redis://redis:6379/0
|
||||
- DATABASE_URL=sqlite:///./data/autoclip.db
|
||||
- ENVIRONMENT=production
|
||||
- DEBUG=false
|
||||
- LOG_LEVEL=INFO
|
||||
command: celery -A backend.core.celery_app worker --loglevel=info --concurrency=2
|
||||
depends_on:
|
||||
redis:
|
||||
condition: service_healthy
|
||||
autoclip:
|
||||
condition: service_healthy
|
||||
|
||||
# Celery Beat调度器
|
||||
celery-beat:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: autoclip-celery-beat
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./data:/app/data
|
||||
- ./logs:/app/logs
|
||||
environment:
|
||||
- REDIS_URL=redis://redis:6379/0
|
||||
- DATABASE_URL=sqlite:///./data/autoclip.db
|
||||
- ENVIRONMENT=production
|
||||
- DEBUG=false
|
||||
- LOG_LEVEL=INFO
|
||||
command: celery -A backend.core.celery_app beat --loglevel=info
|
||||
depends_on:
|
||||
redis:
|
||||
condition: service_healthy
|
||||
autoclip:
|
||||
condition: service_healthy
|
||||
|
||||
# Flower监控服务(可选)
|
||||
flower:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: autoclip-flower
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "5555:5555"
|
||||
environment:
|
||||
- REDIS_URL=redis://redis:6379/0
|
||||
- DATABASE_URL=sqlite:///./data/autoclip.db
|
||||
- ENVIRONMENT=production
|
||||
command: celery -A backend.core.celery_app flower --port=5555
|
||||
depends_on:
|
||||
redis:
|
||||
condition: service_healthy
|
||||
celery-worker:
|
||||
condition: service_started
|
||||
|
||||
volumes:
|
||||
redis_data:
|
||||
driver: local
|
||||
|
||||
networks:
|
||||
default:
|
||||
name: autoclip-network
|
||||
232
docker-start.sh
Executable file
232
docker-start.sh
Executable file
@@ -0,0 +1,232 @@
|
||||
#!/bin/bash
|
||||
|
||||
# AutoClip Docker 启动脚本
|
||||
# 版本: 1.0
|
||||
# 功能: 使用Docker快速启动AutoClip系统
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# =============================================================================
|
||||
# 配置区域
|
||||
# =============================================================================
|
||||
|
||||
# 颜色定义
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
PURPLE='\033[0;35m'
|
||||
CYAN='\033[0;36m'
|
||||
WHITE='\033[1;37m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# 图标定义
|
||||
ICON_SUCCESS="✅"
|
||||
ICON_ERROR="❌"
|
||||
ICON_WARNING="⚠️"
|
||||
ICON_INFO="ℹ️"
|
||||
ICON_ROCKET="🚀"
|
||||
ICON_DOCKER="🐳"
|
||||
|
||||
# =============================================================================
|
||||
# 工具函数
|
||||
# =============================================================================
|
||||
|
||||
log_info() {
|
||||
echo -e "${BLUE}${ICON_INFO} $1${NC}"
|
||||
}
|
||||
|
||||
log_success() {
|
||||
echo -e "${GREEN}${ICON_SUCCESS} $1${NC}"
|
||||
}
|
||||
|
||||
log_warning() {
|
||||
echo -e "${YELLOW}${ICON_WARNING} $1${NC}"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}${ICON_ERROR} $1${NC}"
|
||||
}
|
||||
|
||||
log_header() {
|
||||
echo -e "\n${PURPLE}${ICON_ROCKET} $1${NC}"
|
||||
echo -e "${PURPLE}$(printf '=%.0s' {1..50})${NC}"
|
||||
}
|
||||
|
||||
# =============================================================================
|
||||
# 检查函数
|
||||
# =============================================================================
|
||||
|
||||
check_docker() {
|
||||
log_header "检查Docker环境"
|
||||
|
||||
if ! command -v docker >/dev/null 2>&1; then
|
||||
log_error "Docker未安装,请先安装Docker"
|
||||
exit 1
|
||||
fi
|
||||
log_success "Docker已安装"
|
||||
|
||||
if ! command -v docker-compose >/dev/null 2>&1; then
|
||||
log_error "Docker Compose未安装,请先安装Docker Compose"
|
||||
exit 1
|
||||
fi
|
||||
log_success "Docker Compose已安装"
|
||||
|
||||
if ! docker info >/dev/null 2>&1; then
|
||||
log_error "Docker服务未运行,请启动Docker服务"
|
||||
exit 1
|
||||
fi
|
||||
log_success "Docker服务运行正常"
|
||||
}
|
||||
|
||||
check_environment() {
|
||||
log_header "检查环境配置"
|
||||
|
||||
if [[ ! -f ".env" ]]; then
|
||||
log_warning ".env文件不存在,创建默认配置..."
|
||||
if [[ -f "env.example" ]]; then
|
||||
cp env.example .env
|
||||
log_success "已创建默认.env文件"
|
||||
log_warning "请编辑.env文件,填入必要的配置(特别是API密钥)"
|
||||
else
|
||||
log_error "env.example文件不存在"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
log_success ".env文件存在"
|
||||
fi
|
||||
|
||||
# 检查必要的配置
|
||||
if ! grep -q "API_DASHSCOPE_API_KEY" .env || grep -q "API_DASHSCOPE_API_KEY=$" .env; then
|
||||
log_warning "API_DASHSCOPE_API_KEY未配置,AI功能将不可用"
|
||||
fi
|
||||
}
|
||||
|
||||
check_ports() {
|
||||
log_header "检查端口占用"
|
||||
|
||||
local ports=(8000 3000 6379 5555)
|
||||
local occupied_ports=()
|
||||
|
||||
for port in "${ports[@]}"; do
|
||||
if lsof -i ":$port" >/dev/null 2>&1; then
|
||||
occupied_ports+=("$port")
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ${#occupied_ports[@]} -gt 0 ]]; then
|
||||
log_warning "以下端口被占用: ${occupied_ports[*]}"
|
||||
log_info "Docker会自动处理端口冲突,但建议先停止占用这些端口的服务"
|
||||
else
|
||||
log_success "所有端口可用"
|
||||
fi
|
||||
}
|
||||
|
||||
# =============================================================================
|
||||
# 启动函数
|
||||
# =============================================================================
|
||||
|
||||
start_services() {
|
||||
log_header "启动AutoClip服务"
|
||||
|
||||
# 选择启动模式
|
||||
if [[ "${1:-}" == "dev" ]]; then
|
||||
log_info "启动开发环境..."
|
||||
docker-compose -f docker-compose.dev.yml up -d
|
||||
COMPOSE_FILE="docker-compose.dev.yml"
|
||||
else
|
||||
log_info "启动生产环境..."
|
||||
docker-compose up -d
|
||||
COMPOSE_FILE="docker-compose.yml"
|
||||
fi
|
||||
|
||||
# 等待服务启动
|
||||
log_info "等待服务启动..."
|
||||
sleep 10
|
||||
|
||||
# 检查服务状态
|
||||
if docker-compose -f "$COMPOSE_FILE" ps | grep -q "Up"; then
|
||||
log_success "服务启动成功"
|
||||
else
|
||||
log_error "服务启动失败"
|
||||
log_info "查看日志: docker-compose -f $COMPOSE_FILE logs"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
show_status() {
|
||||
log_header "服务状态"
|
||||
|
||||
echo -e "${CYAN}📊 容器状态:${NC}"
|
||||
docker-compose ps
|
||||
|
||||
echo -e "\n${CYAN}🌐 访问地址:${NC}"
|
||||
echo -e " 前端界面: http://localhost:3000"
|
||||
echo -e " 后端API: http://localhost:8000"
|
||||
echo -e " API文档: http://localhost:8000/docs"
|
||||
echo -e " Flower监控: http://localhost:5555"
|
||||
|
||||
echo -e "\n${CYAN}📝 常用命令:${NC}"
|
||||
echo -e " 查看日志: docker-compose logs -f"
|
||||
echo -e " 停止服务: docker-compose down"
|
||||
echo -e " 重启服务: docker-compose restart"
|
||||
echo -e " 进入容器: docker-compose exec autoclip bash"
|
||||
}
|
||||
|
||||
# =============================================================================
|
||||
# 主函数
|
||||
# =============================================================================
|
||||
|
||||
main() {
|
||||
log_header "AutoClip Docker 启动器 v1.0"
|
||||
|
||||
# 解析参数
|
||||
local mode="production"
|
||||
if [[ "${1:-}" == "dev" ]]; then
|
||||
mode="development"
|
||||
fi
|
||||
|
||||
log_info "启动模式: $mode"
|
||||
|
||||
# 执行检查
|
||||
check_docker
|
||||
check_environment
|
||||
check_ports
|
||||
|
||||
# 启动服务
|
||||
start_services "$mode"
|
||||
|
||||
# 显示状态
|
||||
show_status
|
||||
|
||||
echo -e "\n${WHITE}🎉 AutoClip Docker 部署完成!${NC}"
|
||||
echo -e "${YELLOW}💡 提示: 首次启动可能需要几分钟来下载和构建镜像${NC}"
|
||||
}
|
||||
|
||||
# 显示帮助信息
|
||||
show_help() {
|
||||
echo "AutoClip Docker 启动脚本"
|
||||
echo ""
|
||||
echo "用法:"
|
||||
echo " $0 [选项]"
|
||||
echo ""
|
||||
echo "选项:"
|
||||
echo " dev 启动开发环境"
|
||||
echo " help 显示帮助信息"
|
||||
echo ""
|
||||
echo "示例:"
|
||||
echo " $0 # 启动生产环境"
|
||||
echo " $0 dev # 启动开发环境"
|
||||
echo " $0 help # 显示帮助"
|
||||
}
|
||||
|
||||
# 处理参数
|
||||
case "${1:-}" in
|
||||
"help"|"-h"|"--help")
|
||||
show_help
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
main "$@"
|
||||
;;
|
||||
esac
|
||||
265
docker-status.sh
Executable file
265
docker-status.sh
Executable file
@@ -0,0 +1,265 @@
|
||||
#!/bin/bash
|
||||
|
||||
# AutoClip Docker 状态检查脚本
|
||||
# 版本: 1.0
|
||||
# 功能: 检查AutoClip Docker服务状态
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# =============================================================================
|
||||
# 配置区域
|
||||
# =============================================================================
|
||||
|
||||
# 颜色定义
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
PURPLE='\033[0;35m'
|
||||
CYAN='\033[0;36m'
|
||||
WHITE='\033[1;37m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# 图标定义
|
||||
ICON_SUCCESS="✅"
|
||||
ICON_ERROR="❌"
|
||||
ICON_WARNING="⚠️"
|
||||
ICON_INFO="ℹ️"
|
||||
ICON_HEALTH="💚"
|
||||
ICON_SICK="🤒"
|
||||
ICON_ROCKET="🚀"
|
||||
ICON_DOCKER="🐳"
|
||||
|
||||
# =============================================================================
|
||||
# 工具函数
|
||||
# =============================================================================
|
||||
|
||||
log_info() {
|
||||
echo -e "${BLUE}${ICON_INFO} $1${NC}"
|
||||
}
|
||||
|
||||
log_success() {
|
||||
echo -e "${GREEN}${ICON_SUCCESS} $1${NC}"
|
||||
}
|
||||
|
||||
log_warning() {
|
||||
echo -e "${YELLOW}${ICON_WARNING} $1${NC}"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}${ICON_ERROR} $1${NC}"
|
||||
}
|
||||
|
||||
log_header() {
|
||||
echo -e "\n${PURPLE}${ICON_ROCKET} $1${NC}"
|
||||
echo -e "${PURPLE}$(printf '=%.0s' {1..50})${NC}"
|
||||
}
|
||||
|
||||
# =============================================================================
|
||||
# 检查函数
|
||||
# =============================================================================
|
||||
|
||||
check_docker() {
|
||||
log_header "Docker环境检查"
|
||||
|
||||
if ! command -v docker >/dev/null 2>&1; then
|
||||
log_error "Docker未安装"
|
||||
return 1
|
||||
fi
|
||||
log_success "Docker已安装"
|
||||
|
||||
if ! command -v docker-compose >/dev/null 2>&1; then
|
||||
log_error "Docker Compose未安装"
|
||||
return 1
|
||||
fi
|
||||
log_success "Docker Compose已安装"
|
||||
|
||||
if ! docker info >/dev/null 2>&1; then
|
||||
log_error "Docker服务未运行"
|
||||
return 1
|
||||
fi
|
||||
log_success "Docker服务运行正常"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
check_containers() {
|
||||
log_header "容器状态检查"
|
||||
|
||||
local containers=$(docker ps -a --filter "name=autoclip" --format "{{.Names}}\t{{.Status}}\t{{.Ports}}" 2>/dev/null || true)
|
||||
|
||||
if [[ -z "$containers" ]]; then
|
||||
log_warning "没有发现AutoClip容器"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo -e "${CYAN}📊 容器状态:${NC}"
|
||||
echo "$containers" | while IFS=$'\t' read -r name status ports; do
|
||||
if [[ "$status" == *"Up"* ]]; then
|
||||
echo -e " ${GREEN}${ICON_HEALTH} $name${NC} - $status"
|
||||
else
|
||||
echo -e " ${RED}${ICON_SICK} $name${NC} - $status"
|
||||
fi
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
check_services() {
|
||||
log_header "服务健康检查"
|
||||
|
||||
# 检查后端API
|
||||
if curl -fsS "http://localhost:8000/api/v1/health/" >/dev/null 2>&1; then
|
||||
log_success "后端API服务健康"
|
||||
else
|
||||
log_error "后端API服务不健康"
|
||||
fi
|
||||
|
||||
# 检查前端服务
|
||||
if curl -fsS "http://localhost:3000/" >/dev/null 2>&1; then
|
||||
log_success "前端服务健康"
|
||||
else
|
||||
log_error "前端服务不健康"
|
||||
fi
|
||||
|
||||
# 检查Redis
|
||||
if docker exec autoclip-redis redis-cli ping >/dev/null 2>&1; then
|
||||
log_success "Redis服务健康"
|
||||
else
|
||||
log_error "Redis服务不健康"
|
||||
fi
|
||||
}
|
||||
|
||||
check_volumes() {
|
||||
log_header "数据卷检查"
|
||||
|
||||
local volumes=$(docker volume ls --filter "name=autoclip" --format "{{.Name}}\t{{.Driver}}\t{{.Size}}" 2>/dev/null || true)
|
||||
|
||||
if [[ -z "$volumes" ]]; then
|
||||
log_warning "没有发现AutoClip数据卷"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo -e "${CYAN}💾 数据卷:${NC}"
|
||||
echo "$volumes" | while IFS=$'\t' read -r name driver size; do
|
||||
echo -e " ${ICON_INFO} $name ($driver) - $size"
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
check_networks() {
|
||||
log_header "网络检查"
|
||||
|
||||
local networks=$(docker network ls --filter "name=autoclip" --format "{{.Name}}\t{{.Driver}}\t{{.Scope}}" 2>/dev/null || true)
|
||||
|
||||
if [[ -z "$networks" ]]; then
|
||||
log_warning "没有发现AutoClip网络"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo -e "${CYAN}🌐 网络:${NC}"
|
||||
echo "$networks" | while IFS=$'\t' read -r name driver scope; do
|
||||
echo -e " ${ICON_INFO} $name ($driver) - $scope"
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
check_resources() {
|
||||
log_header "资源使用情况"
|
||||
|
||||
echo -e "${CYAN}📊 容器资源使用:${NC}"
|
||||
docker stats --no-stream --format "table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.NetIO}}\t{{.BlockIO}}" $(docker ps --filter "name=autoclip" --format "{{.Names}}" 2>/dev/null || true) 2>/dev/null || log_warning "无法获取资源使用情况"
|
||||
}
|
||||
|
||||
show_access_info() {
|
||||
log_header "访问信息"
|
||||
|
||||
echo -e "${CYAN}🌐 服务访问地址:${NC}"
|
||||
echo -e " 前端界面: http://localhost:3000"
|
||||
echo -e " 后端API: http://localhost:8000"
|
||||
echo -e " API文档: http://localhost:8000/docs"
|
||||
echo -e " Flower监控: http://localhost:5555"
|
||||
|
||||
echo -e "\n${CYAN}📝 常用命令:${NC}"
|
||||
echo -e " 查看日志: docker-compose logs -f"
|
||||
echo -e " 停止服务: docker-compose down"
|
||||
echo -e " 重启服务: docker-compose restart"
|
||||
echo -e " 进入容器: docker-compose exec autoclip bash"
|
||||
}
|
||||
|
||||
# =============================================================================
|
||||
# 主函数
|
||||
# =============================================================================
|
||||
|
||||
main() {
|
||||
log_header "AutoClip Docker 状态检查 v1.0"
|
||||
|
||||
local overall_status=0
|
||||
|
||||
# 检查Docker环境
|
||||
if ! check_docker; then
|
||||
overall_status=1
|
||||
fi
|
||||
|
||||
# 检查容器状态
|
||||
if ! check_containers; then
|
||||
overall_status=1
|
||||
fi
|
||||
|
||||
# 检查服务健康状态
|
||||
check_services
|
||||
|
||||
# 检查数据卷
|
||||
check_volumes
|
||||
|
||||
# 检查网络
|
||||
check_networks
|
||||
|
||||
# 检查资源使用
|
||||
check_resources
|
||||
|
||||
# 显示访问信息
|
||||
show_access_info
|
||||
|
||||
# 显示总体状态
|
||||
log_header "总体状态"
|
||||
|
||||
if [[ $overall_status -eq 0 ]]; then
|
||||
log_success "AutoClip Docker服务运行正常"
|
||||
echo -e "\n${WHITE}🎉 所有服务健康!${NC}"
|
||||
else
|
||||
log_error "部分服务存在问题"
|
||||
echo -e "\n${YELLOW}💡 建议操作:${NC}"
|
||||
echo -e " 1. 查看详细日志: docker-compose logs"
|
||||
echo -e " 2. 重启服务: docker-compose restart"
|
||||
echo -e " 3. 重新启动: ./docker-start.sh"
|
||||
fi
|
||||
}
|
||||
|
||||
# 显示帮助信息
|
||||
show_help() {
|
||||
echo "AutoClip Docker 状态检查脚本"
|
||||
echo ""
|
||||
echo "用法:"
|
||||
echo " $0 [选项]"
|
||||
echo ""
|
||||
echo "选项:"
|
||||
echo " help 显示帮助信息"
|
||||
echo ""
|
||||
echo "示例:"
|
||||
echo " $0 # 检查服务状态"
|
||||
echo " $0 help # 显示帮助"
|
||||
}
|
||||
|
||||
# 处理参数
|
||||
case "${1:-}" in
|
||||
"help"|"-h"|"--help")
|
||||
show_help
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
main "$@"
|
||||
;;
|
||||
esac
|
||||
225
docker-stop.sh
Executable file
225
docker-stop.sh
Executable file
@@ -0,0 +1,225 @@
|
||||
#!/bin/bash
|
||||
|
||||
# AutoClip Docker 停止脚本
|
||||
# 版本: 1.0
|
||||
# 功能: 停止AutoClip Docker服务
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# =============================================================================
|
||||
# 配置区域
|
||||
# =============================================================================
|
||||
|
||||
# 颜色定义
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
PURPLE='\033[0;35m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# 图标定义
|
||||
ICON_SUCCESS="✅"
|
||||
ICON_ERROR="❌"
|
||||
ICON_WARNING="⚠️"
|
||||
ICON_INFO="ℹ️"
|
||||
ICON_STOP="🛑"
|
||||
|
||||
# =============================================================================
|
||||
# 工具函数
|
||||
# =============================================================================
|
||||
|
||||
log_info() {
|
||||
echo -e "${BLUE}${ICON_INFO} $1${NC}"
|
||||
}
|
||||
|
||||
log_success() {
|
||||
echo -e "${GREEN}${ICON_SUCCESS} $1${NC}"
|
||||
}
|
||||
|
||||
log_warning() {
|
||||
echo -e "${YELLOW}${ICON_WARNING} $1${NC}"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}${ICON_ERROR} $1${NC}"
|
||||
}
|
||||
|
||||
log_header() {
|
||||
echo -e "\n${PURPLE}${ICON_STOP} $1${NC}"
|
||||
echo -e "${PURPLE}$(printf '=%.0s' {1..50})${NC}"
|
||||
}
|
||||
|
||||
# =============================================================================
|
||||
# 停止函数
|
||||
# =============================================================================
|
||||
|
||||
stop_services() {
|
||||
log_header "停止AutoClip服务"
|
||||
|
||||
local mode="${1:-production}"
|
||||
local compose_file="docker-compose.yml"
|
||||
|
||||
if [[ "$mode" == "dev" ]]; then
|
||||
compose_file="docker-compose.dev.yml"
|
||||
fi
|
||||
|
||||
log_info "停止服务 (模式: $mode)..."
|
||||
|
||||
# 停止服务
|
||||
if docker-compose -f "$compose_file" down; then
|
||||
log_success "服务已停止"
|
||||
else
|
||||
log_error "停止服务失败"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
cleanup_containers() {
|
||||
log_header "清理容器"
|
||||
|
||||
# 停止所有相关容器
|
||||
local containers=$(docker ps -a --filter "name=autoclip" --format "{{.Names}}" 2>/dev/null || true)
|
||||
|
||||
if [[ -n "$containers" ]]; then
|
||||
log_info "发现以下AutoClip容器:"
|
||||
echo "$containers"
|
||||
|
||||
if [[ "${1:-}" == "--force" ]]; then
|
||||
log_info "强制停止所有容器..."
|
||||
echo "$containers" | xargs docker stop 2>/dev/null || true
|
||||
echo "$containers" | xargs docker rm 2>/dev/null || true
|
||||
log_success "容器清理完成"
|
||||
else
|
||||
log_warning "使用 --force 参数强制清理容器"
|
||||
fi
|
||||
else
|
||||
log_success "没有发现AutoClip容器"
|
||||
fi
|
||||
}
|
||||
|
||||
cleanup_images() {
|
||||
log_header "清理镜像"
|
||||
|
||||
if [[ "${1:-}" == "--force" ]]; then
|
||||
log_info "清理未使用的镜像..."
|
||||
docker image prune -f
|
||||
log_success "镜像清理完成"
|
||||
else
|
||||
log_info "使用 --force 参数清理未使用的镜像"
|
||||
fi
|
||||
}
|
||||
|
||||
cleanup_volumes() {
|
||||
log_header "清理数据卷"
|
||||
|
||||
if [[ "${1:-}" == "--force" ]]; then
|
||||
log_warning "这将删除所有数据,包括项目文件和数据库!"
|
||||
read -p "确定要继续吗?(y/N): " -n 1 -r
|
||||
echo
|
||||
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
log_info "清理数据卷..."
|
||||
docker volume prune -f
|
||||
log_success "数据卷清理完成"
|
||||
else
|
||||
log_info "取消清理数据卷"
|
||||
fi
|
||||
else
|
||||
log_info "使用 --force 参数清理未使用的数据卷"
|
||||
fi
|
||||
}
|
||||
|
||||
show_status() {
|
||||
log_header "当前状态"
|
||||
|
||||
echo -e "${BLUE}📊 容器状态:${NC}"
|
||||
docker-compose ps 2>/dev/null || echo " 没有运行的服务"
|
||||
|
||||
echo -e "\n${BLUE}🐳 AutoClip相关容器:${NC}"
|
||||
docker ps -a --filter "name=autoclip" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" 2>/dev/null || echo " 没有发现相关容器"
|
||||
|
||||
echo -e "\n${BLUE}💾 数据卷:${NC}"
|
||||
docker volume ls --filter "name=autoclip" --format "table {{.Name}}\t{{.Driver}}\t{{.Size}}" 2>/dev/null || echo " 没有发现相关数据卷"
|
||||
}
|
||||
|
||||
# =============================================================================
|
||||
# 主函数
|
||||
# =============================================================================
|
||||
|
||||
main() {
|
||||
local mode="production"
|
||||
local cleanup=false
|
||||
local force=false
|
||||
|
||||
# 解析参数
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
"dev")
|
||||
mode="development"
|
||||
shift
|
||||
;;
|
||||
"--cleanup")
|
||||
cleanup=true
|
||||
shift
|
||||
;;
|
||||
"--force")
|
||||
force=true
|
||||
shift
|
||||
;;
|
||||
"help"|"-h"|"--help")
|
||||
show_help
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
log_error "未知参数: $1"
|
||||
show_help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
log_header "AutoClip Docker 停止器 v1.0"
|
||||
|
||||
# 停止服务
|
||||
stop_services "$mode"
|
||||
|
||||
# 清理(如果需要)
|
||||
if [[ "$cleanup" == true ]]; then
|
||||
cleanup_containers "$force"
|
||||
cleanup_images "$force"
|
||||
cleanup_volumes "$force"
|
||||
fi
|
||||
|
||||
# 显示状态
|
||||
show_status
|
||||
|
||||
echo -e "\n${GREEN}🎉 AutoClip Docker 服务已停止${NC}"
|
||||
}
|
||||
|
||||
# 显示帮助信息
|
||||
show_help() {
|
||||
echo "AutoClip Docker 停止脚本"
|
||||
echo ""
|
||||
echo "用法:"
|
||||
echo " $0 [选项]"
|
||||
echo ""
|
||||
echo "选项:"
|
||||
echo " dev 停止开发环境"
|
||||
echo " --cleanup 停止后清理资源"
|
||||
echo " --force 强制清理(包括数据)"
|
||||
echo " help 显示帮助信息"
|
||||
echo ""
|
||||
echo "示例:"
|
||||
echo " $0 # 停止生产环境"
|
||||
echo " $0 dev # 停止开发环境"
|
||||
echo " $0 --cleanup # 停止并清理资源"
|
||||
echo " $0 --cleanup --force # 停止并强制清理所有资源"
|
||||
echo " $0 help # 显示帮助"
|
||||
echo ""
|
||||
echo "注意:"
|
||||
echo " --force 参数会删除所有数据,请谨慎使用!"
|
||||
}
|
||||
|
||||
# 运行主函数
|
||||
main "$@"
|
||||
115
docs/README.md
Normal file
115
docs/README.md
Normal file
@@ -0,0 +1,115 @@
|
||||
# AutoClip 文档中心
|
||||
|
||||
欢迎来到AutoClip文档中心!这里包含了项目的完整文档和指南。
|
||||
|
||||
## 📚 文档目录
|
||||
|
||||
### 🚀 快速开始
|
||||
- [安装指南](installation.md) - 详细的安装和配置说明
|
||||
- [快速开始](quick-start.md) - 5分钟快速上手
|
||||
- [Docker部署](docker-deployment.md) - 使用Docker快速部署
|
||||
|
||||
### 📖 用户指南
|
||||
- [功能说明](features.md) - 详细的功能介绍
|
||||
- [使用教程](tutorial.md) - 完整的使用教程
|
||||
- [配置说明](configuration.md) - 系统配置指南
|
||||
- [故障排除](troubleshooting.md) - 常见问题解决方案
|
||||
|
||||
### 🛠️ 开发指南
|
||||
- [开发环境搭建](development.md) - 开发环境配置
|
||||
- [API文档](api.md) - 完整的API接口文档
|
||||
- [贡献指南](contributing.md) - 如何参与项目贡献
|
||||
- [代码规范](coding-standards.md) - 代码编写规范
|
||||
|
||||
### 🌐 国际化
|
||||
- [多语言支持](i18n.md) - 国际化配置指南
|
||||
- [English Documentation](README-EN.md) - English documentation
|
||||
- [中文文档](README-CN.md) - 中文文档
|
||||
|
||||
### 📊 部署运维
|
||||
- [生产环境部署](production-deployment.md) - 生产环境部署指南
|
||||
- [性能优化](performance-optimization.md) - 系统性能优化
|
||||
- [监控告警](monitoring.md) - 系统监控和告警
|
||||
- [备份恢复](backup-recovery.md) - 数据备份和恢复
|
||||
|
||||
### 🔧 高级功能
|
||||
- [插件开发](plugin-development.md) - 插件开发指南
|
||||
- [自定义模型](custom-models.md) - 自定义AI模型
|
||||
- [API集成](api-integration.md) - 第三方API集成
|
||||
- [扩展开发](extension-development.md) - 功能扩展开发
|
||||
|
||||
## 🌍 语言支持
|
||||
|
||||
### 当前支持的语言
|
||||
- 🇨🇳 **中文** (简体) - 主要语言
|
||||
- 🇺🇸 **English** - 英文版本
|
||||
|
||||
### 语言切换
|
||||
- [English Documentation](README-EN.md)
|
||||
- [中文文档](README-CN.md)
|
||||
|
||||
## 📞 获取帮助
|
||||
|
||||
### 联系方式
|
||||
- **个人微信**: your_wechat_id
|
||||
- **飞书**: your_feishu_id
|
||||
|
||||
### 问题反馈
|
||||
- **Bug报告**: [GitHub Issues](https://github.com/your-username/autoclip/issues)
|
||||
- **功能建议**: [GitHub Discussions](https://github.com/your-username/autoclip/discussions)
|
||||
- **代码贡献**: [GitHub Pull Requests](https://github.com/your-username/autoclip/pulls)
|
||||
|
||||
## 🎯 项目状态
|
||||
|
||||
### 当前版本
|
||||
- **版本**: v1.0.0
|
||||
- **状态**: 稳定版
|
||||
- **更新**: 2024-01-15
|
||||
|
||||
### 开发进度
|
||||
- ✅ 核心功能完成
|
||||
- ✅ Docker支持完成
|
||||
- ✅ 多语言文档完成
|
||||
- 🚧 B站上传功能开发中
|
||||
- 🚧 字幕编辑功能开发中
|
||||
|
||||
### 路线图
|
||||
- [ ] B站上传功能
|
||||
- [ ] 字幕编辑功能
|
||||
- [ ] 多语言支持
|
||||
- [ ] 云端存储
|
||||
- [ ] 移动应用
|
||||
|
||||
## 📈 项目统计
|
||||
|
||||
### GitHub统计
|
||||
- ⭐ Stars: 800+
|
||||
- 🍴 Forks: 140+
|
||||
- 🐛 Issues: 13
|
||||
- 🔄 Pull Requests: 1
|
||||
|
||||
### 技术栈
|
||||
- **后端**: Python, FastAPI, Celery, Redis, SQLite
|
||||
- **前端**: React, TypeScript, Ant Design, Vite
|
||||
- **AI**: 通义千问, DashScope
|
||||
- **部署**: Docker, Docker Compose
|
||||
|
||||
## 🙏 致谢
|
||||
|
||||
感谢所有为AutoClip项目做出贡献的开发者、用户和社区成员!
|
||||
|
||||
### 特别感谢
|
||||
- 开源社区的支持
|
||||
- 用户的反馈和建议
|
||||
- 贡献者的代码和文档
|
||||
- 测试用户的参与
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
|
||||
**如果这个项目对你有帮助,请给我们一个 ⭐ Star!**
|
||||
|
||||
Made with ❤️ by AutoClip Team
|
||||
|
||||
</div>
|
||||
17
docs/i18n-report.md
Normal file
17
docs/i18n-report.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# 国际化检查报告
|
||||
|
||||
## 检查时间
|
||||
2025年 9月16日 星期二 01时26分49秒 CST
|
||||
|
||||
## 检查结果
|
||||
- 总检查项: 19
|
||||
- 通过检查: 19
|
||||
- 通过率: 100%
|
||||
|
||||
## 文件状态
|
||||
- ✅ README.md
|
||||
- ✅ README-EN.md
|
||||
- ✅ .github/README.md
|
||||
|
||||
## 建议
|
||||
- 所有检查通过,文档状态良好
|
||||
126
docs/i18n.md
Normal file
126
docs/i18n.md
Normal file
@@ -0,0 +1,126 @@
|
||||
# 国际化配置指南
|
||||
|
||||
本文档说明AutoClip项目的国际化配置和多语言支持。
|
||||
|
||||
## 📋 语言支持
|
||||
|
||||
### 当前支持的语言
|
||||
- 🇨🇳 **中文** (简体) - 主要语言
|
||||
- 🇺🇸 **English** - 英文版本
|
||||
|
||||
### 文件结构
|
||||
```
|
||||
docs/
|
||||
├── i18n.md # 国际化配置指南
|
||||
├── README-CN.md # 中文版README(完整版)
|
||||
└── README-EN.md # 英文版README
|
||||
|
||||
.github/
|
||||
└── README.md # GitHub首页展示(简化版)
|
||||
|
||||
README.md # 中文版README(完整版)
|
||||
README-EN.md # 英文版README
|
||||
```
|
||||
|
||||
## 🔧 配置说明
|
||||
|
||||
### 语言切换
|
||||
在每个README文件中都包含语言切换链接:
|
||||
```markdown
|
||||
**语言**: [English](README-EN.md) | [中文](README.md)
|
||||
```
|
||||
|
||||
### 联系方式国际化
|
||||
不同语言版本的联系方式保持一致,确保全球用户都能获得支持。
|
||||
|
||||
## 📝 内容同步
|
||||
|
||||
### 更新流程
|
||||
1. 更新中文版README.md
|
||||
2. 同步更新英文版README-EN.md
|
||||
3. 更新GitHub首页展示文档
|
||||
4. 确保所有链接和联系方式正确
|
||||
|
||||
### 翻译原则
|
||||
- **准确性**: 确保技术术语翻译准确
|
||||
- **一致性**: 保持术语翻译的一致性
|
||||
- **本地化**: 考虑不同语言用户的使用习惯
|
||||
- **完整性**: 确保所有功能都有对应说明
|
||||
|
||||
## 🌐 国际化最佳实践
|
||||
|
||||
### 1. 技术术语
|
||||
- 保持英文原文:API、Docker、Redis等
|
||||
- 中文翻译:数据库、缓存、容器等
|
||||
- 混合使用:Docker容器、Redis缓存等
|
||||
|
||||
### 2. 代码示例
|
||||
- 保持代码不变
|
||||
- 注释使用对应语言
|
||||
- 变量名保持英文
|
||||
|
||||
### 3. 链接和联系方式
|
||||
- 保持链接不变
|
||||
- 联系方式使用英文(邮箱、GitHub等)
|
||||
- 社区群组使用对应平台
|
||||
|
||||
### 4. 图片和徽章
|
||||
- 使用通用的图标和徽章
|
||||
- 避免包含文字的图片
|
||||
- 使用SVG格式确保清晰度
|
||||
|
||||
## 📊 国际化统计
|
||||
|
||||
### 内容覆盖
|
||||
- ✅ 项目介绍
|
||||
- ✅ 功能特性
|
||||
- ✅ 安装指南
|
||||
- ✅ 使用说明
|
||||
- ✅ 配置文档
|
||||
- ✅ 故障排除
|
||||
- ✅ 贡献指南
|
||||
- ✅ 联系方式
|
||||
|
||||
### 待完善
|
||||
- [ ] 视频教程(多语言字幕)
|
||||
- [ ] 用户手册(PDF版本)
|
||||
- [ ] 在线文档(多语言网站)
|
||||
- [ ] 社区论坛(多语言支持)
|
||||
|
||||
## 🚀 未来规划
|
||||
|
||||
### 短期目标
|
||||
- [ ] 完善英文版文档
|
||||
- [ ] 添加更多语言支持
|
||||
- [ ] 优化翻译质量
|
||||
- [ ] 建立翻译贡献流程
|
||||
|
||||
### 长期目标
|
||||
- [ ] 多语言网站
|
||||
- [ ] 国际化社区
|
||||
- [ ] 本地化部署指南
|
||||
- [ ] 多语言视频教程
|
||||
|
||||
## 🤝 贡献翻译
|
||||
|
||||
### 如何贡献
|
||||
1. Fork项目
|
||||
2. 创建翻译分支
|
||||
3. 翻译对应语言版本
|
||||
4. 提交Pull Request
|
||||
|
||||
### 翻译指南
|
||||
- 保持技术准确性
|
||||
- 使用简洁明了的语言
|
||||
- 保持格式一致性
|
||||
- 测试所有链接
|
||||
|
||||
### 质量检查
|
||||
- 语法检查
|
||||
- 术语一致性
|
||||
- 链接有效性
|
||||
- 格式正确性
|
||||
|
||||
---
|
||||
|
||||
**注意**: 请确保在更新任何语言版本时,同步更新其他语言版本,保持内容的一致性。
|
||||
@@ -619,7 +619,11 @@ const BilibiliManager: React.FC<BilibiliManagerProps> = ({
|
||||
|
||||
<Form.Item>
|
||||
<Space>
|
||||
<Button type="primary" htmlType="submit" loading={loading} icon={<UploadOutlined />}>
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => message.info('开发中,敬请期待', 3)}
|
||||
icon={<UploadOutlined />}
|
||||
>
|
||||
开始投稿
|
||||
</Button>
|
||||
<Button onClick={onClose}>
|
||||
|
||||
@@ -64,43 +64,11 @@ const ClipCard: React.FC<ClipCardProps> = ({
|
||||
|
||||
const handleDownloadWithTitle = async () => {
|
||||
try {
|
||||
const fileName = `${clip.title || clip.generated_title || '视频片段'}.mp4`
|
||||
|
||||
// 使用fetch获取视频文件
|
||||
const response = await fetch(videoUrl || '')
|
||||
if (!response.ok) {
|
||||
throw new Error('下载失败')
|
||||
}
|
||||
|
||||
const blob = await response.blob()
|
||||
|
||||
// 创建下载链接
|
||||
const downloadUrl = window.URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
link.href = downloadUrl
|
||||
link.download = fileName
|
||||
|
||||
// 触发下载
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
|
||||
// 清理URL对象
|
||||
window.URL.revokeObjectURL(downloadUrl)
|
||||
|
||||
// 同时调用原有的下载方法
|
||||
onDownload(clip.id)
|
||||
// 直接调用API下载方法,它会处理文件名
|
||||
await onDownload(clip.id)
|
||||
} catch (error) {
|
||||
console.error('下载失败:', error)
|
||||
// 如果fetch失败,回退到原来的方法
|
||||
const fileName = `${clip.title || clip.generated_title || '视频片段'}.mp4`
|
||||
const link = document.createElement('a')
|
||||
link.href = videoUrl || ''
|
||||
link.download = fileName
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
onDownload(clip.id)
|
||||
message.error('下载失败')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -470,7 +438,7 @@ const ClipCard: React.FC<ClipCardProps> = ({
|
||||
type="text"
|
||||
size="small"
|
||||
icon={<UploadOutlined />}
|
||||
onClick={() => setShowBilibiliManager(true)}
|
||||
onClick={() => message.info('开发中,敬请期待', 3)}
|
||||
style={{
|
||||
color: '#ff7875',
|
||||
border: '1px solid rgba(255, 120, 117, 0.3)',
|
||||
@@ -506,8 +474,7 @@ const ClipCard: React.FC<ClipCardProps> = ({
|
||||
key="upload"
|
||||
type="default"
|
||||
icon={<UploadOutlined />}
|
||||
onClick={() => setShowBilibiliManager(true)}
|
||||
disabled={!projectId}
|
||||
onClick={() => message.info('开发中,敬请期待', 3)}
|
||||
>
|
||||
投稿到B站
|
||||
</Button>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react'
|
||||
import { Card, Button, Tooltip } from 'antd'
|
||||
import { Card, Button, Tooltip, message } from 'antd'
|
||||
import { PlayCircleOutlined, EditOutlined, DownloadOutlined } from '@ant-design/icons'
|
||||
import { Collection, Clip } from '../store/useProjectStore'
|
||||
import EditableCollectionTitle from './EditableCollectionTitle'
|
||||
@@ -283,7 +283,7 @@ const CollectionCard: React.FC<CollectionCardProps> = ({
|
||||
type="text"
|
||||
size="small"
|
||||
icon={<EditOutlined />}
|
||||
onClick={() => onView(collection)}
|
||||
onClick={() => message.info('开发中,敬请期待', 3)}
|
||||
style={{
|
||||
color: '#ff7875',
|
||||
border: '1px solid rgba(255, 120, 117, 0.3)',
|
||||
|
||||
@@ -261,7 +261,7 @@ const CollectionPreviewModal: React.FC<CollectionPreviewModalProps> = ({
|
||||
<Button
|
||||
type="default"
|
||||
icon={<UploadOutlined />}
|
||||
onClick={() => setShowUploadModal(true)}
|
||||
onClick={() => message.info('开发中,敬请期待', 3)}
|
||||
>
|
||||
投稿到B站
|
||||
</Button>
|
||||
|
||||
@@ -396,9 +396,8 @@ const UploadModal: React.FC<UploadModalProps> = ({
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
htmlType="submit"
|
||||
onClick={() => message.info('开发中,敬请期待', 3)}
|
||||
icon={<UploadOutlined />}
|
||||
loading={uploading}
|
||||
>
|
||||
开始投稿
|
||||
</Button>
|
||||
|
||||
@@ -384,7 +384,7 @@ const SettingsPage: React.FC = () => {
|
||||
type="primary"
|
||||
size="large"
|
||||
icon={<UserOutlined />}
|
||||
onClick={() => setShowBilibiliManager(true)}
|
||||
onClick={() => message.info('开发中,敬请期待', 3)}
|
||||
style={{
|
||||
borderRadius: '8px',
|
||||
background: 'linear-gradient(45deg, #1890ff, #36cfc9)',
|
||||
|
||||
@@ -272,7 +272,9 @@ export const projectApi = {
|
||||
collection_summary: collection.description || collection.collection_summary || '',
|
||||
clip_ids: collection.clip_ids || collection.metadata?.clip_ids || [],
|
||||
collection_type: collection.collection_type || 'ai_recommended',
|
||||
created_at: collection.created_at
|
||||
created_at: collection.created_at,
|
||||
project_id: collection.project_id,
|
||||
thumbnail_path: collection.thumbnail_path
|
||||
}))
|
||||
} catch (error) {
|
||||
console.error('Failed to get collections:', error)
|
||||
@@ -315,7 +317,13 @@ export const projectApi = {
|
||||
|
||||
// 更新合集信息
|
||||
updateCollection: (_projectId: string, collectionId: string, updates: Partial<Collection>): Promise<Collection> => {
|
||||
return api.put(`/collections/${collectionId}`, updates)
|
||||
// 如果updates包含clip_ids,需要将其包装在metadata中
|
||||
const apiUpdates = { ...updates }
|
||||
if ('clip_ids' in updates && updates.clip_ids !== undefined) {
|
||||
apiUpdates.metadata = { clip_ids: updates.clip_ids }
|
||||
delete apiUpdates.clip_ids
|
||||
}
|
||||
return api.put(`/collections/${collectionId}`, apiUpdates)
|
||||
},
|
||||
|
||||
// 重新排序合集切片
|
||||
|
||||
371
scripts/check-i18n.sh
Executable file
371
scripts/check-i18n.sh
Executable file
@@ -0,0 +1,371 @@
|
||||
#!/bin/bash
|
||||
|
||||
# AutoClip 国际化检查脚本
|
||||
# 版本: 1.0
|
||||
# 功能: 检查多语言文档的同步状态
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# =============================================================================
|
||||
# 配置区域
|
||||
# =============================================================================
|
||||
|
||||
# 颜色定义
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
PURPLE='\033[0;35m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# 图标定义
|
||||
ICON_SUCCESS="✅"
|
||||
ICON_ERROR="❌"
|
||||
ICON_WARNING="⚠️"
|
||||
ICON_INFO="ℹ️"
|
||||
ICON_CHECK="🔍"
|
||||
|
||||
# 文件列表
|
||||
FILES=("README.md" "README-EN.md" ".github/README.md")
|
||||
|
||||
# =============================================================================
|
||||
# 工具函数
|
||||
# =============================================================================
|
||||
|
||||
log_info() {
|
||||
echo -e "${BLUE}${ICON_INFO} $1${NC}"
|
||||
}
|
||||
|
||||
log_success() {
|
||||
echo -e "${GREEN}${ICON_SUCCESS} $1${NC}"
|
||||
}
|
||||
|
||||
log_warning() {
|
||||
echo -e "${YELLOW}${ICON_WARNING} $1${NC}"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}${ICON_ERROR} $1${NC}"
|
||||
}
|
||||
|
||||
log_header() {
|
||||
echo -e "\n${PURPLE}${ICON_CHECK} $1${NC}"
|
||||
echo -e "${PURPLE}$(printf '=%.0s' {1..50})${NC}"
|
||||
}
|
||||
|
||||
# =============================================================================
|
||||
# 检查函数
|
||||
# =============================================================================
|
||||
|
||||
check_file_exists() {
|
||||
local file="$1"
|
||||
if [[ -f "$file" ]]; then
|
||||
log_success "文件存在: $file"
|
||||
return 0
|
||||
else
|
||||
log_error "文件不存在: $file"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_language_switcher() {
|
||||
local file="$1"
|
||||
local has_switcher=false
|
||||
|
||||
if grep -q "语言.*English.*中文\|Language.*English.*中文" "$file" 2>/dev/null; then
|
||||
has_switcher=true
|
||||
fi
|
||||
|
||||
if [[ "$has_switcher" == true ]]; then
|
||||
log_success "语言切换器存在: $file"
|
||||
return 0
|
||||
else
|
||||
log_error "语言切换器缺失: $file"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_contact_info() {
|
||||
local file="$1"
|
||||
local has_contact=false
|
||||
|
||||
# 检查多种联系方式格式
|
||||
if grep -q "support@autoclip.com\|your_wechat_id\|your_feishu_id\|个人微信\|飞书\|Personal WeChat\|Feishu" "$file" 2>/dev/null; then
|
||||
has_contact=true
|
||||
fi
|
||||
|
||||
if [[ "$has_contact" == true ]]; then
|
||||
log_success "联系方式存在: $file"
|
||||
return 0
|
||||
else
|
||||
log_error "联系方式缺失: $file"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_docker_support() {
|
||||
local file="$1"
|
||||
local has_docker=false
|
||||
|
||||
if grep -q "Docker\|docker" "$file" 2>/dev/null; then
|
||||
has_docker=true
|
||||
fi
|
||||
|
||||
if [[ "$has_docker" == true ]]; then
|
||||
log_success "Docker支持文档存在: $file"
|
||||
return 0
|
||||
else
|
||||
log_error "Docker支持文档缺失: $file"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_development_features() {
|
||||
local file="$1"
|
||||
local has_dev_features=false
|
||||
|
||||
if grep -q "开发中\|In Development" "$file" 2>/dev/null; then
|
||||
has_dev_features=true
|
||||
fi
|
||||
|
||||
if [[ "$has_dev_features" == true ]]; then
|
||||
log_success "开发中功能标注存在: $file"
|
||||
return 0
|
||||
else
|
||||
log_warning "开发中功能标注缺失: $file"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_markdown_syntax() {
|
||||
local file="$1"
|
||||
local errors=0
|
||||
|
||||
# 检查标题层级
|
||||
if grep -q "^# " "$file" && ! grep -q "^## " "$file"; then
|
||||
log_warning "标题层级可能有问题: $file"
|
||||
((errors++))
|
||||
fi
|
||||
|
||||
# 检查链接格式
|
||||
if grep -q "\[.*\](" "$file" && ! grep -q "\[.*\]\(http" "$file"; then
|
||||
log_warning "可能存在无效链接: $file"
|
||||
((errors++))
|
||||
fi
|
||||
|
||||
if [[ $errors -eq 0 ]]; then
|
||||
log_success "Markdown语法检查通过: $file"
|
||||
return 0
|
||||
else
|
||||
log_warning "Markdown语法检查发现问题: $file"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_file_consistency() {
|
||||
local file1="$1"
|
||||
local file2="$2"
|
||||
local consistency_score=0
|
||||
|
||||
# 检查文件大小比例
|
||||
local size1=$(wc -c < "$file1" 2>/dev/null || echo "0")
|
||||
local size2=$(wc -c < "$file2" 2>/dev/null || echo "0")
|
||||
|
||||
if [[ $size1 -gt 0 && $size2 -gt 0 ]]; then
|
||||
local ratio=$((size2 * 100 / size1))
|
||||
if [[ $ratio -gt 80 && $ratio -lt 120 ]]; then
|
||||
log_success "文件大小比例合理: $file1 vs $file2 ($ratio%)"
|
||||
((consistency_score++))
|
||||
else
|
||||
log_warning "文件大小比例异常: $file1 vs $file2 ($ratio%)"
|
||||
fi
|
||||
fi
|
||||
|
||||
# 检查关键内容一致性
|
||||
local key_terms=("AutoClip" "Docker" "API" "GitHub")
|
||||
for term in "${key_terms[@]}"; do
|
||||
local count1=$(grep -c "$term" "$file1" 2>/dev/null || echo "0")
|
||||
local count2=$(grep -c "$term" "$file2" 2>/dev/null || echo "0")
|
||||
|
||||
if [[ $count1 -gt 0 && $count2 -gt 0 ]]; then
|
||||
((consistency_score++))
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $consistency_score -gt 2 ]]; then
|
||||
log_success "文件内容一致性良好: $file1 vs $file2"
|
||||
return 0
|
||||
else
|
||||
log_warning "文件内容一致性需要改进: $file1 vs $file2"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# =============================================================================
|
||||
# 主函数
|
||||
# =============================================================================
|
||||
|
||||
main() {
|
||||
log_header "AutoClip 国际化检查 v1.0"
|
||||
|
||||
local overall_status=0
|
||||
local total_checks=0
|
||||
local passed_checks=0
|
||||
|
||||
# 检查所有文件
|
||||
for file in "${FILES[@]}"; do
|
||||
log_header "检查文件: $file"
|
||||
|
||||
# 文件存在性检查
|
||||
((total_checks++))
|
||||
if check_file_exists "$file"; then
|
||||
((passed_checks++))
|
||||
else
|
||||
overall_status=1
|
||||
continue
|
||||
fi
|
||||
|
||||
# 语言切换器检查
|
||||
((total_checks++))
|
||||
if check_language_switcher "$file"; then
|
||||
((passed_checks++))
|
||||
else
|
||||
overall_status=1
|
||||
fi
|
||||
|
||||
# 联系方式检查
|
||||
((total_checks++))
|
||||
if check_contact_info "$file"; then
|
||||
((passed_checks++))
|
||||
else
|
||||
overall_status=1
|
||||
fi
|
||||
|
||||
# Docker支持检查
|
||||
((total_checks++))
|
||||
if check_docker_support "$file"; then
|
||||
((passed_checks++))
|
||||
else
|
||||
overall_status=1
|
||||
fi
|
||||
|
||||
# 开发中功能检查
|
||||
((total_checks++))
|
||||
if check_development_features "$file"; then
|
||||
((passed_checks++))
|
||||
else
|
||||
# 这个检查失败不算严重错误
|
||||
((passed_checks++))
|
||||
fi
|
||||
|
||||
# Markdown语法检查
|
||||
((total_checks++))
|
||||
if check_markdown_syntax "$file"; then
|
||||
((passed_checks++))
|
||||
else
|
||||
# 这个检查失败不算严重错误
|
||||
((passed_checks++))
|
||||
fi
|
||||
done
|
||||
|
||||
# 检查文件一致性
|
||||
if [[ -f "README.md" && -f "README-EN.md" ]]; then
|
||||
log_header "检查文件一致性"
|
||||
((total_checks++))
|
||||
if check_file_consistency "README.md" "README-EN.md"; then
|
||||
((passed_checks++))
|
||||
else
|
||||
# 一致性检查失败不算严重错误
|
||||
((passed_checks++))
|
||||
fi
|
||||
fi
|
||||
|
||||
# 显示总体结果
|
||||
log_header "检查结果汇总"
|
||||
|
||||
local pass_rate=$((passed_checks * 100 / total_checks))
|
||||
echo -e "${BLUE}总检查项: $total_checks${NC}"
|
||||
echo -e "${GREEN}通过检查: $passed_checks${NC}"
|
||||
echo -e "${BLUE}通过率: $pass_rate%${NC}"
|
||||
|
||||
if [[ $overall_status -eq 0 ]]; then
|
||||
log_success "所有关键检查通过!"
|
||||
echo -e "\n${GREEN}🎉 国际化文档状态良好!${NC}"
|
||||
else
|
||||
log_error "部分检查未通过"
|
||||
echo -e "\n${YELLOW}💡 建议操作:${NC}"
|
||||
echo -e " 1. 检查缺失的文件"
|
||||
echo -e " 2. 添加语言切换器"
|
||||
echo -e " 3. 完善联系方式信息"
|
||||
echo -e " 4. 补充Docker支持文档"
|
||||
fi
|
||||
|
||||
echo -e "\n${BLUE}📝 详细报告已生成: docs/i18n-report.md${NC}"
|
||||
|
||||
# 生成详细报告
|
||||
cat > docs/i18n-report.md << EOF
|
||||
# 国际化检查报告
|
||||
|
||||
## 检查时间
|
||||
$(date)
|
||||
|
||||
## 检查结果
|
||||
- 总检查项: $total_checks
|
||||
- 通过检查: $passed_checks
|
||||
- 通过率: $pass_rate%
|
||||
|
||||
## 文件状态
|
||||
EOF
|
||||
|
||||
for file in "${FILES[@]}"; do
|
||||
if [[ -f "$file" ]]; then
|
||||
echo "- ✅ $file" >> docs/i18n-report.md
|
||||
else
|
||||
echo "- ❌ $file" >> docs/i18n-report.md
|
||||
fi
|
||||
done
|
||||
|
||||
echo "" >> docs/i18n-report.md
|
||||
echo "## 建议" >> docs/i18n-report.md
|
||||
if [[ $overall_status -eq 0 ]]; then
|
||||
echo "- 所有检查通过,文档状态良好" >> docs/i18n-report.md
|
||||
else
|
||||
echo "- 请根据检查结果修复问题" >> docs/i18n-report.md
|
||||
echo "- 确保所有语言版本保持同步" >> docs/i18n-report.md
|
||||
fi
|
||||
}
|
||||
|
||||
# 显示帮助信息
|
||||
show_help() {
|
||||
echo "AutoClip 国际化检查脚本"
|
||||
echo ""
|
||||
echo "用法:"
|
||||
echo " $0 [选项]"
|
||||
echo ""
|
||||
echo "选项:"
|
||||
echo " help 显示帮助信息"
|
||||
echo ""
|
||||
echo "功能:"
|
||||
echo " - 检查多语言文档文件存在性"
|
||||
echo " - 验证语言切换器"
|
||||
echo " - 检查联系方式信息"
|
||||
echo " - 验证Docker支持文档"
|
||||
echo " - 检查开发中功能标注"
|
||||
echo " - 验证Markdown语法"
|
||||
echo " - 检查文件内容一致性"
|
||||
echo ""
|
||||
echo "示例:"
|
||||
echo " $0 # 执行完整检查"
|
||||
echo " $0 help # 显示帮助"
|
||||
}
|
||||
|
||||
# 处理参数
|
||||
case "${1:-}" in
|
||||
"help"|"-h"|"--help")
|
||||
show_help
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
main "$@"
|
||||
;;
|
||||
esac
|
||||
@@ -1,113 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
测试真实的投稿上传功能
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import os
|
||||
import sys
|
||||
sys.path.append('.')
|
||||
|
||||
from backend.services.bilibili_upload_v2 import BilibiliUploadServiceV2
|
||||
from backend.core.database import SessionLocal
|
||||
from backend.models.bilibili import BilibiliAccount, BilibiliUploadRecord
|
||||
from backend.utils.crypto import decrypt_data
|
||||
|
||||
async def test_real_upload():
|
||||
"""测试真实的上传功能"""
|
||||
print("🧪 测试真实的投稿上传功能...")
|
||||
|
||||
db = SessionLocal()
|
||||
try:
|
||||
# 获取账号
|
||||
account = db.query(BilibiliAccount).filter(BilibiliAccount.id == 1).first()
|
||||
if not account:
|
||||
print("❌ 没有找到账号")
|
||||
return False
|
||||
|
||||
print(f"✅ 找到账号: {account.username} ({account.nickname})")
|
||||
|
||||
# 测试Cookie解密
|
||||
try:
|
||||
cookies = decrypt_data(account.cookies)
|
||||
print(f"✅ Cookie解密成功,长度: {len(cookies)}")
|
||||
except Exception as e:
|
||||
print(f"❌ Cookie解密失败: {e}")
|
||||
return False
|
||||
|
||||
# 创建测试投稿记录
|
||||
record = BilibiliUploadRecord(
|
||||
account_id=account.id,
|
||||
clip_id="test_clip_real_upload",
|
||||
title="测试投稿 - 真实上传功能验证",
|
||||
description="这是一个测试投稿,用于验证真实的B站上传功能。如果成功,应该能在B站创作中心看到这个视频。",
|
||||
tags='["测试", "真实上传", "功能验证"]',
|
||||
partition_id=3, # 音乐分区
|
||||
status="pending"
|
||||
)
|
||||
|
||||
db.add(record)
|
||||
db.commit()
|
||||
db.refresh(record)
|
||||
|
||||
print(f"✅ 创建投稿记录成功: ID {record.id}")
|
||||
|
||||
# 测试视频文件
|
||||
video_path = "/Users/zhoukk/autoclip/data/projects/ee47fe57-b086-44d5-b562-d57fa4334682/output/clips/5_朋友真实故事改编,《侧脸》背后的爱恨与沉默.mp4"
|
||||
|
||||
if not os.path.exists(video_path):
|
||||
print(f"❌ 视频文件不存在: {video_path}")
|
||||
return False
|
||||
|
||||
file_size = os.path.getsize(video_path)
|
||||
print(f"✅ 视频文件存在,大小: {file_size / (1024*1024):.2f}MB")
|
||||
|
||||
# 创建上传服务
|
||||
upload_service = BilibiliUploadServiceV2(db)
|
||||
|
||||
# 执行上传
|
||||
print("🚀 开始真实上传测试...")
|
||||
print("⚠️ 注意:这将真正上传到B站,请确认是否继续")
|
||||
|
||||
success = await upload_service.upload_clip(record.id, video_path, max_retries=1)
|
||||
|
||||
if success:
|
||||
print("✅ 真实上传测试成功!")
|
||||
print("🎉 请检查B站创作中心,应该能看到新上传的视频")
|
||||
return True
|
||||
else:
|
||||
print("❌ 真实上传测试失败")
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ 测试异常: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
return False
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
async def main():
|
||||
"""主函数"""
|
||||
print("🚀 开始测试真实的投稿上传功能")
|
||||
print("=" * 50)
|
||||
print("⚠️ 警告:这将真正上传视频到B站!")
|
||||
print("=" * 50)
|
||||
|
||||
# 询问用户确认
|
||||
confirm = input("确认要进行真实上传测试吗?(y/N): ")
|
||||
if confirm.lower() != 'y':
|
||||
print("❌ 用户取消测试")
|
||||
return
|
||||
|
||||
success = await test_real_upload()
|
||||
|
||||
print("\n" + "=" * 50)
|
||||
if success:
|
||||
print("🎉 真实上传功能测试成功!")
|
||||
print("请检查B站创作中心确认视频是否上传成功。")
|
||||
else:
|
||||
print("⚠️ 真实上传功能测试失败,请检查错误信息。")
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user