like数の表示
This commit is contained in:
parent
80d14f7a9d
commit
980bc54f33
|
|
@ -67,6 +67,9 @@ async function fetchVideoDetails(
|
||||||
: null,
|
: null,
|
||||||
publishedAt: item.snippet?.publishedAt?.slice(0, 10) ?? null,
|
publishedAt: item.snippet?.publishedAt?.slice(0, 10) ?? null,
|
||||||
category: CATEGORY_MAP[item.snippet?.categoryId] ?? null,
|
category: CATEGORY_MAP[item.snippet?.categoryId] ?? null,
|
||||||
|
likeCount: item.statistics?.likeCount
|
||||||
|
? parseInt(item.statistics.likeCount, 10)
|
||||||
|
: null,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
browser.tabs.sendMessage(tabId, {
|
browser.tabs.sendMessage(tabId, {
|
||||||
|
|
|
||||||
|
|
@ -180,6 +180,7 @@ function parseVideo(renderer: any): PlaylistVideo | null {
|
||||||
category: null,
|
category: null,
|
||||||
addedBy: null,
|
addedBy: null,
|
||||||
voteCount: null,
|
voteCount: null,
|
||||||
|
likeCount: null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ function mapRawVideo(v: any): PlaylistVideo {
|
||||||
category: v.category ?? null,
|
category: v.category ?? null,
|
||||||
addedBy: v.addedBy ?? null,
|
addedBy: v.addedBy ?? null,
|
||||||
voteCount: v.voteCount ?? null,
|
voteCount: v.voteCount ?? null,
|
||||||
|
likeCount: v.likeCount ?? null,
|
||||||
} satisfies PlaylistVideo;
|
} satisfies PlaylistVideo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ type MessageKey =
|
||||||
| "colViews"
|
| "colViews"
|
||||||
| "colPublished"
|
| "colPublished"
|
||||||
| "colCategory"
|
| "colCategory"
|
||||||
|
| "colLikes"
|
||||||
| "colAddedBy"
|
| "colAddedBy"
|
||||||
| "colVotes"
|
| "colVotes"
|
||||||
| "filterTitle"
|
| "filterTitle"
|
||||||
|
|
@ -41,6 +42,7 @@ const messages: Record<string, Record<MessageKey, string>> = {
|
||||||
colViews: "再生数",
|
colViews: "再生数",
|
||||||
colPublished: "公開日",
|
colPublished: "公開日",
|
||||||
colCategory: "カテゴリ",
|
colCategory: "カテゴリ",
|
||||||
|
colLikes: "高評価",
|
||||||
colAddedBy: "追加者",
|
colAddedBy: "追加者",
|
||||||
colVotes: "投票",
|
colVotes: "投票",
|
||||||
filterTitle: "タイトル検索...",
|
filterTitle: "タイトル検索...",
|
||||||
|
|
@ -75,6 +77,7 @@ const messages: Record<string, Record<MessageKey, string>> = {
|
||||||
colViews: "Views",
|
colViews: "Views",
|
||||||
colPublished: "Published",
|
colPublished: "Published",
|
||||||
colCategory: "Category",
|
colCategory: "Category",
|
||||||
|
colLikes: "Likes",
|
||||||
colAddedBy: "Added by",
|
colAddedBy: "Added by",
|
||||||
colVotes: "Votes",
|
colVotes: "Votes",
|
||||||
filterTitle: "Search title...",
|
filterTitle: "Search title...",
|
||||||
|
|
|
||||||
|
|
@ -513,6 +513,7 @@ html[dark] .ytpf-tr:hover {
|
||||||
.ytpf-col-views { width: 120px; text-align: right; font-family: "Roboto Mono", monospace; }
|
.ytpf-col-views { width: 120px; text-align: right; font-family: "Roboto Mono", monospace; }
|
||||||
.ytpf-col-published { width: 110px; font-family: "Roboto Mono", monospace; }
|
.ytpf-col-published { width: 110px; font-family: "Roboto Mono", monospace; }
|
||||||
.ytpf-col-category { width: 120px; }
|
.ytpf-col-category { width: 120px; }
|
||||||
|
.ytpf-col-likes { width: 90px; text-align: right; font-family: "Roboto Mono", monospace; }
|
||||||
.ytpf-col-addedby { width: 140px; }
|
.ytpf-col-addedby { width: 140px; }
|
||||||
.ytpf-col-votes { width: 60px; text-align: center; font-family: "Roboto Mono", monospace; }
|
.ytpf-col-votes { width: 60px; text-align: center; font-family: "Roboto Mono", monospace; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import type { PlaylistData, PlaylistVideo, DetailUpdate } from "../../types/play
|
||||||
import type { Message } from "../../shared/messages";
|
import type { Message } from "../../shared/messages";
|
||||||
import { t } from "./i18n";
|
import { t } from "./i18n";
|
||||||
|
|
||||||
type SortKey = "index" | "title" | "channel" | "duration" | "views" | "published" | "category" | "addedBy" | "votes";
|
type SortKey = "index" | "title" | "channel" | "duration" | "views" | "likes" | "published" | "category" | "addedBy" | "votes";
|
||||||
type SortDir = "asc" | "desc";
|
type SortDir = "asc" | "desc";
|
||||||
|
|
||||||
interface Column {
|
interface Column {
|
||||||
|
|
@ -22,6 +22,7 @@ function getAllColumns(hasDetails: boolean): Column[] {
|
||||||
{ label: t("colChannel"), cls: "ytpf-col-channel", key: "channel", defaultWidth: 20 },
|
{ label: t("colChannel"), cls: "ytpf-col-channel", key: "channel", defaultWidth: 20 },
|
||||||
{ label: t("colDuration"), cls: "ytpf-col-duration", key: "duration", defaultWidth: 8 },
|
{ label: t("colDuration"), cls: "ytpf-col-duration", key: "duration", defaultWidth: 8 },
|
||||||
{ label: t("colViews"), cls: "ytpf-col-views", key: "views", defaultWidth: 12 },
|
{ label: t("colViews"), cls: "ytpf-col-views", key: "views", defaultWidth: 12 },
|
||||||
|
{ label: t("colLikes"), cls: "ytpf-col-likes", key: "likes", detail: true, defaultWidth: 9 },
|
||||||
{ label: t("colPublished"), cls: "ytpf-col-published", key: "published", detail: true, defaultWidth: 10 },
|
{ label: t("colPublished"), cls: "ytpf-col-published", key: "published", detail: true, defaultWidth: 10 },
|
||||||
{ label: t("colCategory"), cls: "ytpf-col-category", key: "category", detail: true, defaultWidth: 10 },
|
{ label: t("colCategory"), cls: "ytpf-col-category", key: "category", detail: true, defaultWidth: 10 },
|
||||||
{ label: t("colAddedBy"), cls: "ytpf-col-addedby", key: "addedBy", collab: true, defaultWidth: 14 },
|
{ label: t("colAddedBy"), cls: "ytpf-col-addedby", key: "addedBy", collab: true, defaultWidth: 14 },
|
||||||
|
|
@ -272,6 +273,8 @@ function compareFn(key: SortKey, dir: SortDir) {
|
||||||
return ((a.durationSeconds ?? -1) - (b.durationSeconds ?? -1)) * m;
|
return ((a.durationSeconds ?? -1) - (b.durationSeconds ?? -1)) * m;
|
||||||
case "views":
|
case "views":
|
||||||
return (parseViewCount(a.viewCountText) - parseViewCount(b.viewCountText)) * m;
|
return (parseViewCount(a.viewCountText) - parseViewCount(b.viewCountText)) * m;
|
||||||
|
case "likes":
|
||||||
|
return ((a.likeCount ?? -1) - (b.likeCount ?? -1)) * m;
|
||||||
case "published":
|
case "published":
|
||||||
return (a.publishedAt ?? "").localeCompare(b.publishedAt ?? "") * m;
|
return (a.publishedAt ?? "").localeCompare(b.publishedAt ?? "") * m;
|
||||||
case "category":
|
case "category":
|
||||||
|
|
@ -325,6 +328,9 @@ function buildCell(video: PlaylistVideo, col: Column, playlistId: string): HTMLT
|
||||||
case "views":
|
case "views":
|
||||||
td.textContent = video.viewCountText ?? "--";
|
td.textContent = video.viewCountText ?? "--";
|
||||||
break;
|
break;
|
||||||
|
case "likes":
|
||||||
|
td.textContent = video.likeCount != null ? video.likeCount.toLocaleString() : "--";
|
||||||
|
break;
|
||||||
case "published":
|
case "published":
|
||||||
td.textContent = video.publishedAt ?? "--";
|
td.textContent = video.publishedAt ?? "--";
|
||||||
break;
|
break;
|
||||||
|
|
@ -970,6 +976,7 @@ export function renderPlaylistTable(data: PlaylistData, columnPrefs: ColumnPrefs
|
||||||
v.viewCountText = u.viewCountText ?? v.viewCountText;
|
v.viewCountText = u.viewCountText ?? v.viewCountText;
|
||||||
v.publishedAt = u.publishedAt;
|
v.publishedAt = u.publishedAt;
|
||||||
v.category = u.category;
|
v.category = u.category;
|
||||||
|
v.likeCount = u.likeCount ?? v.likeCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,8 @@ export interface PlaylistVideo {
|
||||||
addedBy: string | null;
|
addedBy: string | null;
|
||||||
/** Vote count / approvals (collaborative playlists only) */
|
/** Vote count / approvals (collaborative playlists only) */
|
||||||
voteCount: number | null;
|
voteCount: number | null;
|
||||||
|
/** Like count from Data API */
|
||||||
|
likeCount: number | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PlaylistMetadata {
|
export interface PlaylistMetadata {
|
||||||
|
|
@ -55,6 +57,7 @@ export interface DetailUpdate {
|
||||||
viewCountText: string | null;
|
viewCountText: string | null;
|
||||||
publishedAt: string | null;
|
publishedAt: string | null;
|
||||||
category: string | null;
|
category: string | null;
|
||||||
|
likeCount: number | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PlaylistData {
|
export interface PlaylistData {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user