title modification

This commit is contained in:
2026-09-26 08:03:20 +08:00
parent 37ee850ee1
commit 7fae2bb8c9
6 changed files with 106 additions and 1 deletions

View File

@@ -349,6 +349,22 @@ class VideoRepository:
(remote_url, utc_now(), normalize_video_hash(video_hash)),
)
def update_title(self, video_hash: str, title: str) -> Optional[Dict[str, Any]]:
normalized_hash = normalize_video_hash(video_hash)
cleaned_title = title.strip()[:200]
if not cleaned_title:
raise ValueError("Title cannot be empty.")
with self._connect() as connection:
cursor = connection.execute(
"UPDATE videos SET title = ?, updated_at = ? WHERE video_hash = ?",
(cleaned_title, utc_now(), normalized_hash),
)
if cursor.rowcount == 0:
return None
return self.get_video(normalized_hash)
def list_videos(self) -> List[Dict[str, Any]]:
with self._connect() as connection:
rows = connection.execute(