This commit is contained in:
2026-10-25 10:30:22 +08:00
parent 38894ba80c
commit ae84347912
11 changed files with 287 additions and 12 deletions

View File

@@ -1011,11 +1011,28 @@ class VideoRepository:
)
return cursor.rowcount > 0
def clear_sentence_translations(self, video_hash: str) -> None:
def clear_sentence_translations(
self,
video_hash: str,
indexes: Optional[Sequence[int]] = None,
) -> None:
normalized_hash = normalize_video_hash(video_hash)
with self._connect() as connection:
connection.execute(
"UPDATE sentences SET zh_text = NULL WHERE video_hash = ?",
(normalize_video_hash(video_hash),),
if indexes is None:
connection.execute(
"UPDATE sentences SET zh_text = NULL WHERE video_hash = ?",
(normalized_hash,),
)
return
unique_indexes = list(dict.fromkeys(indexes))
if not unique_indexes:
return
connection.executemany(
"""
UPDATE sentences SET zh_text = NULL
WHERE video_hash = ? AND sentence_index = ?
""",
[(normalized_hash, index) for index in unique_indexes],
)
def save_sentence_translations(