Plugin 1.2.0: Taste 'Gefaellt mir nicht', Fortschrittsbalken auf 'Aktueller Titel'
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -4030,8 +4030,10 @@ var require_actions = __commonJS({
|
||||
playlistTitle: "",
|
||||
playlistCover: "",
|
||||
// Cover-Adresse, von Playtube geholt (Befehl "playlist_cover")
|
||||
playlistCoverId: ""
|
||||
playlistCoverId: "",
|
||||
// zu welcher Playlist das gespeicherte Cover gehoert
|
||||
showProgress: true
|
||||
// "Aktueller Titel": Fortschrittsbalken ueber dem Cover
|
||||
});
|
||||
var TARGETS = ["auto", "youtube", "music"];
|
||||
var TABS = ["toggle", "youtube", "music"];
|
||||
@@ -4049,6 +4051,8 @@ var require_actions = __commonJS({
|
||||
settings.seconds = clampInt(settings.seconds, 1, 300, DEFAULTS.seconds);
|
||||
const show = raw && raw.showTitle !== void 0 ? raw.showTitle : titleDefault;
|
||||
settings.showTitle = show === true || show === "true";
|
||||
const progress = raw && raw.showProgress !== void 0 ? raw.showProgress : DEFAULTS.showProgress;
|
||||
settings.showProgress = progress === true || progress === "true";
|
||||
settings.playlistId = typeof settings.playlistId === "string" ? settings.playlistId.trim() : "";
|
||||
settings.playlistTitle = typeof settings.playlistTitle === "string" ? settings.playlistTitle : "";
|
||||
const cover = typeof settings.playlistCover === "string" ? settings.playlistCover : "";
|
||||
@@ -4153,9 +4157,13 @@ var require_actions = __commonJS({
|
||||
if (!connected) return { coverUrl: null, title: s.showTitle ? OFFLINE_TITLE : "" };
|
||||
const tab = pickTab(state, s.target);
|
||||
const info = tab && tab.info;
|
||||
const duration = info && Number(info.duration);
|
||||
const current = info && Number(info.currentTime);
|
||||
return {
|
||||
coverUrl: info && info.hasVideo && info.thumbnail ? info.thumbnail : null,
|
||||
title: s.showTitle && info && info.title ? wrapTitle(info.title) : ""
|
||||
title: s.showTitle && info && info.title ? wrapTitle(info.title) : "",
|
||||
// Anteil 0..1 (auf Prozent gerundet, damit nicht jede Sekunde ein neues Bild noetig ist).
|
||||
progress: s.showProgress && duration > 0 && Number.isFinite(current) ? Math.round(Math.max(0, Math.min(1, current / duration)) * 100) / 100 : null
|
||||
};
|
||||
}
|
||||
},
|
||||
@@ -4166,6 +4174,13 @@ var require_actions = __commonJS({
|
||||
return { state: tab && tab.info.likeStatus === "like" ? 1 : 0 };
|
||||
}
|
||||
},
|
||||
dislike: {
|
||||
request: (s) => ({ cmd: "dislike", fields: { target: s.target } }),
|
||||
render: (s, state, connected) => {
|
||||
const tab = connected ? pickTab(state, s.target) : null;
|
||||
return { state: tab && tab.info.likeStatus === "dislike" ? 1 : 0 };
|
||||
}
|
||||
},
|
||||
shuffle: { request: (s) => ({ cmd: "shuffle", fields: { target: s.target } }) },
|
||||
repeat: {
|
||||
request: (s) => ({ cmd: "repeat", fields: { target: s.target } }),
|
||||
@@ -4300,10 +4315,14 @@ var require_infoPanel = __commonJS({
|
||||
parts.push(`<rect x="${BAR_X}" y="${BAR_Y}" width="${(BAR_WIDTH * ratio).toFixed(1)}" height="${BAR_HEIGHT}" rx="3" fill="${ACCENT}"/>`);
|
||||
return `${head}${parts.join("")}</svg>`;
|
||||
}
|
||||
function buildCoverProgressSvg(coverDataUri, ratio) {
|
||||
const clamped = Math.max(0, Math.min(1, Number(ratio) || 0));
|
||||
return `<svg xmlns="http://www.w3.org/2000/svg" width="${SIZE}" height="${SIZE}" viewBox="0 0 ${SIZE} ${SIZE}"><rect width="${SIZE}" height="${SIZE}" fill="${BACKGROUND}"/><image x="0" y="0" width="${SIZE}" height="${SIZE}" preserveAspectRatio="xMidYMid slice" href="${coverDataUri}"/><rect x="0" y="0" width="${SIZE}" height="7" fill="#000" fill-opacity="0.55"/><rect x="0" y="0" width="${(SIZE * clamped).toFixed(1)}" height="7" fill="${ACCENT}"/></svg>`;
|
||||
}
|
||||
function svgToDataUri(svg) {
|
||||
return `data:image/svg+xml;base64,${Buffer.from(svg, "utf8").toString("base64")}`;
|
||||
}
|
||||
module2.exports = { buildInfoSvg, svgToDataUri, formatTime, SIZE };
|
||||
module2.exports = { buildInfoSvg, buildCoverProgressSvg, svgToDataUri, formatTime, SIZE };
|
||||
}
|
||||
});
|
||||
|
||||
@@ -4320,7 +4339,7 @@ var require_controller = __commonJS({
|
||||
pickTab,
|
||||
renderAction
|
||||
} = require_actions();
|
||||
var { buildInfoSvg, svgToDataUri } = require_infoPanel();
|
||||
var { buildInfoSvg, buildCoverProgressSvg, svgToDataUri } = require_infoPanel();
|
||||
var POLL_INTERVAL_MS = 1e3;
|
||||
var REFRESH_AFTER_COMMAND_MS = 350;
|
||||
var COVER_CACHE_LIMIT = 24;
|
||||
@@ -4532,13 +4551,17 @@ var require_controller = __commonJS({
|
||||
const coverUrl = view.coverUrl ? sharpCoverUrl(view.coverUrl) : null;
|
||||
const cover = coverUrl ? this.covers.get(coverUrl) || null : null;
|
||||
if (coverUrl && !cover) this.loadCover(coverUrl);
|
||||
const next = { state: view.state, title: view.title, cover: cover ? coverUrl : null };
|
||||
const progress = cover && typeof view.progress === "number" ? view.progress : null;
|
||||
const next = { state: view.state, title: view.title, cover: cover ? coverUrl : null, progress };
|
||||
const previous = key.last || {};
|
||||
const changed = (name) => previous[name] !== next[name];
|
||||
key.last = next;
|
||||
if (view.state !== void 0 && changed("state")) this.host.setState(context, view.state);
|
||||
if (view.title !== void 0 && changed("title")) this.host.setTitle(context, view.title);
|
||||
if (view.coverUrl !== void 0 && changed("cover")) this.host.setImage(context, cover);
|
||||
if (view.coverUrl !== void 0 && (changed("cover") || changed("progress"))) {
|
||||
const image = cover && progress !== null ? svgToDataUri(buildCoverProgressSvg(cover, progress)) : cover;
|
||||
this.host.setImage(context, image);
|
||||
}
|
||||
}
|
||||
/** Hohes Info-Display: komplette "Aktueller Titel"-Karte als SVG-Bild. */
|
||||
renderInfo(context, key) {
|
||||
|
||||
Reference in New Issue
Block a user