Add view count to videos

- Video model: view_count column (Integer, nullable)
- ytdlp._normalize_video: extract view_count from yt-dlp info
- _VIDEO_SELECT: include v.view_count in all queries
- VideoDetail schema: view_count field
- Watch page: formatViews() helper, show "X.XM views" in meta row
  alongside date and category

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Mattias Tall
2026-05-26 11:18:53 +02:00
parent cdf6520fd8
commit 8221177615
4 changed files with 13 additions and 1 deletions

View File

@@ -65,6 +65,7 @@ class VideoDetail(BaseModel):
download_resolution: Optional[str] = None
local_file_url: Optional[str] = None
is_recommended: bool = False
view_count: Optional[int] = None
model_config = {"from_attributes": True}
@@ -421,7 +422,7 @@ def surprise_me(
_VIDEO_SELECT = """
SELECT v.id, v.youtube_video_id, v.title, v.description, v.thumbnail_url,
v.duration_seconds, v.published_at, v.tags, v.category,
v.duration_seconds, v.published_at, v.tags, v.category, v.view_count,
c.id AS channel_id, c.name AS channel_name, c.youtube_channel_id AS channel_youtube_id,
COALESCE(uv.watched, 0) AS watched,
COALESCE(uv.watch_progress_seconds, 0) AS watch_progress_seconds,