3e94013d2b
- Tauri FFmpeg sidecar 支持从 MP4 提取音频(MP4→MP3) - VoiceMaterialLibrary 支持 .mp4 上传自动提取音频后走声音复刻 - 前端路径安全:writeFile/remove 改用 BaseDirectory.AppLocalData + 相对路径 - 新增 prompt:新房装修流程、装备材料选择 - 新增素材6.2:48个分类 + 67个视频素材入库脚本 - MP4 时长限制修正:10秒~2分钟(原5分钟)
51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
import os
|
|
import sys
|
|
from pathlib import Path
|
|
from dotenv import load_dotenv
|
|
from qiniu import Auth, put_file
|
|
|
|
# 加载环境变量
|
|
env_path = Path(__file__).resolve().parent.parent / 'python-api' / '.env'
|
|
load_dotenv(env_path)
|
|
|
|
access_key = os.getenv('QINIU_ACCESS_KEY')
|
|
secret_key = os.getenv('QINIU_SECRET_KEY')
|
|
bucket = os.getenv('QINIU_VIDEO_BUCKET', 'media-liche')
|
|
domain = os.getenv('QINIU_VIDEO_DOMAIN', 'media.liche.cn')
|
|
|
|
if not access_key or not secret_key:
|
|
print("错误: 未找到七牛云凭证,请检查 .env 文件")
|
|
sys.exit(1)
|
|
|
|
q = Auth(access_key, secret_key)
|
|
src_dir = Path('/Users/0fun/Downloads/新增素材6.2')
|
|
|
|
total = 0
|
|
success = 0
|
|
failed = 0
|
|
|
|
files = sorted([p for p in src_dir.rglob('*.mp4') if not p.name.startswith('._') and '.DS_Store' not in str(p)])
|
|
|
|
print(f"发现 {len(files)} 个 MP4 文件,开始上传...\n")
|
|
|
|
for mp4_path in files:
|
|
total += 1
|
|
key = f"meijiaka-zy/materials/{mp4_path.name}"
|
|
|
|
try:
|
|
token = q.upload_token(bucket, key, 3600)
|
|
ret, info = put_file(token, key, str(mp4_path))
|
|
if ret is not None:
|
|
url = f"https://{domain}/{key}"
|
|
print(f"✅ [{total}/{len(files)}] {mp4_path.name}")
|
|
success += 1
|
|
else:
|
|
print(f"❌ [{total}/{len(files)}] {mp4_path.name} → 失败: {info}")
|
|
failed += 1
|
|
except Exception as e:
|
|
print(f"❌ [{total}/{len(files)}] {mp4_path.name} → 异常: {e}")
|
|
failed += 1
|
|
|
|
print(f"\n{'=' * 50}")
|
|
print(f"总计: {total}, 成功: {success}, 失败: {failed}")
|