Add lazy comment fetching to watch page

- VideoComment model (video_id, author, text, likes, is_pinned, published_at)
- fetch_video_comments() in ytdlp.py: top 20 comments, no reply threads,
  sorted pinned-first then by likes
- GET /videos/by-yt/{id}/comments — returns cached comments instantly
- POST /videos/by-yt/{id}/comments/refresh — fetches from YouTube, stores, returns
- Watch page: CommentsSection shows "Load comments" button when uncached,
  renders comments with author/likes once loaded; Refresh link to re-fetch

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Mattias Tall
2026-05-26 11:15:41 +02:00
parent d6dd07e0bd
commit cdf6520fd8
5 changed files with 201 additions and 0 deletions

View File

@@ -68,6 +68,8 @@ export const longVideos = () => api.get("/videos/long");
export const surpriseMe = () => api.get("/videos/surprise");
export const getVideo = (id) => api.get(`/videos/${id}`);
export const getVideoByYtId = (ytId) => api.get(`/videos/by-yt/${ytId}`);
export const getVideoComments = (ytId) => api.get(`/videos/by-yt/${ytId}/comments`);
export const refreshVideoComments = (ytId) => api.post(`/videos/by-yt/${ytId}/comments/refresh`);
export const updateProgress = (id, data) => api.patch(`/videos/${id}/progress`, data);
export const toggleQueue = (id) => api.post(`/videos/${id}/queue`);
export const getQueue = () => api.get("/videos/queue");