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:
@@ -165,6 +165,20 @@ class UserTagAffinity(Base):
|
||||
updated_at = Column(DateTime, default=datetime.utcnow)
|
||||
|
||||
|
||||
class VideoComment(Base):
|
||||
__tablename__ = "video_comments"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
video_id = Column(Integer, ForeignKey("videos.id", ondelete="CASCADE"), nullable=False, index=True)
|
||||
youtube_comment_id = Column(String)
|
||||
author = Column(String)
|
||||
text = Column(Text)
|
||||
likes = Column(Integer, default=0)
|
||||
is_pinned = Column(Boolean, default=False)
|
||||
published_at = Column(DateTime)
|
||||
fetched_at = Column(DateTime, default=datetime.utcnow)
|
||||
|
||||
|
||||
class Collection(Base):
|
||||
__tablename__ = "collections"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user