Compare commits
2 Commits
ffd46b5e08
...
c9e64d2814
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c9e64d2814 | ||
|
|
3f225e7647 |
@@ -84,6 +84,7 @@ def init_db():
|
|||||||
try:
|
try:
|
||||||
# Column migrations — safe to run on every startup
|
# Column migrations — safe to run on every startup
|
||||||
_add_column_if_missing(raw_conn, "videos", "view_count", "INTEGER")
|
_add_column_if_missing(raw_conn, "videos", "view_count", "INTEGER")
|
||||||
|
_add_column_if_missing(raw_conn, "videos", "like_count", "INTEGER")
|
||||||
raw_conn.commit()
|
raw_conn.commit()
|
||||||
# executescript handles multi-statement SQL including trigger BEGIN...END blocks
|
# executescript handles multi-statement SQL including trigger BEGIN...END blocks
|
||||||
raw_conn.executescript(FTS_SETUP_SQL)
|
raw_conn.executescript(FTS_SETUP_SQL)
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ class Video(Base):
|
|||||||
category = Column(String)
|
category = Column(String)
|
||||||
chapters = Column(Text) # JSON array of {start_time, end_time, title}
|
chapters = Column(Text) # JSON array of {start_time, end_time, title}
|
||||||
view_count = Column(Integer)
|
view_count = Column(Integer)
|
||||||
|
like_count = Column(Integer)
|
||||||
|
|
||||||
|
|
||||||
class UserVideo(Base):
|
class UserVideo(Base):
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ class VideoDetail(BaseModel):
|
|||||||
local_file_url: Optional[str] = None
|
local_file_url: Optional[str] = None
|
||||||
is_recommended: bool = False
|
is_recommended: bool = False
|
||||||
view_count: Optional[int] = None
|
view_count: Optional[int] = None
|
||||||
|
like_count: Optional[int] = None
|
||||||
|
|
||||||
model_config = {"from_attributes": True}
|
model_config = {"from_attributes": True}
|
||||||
|
|
||||||
@@ -422,7 +423,7 @@ def surprise_me(
|
|||||||
|
|
||||||
_VIDEO_SELECT = """
|
_VIDEO_SELECT = """
|
||||||
SELECT v.id, v.youtube_video_id, v.title, v.description, v.thumbnail_url,
|
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.duration_seconds, v.published_at, v.tags, v.category, v.view_count, v.like_count,
|
||||||
c.id AS channel_id, c.name AS channel_name, c.youtube_channel_id AS channel_youtube_id,
|
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.watched, 0) AS watched,
|
||||||
COALESCE(uv.watch_progress_seconds, 0) AS watch_progress_seconds,
|
COALESCE(uv.watch_progress_seconds, 0) AS watch_progress_seconds,
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ def _normalize_video(info: dict) -> dict:
|
|||||||
"category": info.get("category") or (info.get("categories") or [None])[0],
|
"category": info.get("category") or (info.get("categories") or [None])[0],
|
||||||
"chapters": json.dumps(chapters) if chapters else None,
|
"chapters": json.dumps(chapters) if chapters else None,
|
||||||
"view_count": info.get("view_count"),
|
"view_count": info.get("view_count"),
|
||||||
|
"like_count": info.get("like_count"),
|
||||||
"channel": {
|
"channel": {
|
||||||
"youtube_channel_id": info.get("channel_id"),
|
"youtube_channel_id": info.get("channel_id"),
|
||||||
"name": info.get("channel") or info.get("uploader", ""),
|
"name": info.get("channel") or info.get("uploader", ""),
|
||||||
@@ -390,7 +391,7 @@ def fetch_video_comments(youtube_video_id: str, max_comments: int = 20) -> list[
|
|||||||
"yt-dlp", url,
|
"yt-dlp", url,
|
||||||
"--dump-json",
|
"--dump-json",
|
||||||
"--write-comments",
|
"--write-comments",
|
||||||
"--extractor-args", f"youtube:max_comments={max_comments},max_comment_depth=1",
|
"--extractor-args", f"youtube:max_comments={max_comments};comment_sort=top",
|
||||||
"--no-download",
|
"--no-download",
|
||||||
"--no-playlist",
|
"--no-playlist",
|
||||||
"--quiet",
|
"--quiet",
|
||||||
|
|||||||
@@ -894,6 +894,7 @@ export default function Watch() {
|
|||||||
<div className="flex items-center gap-2 text-sm text-zinc-500 flex-wrap">
|
<div className="flex items-center gap-2 text-sm text-zinc-500 flex-wrap">
|
||||||
{date && <span>{date}</span>}
|
{date && <span>{date}</span>}
|
||||||
{video?.view_count > 0 && <><span>·</span><span>{formatViews(video.view_count)}</span></>}
|
{video?.view_count > 0 && <><span>·</span><span>{formatViews(video.view_count)}</span></>}
|
||||||
|
{video?.like_count > 0 && <><span>·</span><span>👍 {formatViews(video.like_count).replace(" views", "")}</span></>}
|
||||||
{video?.category && <><span>·</span><span>{video.category}</span></>}
|
{video?.category && <><span>·</span><span>{video.category}</span></>}
|
||||||
{video?.duration_seconds && (
|
{video?.duration_seconds && (
|
||||||
<><span>·</span>
|
<><span>·</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user