Fix comments (Python API), add dislike bar

Comments: switch from CLI --write-comments to yt-dlp Python API with
getcomments=True — more reliable, proper extractor_args dict format

Dislikes: add dislike_count column, fetch from returnyoutubedislike.com
after each video metadata upsert (5s timeout, non-fatal)

UI: replace emoji like count with a like/dislike ratio bar — blue fill
showing like proportion, labels on each end; views stay in meta row

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Mattias Tall
2026-05-26 11:33:00 +02:00
parent c9e64d2814
commit 74e2b4cd73
5 changed files with 83 additions and 22 deletions

View File

@@ -67,6 +67,7 @@ class VideoDetail(BaseModel):
is_recommended: bool = False
view_count: Optional[int] = None
like_count: Optional[int] = None
dislike_count: Optional[int] = None
model_config = {"from_attributes": True}
@@ -423,7 +424,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.view_count, v.like_count,
v.duration_seconds, v.published_at, v.tags, v.category, v.view_count, v.like_count, v.dislike_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,
@@ -488,6 +489,12 @@ def _upsert_video_from_yt(db: Session, youtube_video_id: str) -> bool:
if channel:
video.channel_id = channel.id
# Fetch crowdsourced dislike count if not already known
if not video.dislike_count:
dislikes = ytdlp.fetch_dislike_count(youtube_video_id)
if dislikes is not None:
video.dislike_count = dislikes
db.commit()
return True