add volcengine OSS support

This commit is contained in:
2026-08-30 06:52:14 +08:00
parent 6de1d4a3d0
commit 856aa38026
9 changed files with 339 additions and 10 deletions

View File

@@ -43,6 +43,7 @@ class VideoRepository:
error_message TEXT,
algorithm_version TEXT,
transcription TEXT,
remote_url TEXT,
created_at TEXT NOT NULL,
updated_at TEXT NOT NULL
);
@@ -113,6 +114,14 @@ class VideoRepository:
"ALTER TABLE dub_share_segments ADD COLUMN score_details TEXT NOT NULL DEFAULT '{}'"
)
with self._connect() as connection:
video_columns = {
row["name"]
for row in connection.execute("PRAGMA table_info(videos)")
}
if "remote_url" not in video_columns:
connection.execute("ALTER TABLE videos ADD COLUMN remote_url TEXT")
def upsert_upload(
self,
*,
@@ -137,8 +146,8 @@ class VideoRepository:
INSERT INTO videos (
video_hash, title, filename, stored_filename, content_type,
size_bytes, duration_ms, language, status, error_message,
algorithm_version, transcription, created_at, updated_at
) VALUES (?, ?, ?, ?, ?, ?, NULL, ?, 'uploaded', NULL, NULL, NULL, ?, ?)
algorithm_version, transcription, remote_url, created_at, updated_at
) VALUES (?, ?, ?, ?, ?, ?, NULL, ?, 'uploaded', NULL, NULL, NULL, NULL, ?, ?)
ON CONFLICT(video_hash) DO UPDATE SET
title = excluded.title,
filename = excluded.filename,
@@ -180,6 +189,7 @@ class VideoRepository:
self,
document: SentenceBoundaryDocument,
transcription: Optional[str],
ready: bool = True,
) -> None:
with self._connect() as connection:
connection.execute(
@@ -208,12 +218,13 @@ class VideoRepository:
)
connection.execute(
"""
UPDATE videos SET duration_ms = ?, status = 'ready', error_message = NULL,
UPDATE videos SET duration_ms = ?, status = ?, error_message = NULL,
algorithm_version = ?, transcription = ?, updated_at = ?
WHERE video_hash = ?
""",
(
document.duration_ms,
"ready" if ready else "processing",
document.algorithm_version,
transcription,
utc_now(),
@@ -221,6 +232,17 @@ class VideoRepository:
),
)
def mark_oss_uploaded(self, video_hash: str, remote_url: str) -> None:
with self._connect() as connection:
connection.execute(
"""
UPDATE videos
SET remote_url = ?, status = 'ready', error_message = NULL, updated_at = ?
WHERE video_hash = ?
""",
(remote_url, utc_now(), normalize_video_hash(video_hash)),
)
def list_videos(self) -> List[Dict[str, Any]]:
with self._connect() as connection:
rows = connection.execute(