Improve ATV handling

This commit is contained in:
ponzischeme89
2026-05-27 07:21:24 +12:00
parent 9291a97df9
commit c3137a2bdf
14 changed files with 2206 additions and 391 deletions
+102 -80
View File
@@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Current Airing Shows</title>
<title>EmbyToolkit</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<style>
@@ -13,13 +13,13 @@
--surface2: #1a2030;
--surface3: #222840;
--border: #252d3d;
--border-active: #4a6fff;
--border-active: #14b8a6;
--text: #e8ecf4;
--text-2: #8892a8;
--text-3: #4e5a70;
--accent: #4a6fff;
--accent-h: #6384ff;
--accent-glow: rgba(74,111,255,0.12);
--accent: #14b8a6;
--accent-h: #2dd4bf;
--accent-glow: rgba(20,184,166,0.12);
--green: #34d399;
--green-bg: rgba(52,211,153,0.08);
--red: #f87171;
@@ -30,86 +30,86 @@
* { box-sizing: border-box; }
body {
margin: 0;
min-height: 100vh;
min-height: 100svh;
background: var(--bg);
color: var(--text);
font-family: 'DM Sans', sans-serif;
display: grid;
grid-template-columns: 220px 1fr;
height: 100vh;
height: 100svh;
overflow: hidden;
}
.header {
height: 56px;
padding: 0 24px;
/* ── App Nav Sidebar ── */
.app-nav {
display: flex;
align-items: center;
gap: 14px;
border-bottom: 1px solid var(--border);
flex-direction: column;
background: var(--surface);
border-right: 1px solid var(--border);
overflow: hidden;
}
.header-logo {
width: 30px;
height: 30px;
border-radius: 7px;
display: grid;
place-items: center;
background: var(--accent);
color: #fff;
font-size: 12px;
font-weight: 700;
}
.header h1 {
margin: 0;
font-size: 15px;
font-weight: 600;
letter-spacing: -0.02em;
}
.header-nav {
.app-nav-brand {
padding: 18px 16px;
display: flex;
align-items: center;
gap: 8px;
margin-left: 10px;
gap: 10px;
border-bottom: 1px solid var(--border);
flex-shrink: 0;
}
.nav-link {
padding: 6px 10px;
border-radius: 999px;
border: 1px solid var(--border);
.app-nav-logo {
width: 32px; height: 32px;
background: var(--accent);
border-radius: 8px;
display: grid; place-items: center;
color: #fff;
flex-shrink: 0;
}
.app-nav-name {
font-size: 15px;
font-weight: 700;
letter-spacing: -0.03em;
}
.app-nav-items {
list-style: none;
padding: 8px;
flex: 1;
overflow-y: auto;
margin: 0;
}
.app-nav-item {
display: flex;
align-items: center;
gap: 10px;
padding: 9px 12px;
border-radius: 8px;
color: var(--text-2);
text-decoration: none;
font-size: 12px;
font-weight: 600;
transition: background 0.12s, border-color 0.12s, color 0.12s;
font-size: 13px;
font-weight: 500;
transition: background 0.12s, color 0.12s;
margin-bottom: 1px;
}
.nav-link:hover {
background: var(--surface2);
color: var(--text);
}
.nav-link.active {
background: var(--accent-glow);
border-color: var(--accent);
color: var(--text);
}
.header-status {
margin-left: auto;
.app-nav-item:hover { background: var(--surface2); color: var(--text); }
.app-nav-item.active { background: var(--accent); color: #fff; }
.app-nav-footer {
padding: 14px 16px;
border-top: 1px solid var(--border);
display: flex;
align-items: center;
gap: 7px;
font-size: 12px;
color: var(--text-2);
flex-shrink: 0;
}
.dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--green);
box-shadow: 0 0 6px var(--green);
}
.dot.off {
background: var(--red);
box-shadow: 0 0 6px var(--red);
width: 7px; height: 7px; border-radius: 50%;
background: var(--green); box-shadow: 0 0 6px var(--green);
}
.dot.off { background: var(--red); box-shadow: 0 0 6px var(--red); }
.page {
padding: 20px 22px 26px;
overflow-y: auto;
}
.hero {
display: flex;
@@ -195,12 +195,6 @@
}
.btn:hover:not(:disabled) { background: var(--surface3); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
background: var(--accent);
border-color: var(--accent);
color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-h); }
.btn-green {
background: var(--green);
border-color: var(--green);
@@ -382,19 +376,36 @@
</head>
<body>
<header class="header">
<div class="header-logo">TG</div>
<h1>Emby Thumbnail Generator</h1>
<nav class="header-nav">
<a class="nav-link" href="/">Generator</a>
<a class="nav-link" href="/collections">Collections</a>
<a class="nav-link active" href="/airing">Airing</a>
</nav>
<div class="header-status">
<nav class="app-nav">
<div class="app-nav-brand">
<div class="app-nav-logo">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/><polyline points="3.29 7 12 12 20.71 7"/><line x1="12" y1="22" x2="12" y2="12"/></svg>
</div>
<span class="app-nav-name">EmbyToolkit</span>
</div>
<ul class="app-nav-items">
<li><a class="app-nav-item" href="/">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><path d="m21 15-5-5L5 21"/></svg>
<span>Generator</span>
</a></li>
<li><a class="app-nav-item" href="/collections">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="14" y="14" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/></svg>
<span>Collections</span>
</a></li>
<li><a class="app-nav-item active" href="/airing">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="7" width="20" height="15" rx="2"/><polyline points="17 2 12 7 7 2"/></svg>
<span>Airing</span>
</a></li>
<li><a class="app-nav-item" href="/bulk-assign">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"/></svg>
<span>Bulk Assign</span>
</a></li>
</ul>
<div class="app-nav-footer">
<span class="dot" id="statusDot"></span>
<span id="statusText">Checking…</span>
</div>
</header>
</nav>
<main class="page">
<section class="hero">
@@ -402,7 +413,7 @@
<h2>Current Airing Shows</h2>
<p>
This page uses Emby metadata to find continuing shows, upcoming airtimes, and season premieres.
<strong>Apply New Season</strong> is enabled when the latest season premiere is between 1 and 3 weeks old.
<strong>Apply New Season</strong> is available only when the show is in Emby and already has a logo.
</p>
</div>
</section>
@@ -520,8 +531,10 @@ function formatWeekRange(startValue, endValue) {
function canApplyNewSeason(item) {
return Boolean(
item.eligible_new_season ||
((item.status || '').toLowerCase() === 'continuing' && (item.selected_week_air_at || item.next_air_at))
item.has_logo && (
item.eligible_new_season ||
((item.status || '').toLowerCase() === 'continuing' && (item.selected_week_air_at || item.next_air_at))
)
);
}
@@ -536,6 +549,15 @@ function renderCards(items) {
${items.map((item) => `
${(() => {
const applyAllowed = canApplyNewSeason(item);
const note = !item.has_logo
? 'Requires an Emby logo before New Season artwork can be applied.'
: applyAllowed
? (item.eligibility_reason === 'current_airing' || (!item.eligibility_reason && ((item.status || '').toLowerCase() === 'continuing') && (item.selected_week_air_at || item.next_air_at))
? 'Applies thumb + primary. Eligible because the show is continuing and has a current or upcoming airing.'
: (item.season_premiere_inferred
? 'Applies thumb + primary. Season start was inferred from current season activity.'
: 'Applies thumb + primary with default artwork settings.'))
: `Available when Emby finds a current or upcoming airing, or a recent season start in the ${esc(String(state.windowMinDays))}-${esc(String(state.windowMaxDays))} day window.`;
return `
<article class="card">
<img class="card-poster" src="${esc(item.poster_url)}" alt="" loading="lazy" decoding="async">
@@ -578,7 +600,7 @@ function renderCards(items) {
>
${state.applyingId === item.id ? 'Applying…' : 'Apply New Season'}
</button>
<span class="card-note">${applyAllowed ? (item.eligibility_reason === 'current_airing' || (!item.eligibility_reason && ((item.status || '').toLowerCase() === 'continuing') && (item.selected_week_air_at || item.next_air_at)) ? 'Applies thumb + primary. Eligible because the show is continuing and has a current or upcoming airing.' : (item.season_premiere_inferred ? 'Applies thumb + primary. Season start was inferred from current season activity.' : 'Applies thumb + primary with default artwork settings.')) : `Available when Emby finds a current or upcoming airing, or a recent season start in the ${esc(String(state.windowMinDays))}-${esc(String(state.windowMaxDays))} day window.`}</span>
<span class="card-note">${note}</span>
</div>
</div>
</article>
+872
View File
@@ -0,0 +1,872 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>EmbyToolkit</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<style>
:root {
--bg: #0d0f12;
--surface: #13171f;
--surface2: #1a2030;
--surface3: #222840;
--border: #252d3d;
--text: #e8ecf4;
--text-2: #8892a8;
--text-3: #4e5a70;
--accent: #14b8a6;
--accent-h: #2dd4bf;
--accent-glow: rgba(20,184,166,0.12);
--green: #34d399;
--green-bg: rgba(52,211,153,0.08);
--red: #f87171;
--r: 10px;
--r-lg: 14px;
}
* { box-sizing: border-box; }
body {
margin: 0;
background: var(--bg);
color: var(--text);
font-family: 'DM Sans', sans-serif;
display: grid;
grid-template-columns: 220px 1fr;
height: 100vh;
height: 100svh;
overflow: hidden;
}
/* ── App Nav Sidebar ── */
.app-nav {
display: flex;
flex-direction: column;
background: var(--surface);
border-right: 1px solid var(--border);
overflow: hidden;
}
.app-nav-brand {
padding: 18px 16px;
display: flex;
align-items: center;
gap: 10px;
border-bottom: 1px solid var(--border);
flex-shrink: 0;
}
.app-nav-logo {
width: 32px; height: 32px;
background: var(--accent);
border-radius: 8px;
display: grid; place-items: center;
color: #fff;
flex-shrink: 0;
}
.app-nav-name {
font-size: 15px;
font-weight: 700;
letter-spacing: -0.03em;
}
.app-nav-items {
list-style: none;
padding: 8px;
flex: 1;
overflow-y: auto;
margin: 0;
}
.app-nav-item {
display: flex;
align-items: center;
gap: 10px;
padding: 9px 12px;
border-radius: 8px;
color: var(--text-2);
text-decoration: none;
font-size: 13px;
font-weight: 500;
transition: background 0.12s, color 0.12s;
margin-bottom: 1px;
}
.app-nav-item:hover { background: var(--surface2); color: var(--text); }
.app-nav-item.active { background: var(--accent); color: #fff; }
.app-nav-footer {
padding: 14px 16px;
border-top: 1px solid var(--border);
display: flex;
align-items: center;
gap: 7px;
font-size: 12px;
color: var(--text-2);
flex-shrink: 0;
}
.dot {
width: 7px; height: 7px; border-radius: 50%;
background: var(--green); box-shadow: 0 0 6px var(--green);
}
.dot.off { background: var(--red); box-shadow: 0 0 6px var(--red); }
.tab-bar {
display: flex;
gap: 6px;
margin-bottom: 18px;
}
.tab-btn {
min-height: 34px;
padding: 0 16px;
border-radius: 999px;
border: 1px solid var(--border);
background: var(--surface2);
color: var(--text-2);
font-family: inherit;
font-size: 13px;
font-weight: 600;
cursor: pointer;
transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.tab-btn:hover { background: var(--surface3); color: var(--text); }
.tab-btn.active {
background: var(--accent-glow);
border-color: var(--accent);
color: var(--text);
}
.header-status {
margin-left: auto;
display: flex;
align-items: center;
gap: 7px;
font-size: 12px;
color: var(--text-2);
}
.dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--green);
box-shadow: 0 0 6px var(--green);
}
.dot.off {
background: var(--red);
box-shadow: 0 0 6px var(--red);
}
.page {
padding: 20px 22px 26px;
overflow-y: auto;
}
.hero {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 18px;
margin-bottom: 16px;
}
.hero-copy h2 {
margin: 0 0 8px;
font-size: clamp(24px, 3vw, 34px);
line-height: 1;
letter-spacing: -0.04em;
}
.hero-copy p {
margin: 0;
max-width: 860px;
color: var(--text-2);
font-size: 14px;
line-height: 1.5;
}
.toolbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 14px;
margin-bottom: 18px;
padding: 14px 16px;
border: 1px solid var(--border);
border-radius: var(--r-lg);
background: linear-gradient(180deg, rgba(26,32,48,0.95), rgba(19,23,31,0.95));
}
.toolbar-meta {
display: flex;
flex-wrap: wrap;
gap: 16px;
color: var(--text-2);
font-size: 12px;
}
.toolbar-meta strong {
color: var(--text);
font-weight: 700;
}
.toolbar-actions {
display: flex;
align-items: center;
gap: 10px;
flex-wrap: wrap;
}
.search-input {
min-width: 260px;
min-height: 36px;
padding: 0 12px;
border-radius: 10px;
border: 1px solid var(--border);
background: var(--surface2);
color: var(--text);
font: inherit;
}
.selection-meta {
color: var(--text-2);
font-size: 12px;
font-family: 'JetBrains Mono', monospace;
}
.chip-toggle {
min-height: 34px;
padding: 0 12px;
display: inline-flex;
align-items: center;
gap: 8px;
border-radius: 999px;
border: 1px solid var(--border);
background: var(--surface2);
color: var(--text);
cursor: pointer;
user-select: none;
font-size: 12px;
font-weight: 600;
}
.chip-toggle input {
margin: 0;
accent-color: var(--accent);
}
.btn {
min-height: 36px;
padding: 0 14px;
border-radius: 10px;
border: 1px solid var(--border);
background: var(--surface2);
color: var(--text);
font-family: inherit;
font-size: 13px;
font-weight: 600;
cursor: pointer;
transition: background 0.12s, border-color 0.12s, opacity 0.12s;
}
.btn:hover:not(:disabled) { background: var(--surface3); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
background: var(--accent);
border-color: var(--accent);
color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-h); }
.btn-green {
background: var(--green);
border-color: var(--green);
color: #08120e;
}
.grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 14px;
}
.card {
display: grid;
grid-template-columns: 108px minmax(0, 1fr);
gap: 14px;
padding: 14px;
border: 1px solid var(--border);
border-radius: var(--r-lg);
background: linear-gradient(180deg, rgba(19,23,31,0.98), rgba(13,15,18,0.98));
min-height: 186px;
}
.card-poster {
width: 108px;
aspect-ratio: 2 / 3;
object-fit: cover;
border-radius: 10px;
background: var(--surface2);
}
.card-poster.placeholder {
display: grid;
place-items: center;
color: var(--text-3);
font-size: 12px;
}
.card-body {
min-width: 0;
display: flex;
flex-direction: column;
gap: 10px;
}
.card-top {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 10px;
}
.card-title {
margin: 0;
font-size: 18px;
font-weight: 700;
line-height: 1.1;
letter-spacing: -0.03em;
}
.card-year {
margin-top: 4px;
color: var(--text-2);
font-size: 12px;
}
.pill {
padding: 4px 8px;
border-radius: 999px;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.06em;
text-transform: uppercase;
border: 1px solid transparent;
white-space: nowrap;
}
.pill-green {
background: var(--green-bg);
border-color: rgba(52,211,153,0.4);
color: var(--green);
}
.pill-muted {
background: rgba(136,146,168,0.08);
border-color: rgba(136,146,168,0.2);
color: var(--text-2);
}
.meta-list {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.meta-chip {
padding: 6px 8px;
border-radius: 999px;
border: 1px solid var(--border);
background: var(--surface2);
color: var(--text-2);
font-size: 11px;
font-weight: 600;
letter-spacing: 0.03em;
}
.meta-chip.ok {
border-color: rgba(52,211,153,0.4);
background: var(--green-bg);
color: var(--green);
}
.card-actions {
display: flex;
align-items: center;
gap: 10px;
margin-top: auto;
flex-wrap: wrap;
}
.card-check {
min-height: 32px;
padding: 0 10px;
}
.card-note {
color: var(--text-3);
font-size: 12px;
flex: 1 1 220px;
}
.empty {
padding: 54px 20px;
border: 1px dashed var(--border);
border-radius: var(--r-lg);
text-align: center;
color: var(--text-3);
font-size: 14px;
}
.pager {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-top: 16px;
padding-top: 4px;
}
.pager-meta {
color: var(--text-2);
font-size: 12px;
font-family: 'JetBrains Mono', monospace;
}
.pager-actions {
display: flex;
gap: 8px;
}
.toast {
position: fixed;
right: 20px;
bottom: 20px;
padding: 11px 18px;
border-radius: 10px;
font-size: 13px;
font-weight: 500;
transform: translateY(80px);
opacity: 0;
transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
pointer-events: none;
z-index: 50;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.ok { background: var(--green-bg); border: 1px solid var(--green); color: var(--green); }
.toast.err { background: rgba(248,113,113,.1); border: 1px solid var(--red); color: var(--red); }
@media (max-width: 980px) {
.hero, .toolbar, .pager {
flex-direction: column;
align-items: stretch;
}
.toolbar-actions, .pager-actions {
justify-content: space-between;
}
.search-input {
min-width: 0;
width: 100%;
}
}
@media (max-width: 720px) {
.page { padding: 16px; }
.header { padding: 0 16px; }
.card {
grid-template-columns: 84px minmax(0, 1fr);
gap: 12px;
padding: 12px;
}
.card-poster { width: 84px; }
.card-title { font-size: 16px; }
}
</style>
</head>
<body>
<nav class="app-nav">
<div class="app-nav-brand">
<div class="app-nav-logo">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/><polyline points="3.29 7 12 12 20.71 7"/><line x1="12" y1="22" x2="12" y2="12"/></svg>
</div>
<span class="app-nav-name">EmbyToolkit</span>
</div>
<ul class="app-nav-items">
<li><a class="app-nav-item" href="/">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><path d="m21 15-5-5L5 21"/></svg>
<span>Generator</span>
</a></li>
<li><a class="app-nav-item" href="/collections">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="14" y="14" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/></svg>
<span>Collections</span>
</a></li>
<li><a class="app-nav-item" href="/airing">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="7" width="20" height="15" rx="2"/><polyline points="17 2 12 7 7 2"/></svg>
<span>Airing</span>
</a></li>
<li><a class="app-nav-item active" href="/bulk-assign">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"/></svg>
<span>Bulk Assign</span>
</a></li>
</ul>
<div class="app-nav-footer">
<span class="dot" id="statusDot"></span>
<span id="statusText">Checking…</span>
</div>
</nav>
<main class="page">
<section class="hero">
<div class="hero-copy">
<h2>Bulk Assign</h2>
<p id="heroDesc">
Bulk assign applies generated <strong>Thumb</strong> artwork only,
and is enabled when Emby already has a <strong>Logo</strong> and <strong>Backdrop</strong>.
</p>
</div>
</section>
<div class="tab-bar">
<button class="tab-btn active" id="tabSeries" data-mode="series">TV Series</button>
<button class="tab-btn" id="tabMovies" data-mode="movies">Movies</button>
</div>
<section class="toolbar">
<div class="toolbar-meta">
<div><strong id="countText">0</strong> <span id="countLabel">series</span></div>
<div>Search <strong id="queryText">All</strong></div>
</div>
<div class="toolbar-actions">
<input class="search-input" id="searchInput" type="text" placeholder="Search TV series…" autocomplete="off">
<button class="btn" id="btnRefresh">Refresh</button>
<button class="btn" id="btnSelectEligible">Select eligible</button>
<button class="btn" id="btnClearSelected">Clear selected</button>
<button class="btn btn-primary" id="btnBulkApply" disabled>Apply Selected</button>
<button class="btn btn-green" id="btnApplyAll">Apply All Eligible</button>
<div class="selection-meta" id="selectionMeta">0 selected</div>
</div>
</section>
<section id="results">
<div class="empty">Loading series…</div>
</section>
<section class="pager">
<div class="pager-meta" id="pagerMeta">No results</div>
<div class="pager-actions">
<button class="btn" id="btnPrev" disabled>Previous</button>
<button class="btn" id="btnNext" disabled>Next</button>
</div>
</section>
</main>
<div class="toast" id="toast"></div>
<script>
const state = {
mode: 'series',
page: 1,
limit: 24,
total: 0,
query: '',
items: [],
applyingId: null,
bulkApplying: false,
selectedIds: new Set(),
searchTimer: null,
};
const $ = (selector) => document.querySelector(selector);
const results = $('#results');
const countText = $('#countText');
const countLabel = $('#countLabel');
const queryText = $('#queryText');
const searchInput = $('#searchInput');
const selectionMeta = $('#selectionMeta');
const btnRefresh = $('#btnRefresh');
const btnSelectEligible = $('#btnSelectEligible');
const btnClearSelected = $('#btnClearSelected');
const btnBulkApply = $('#btnBulkApply');
const pagerMeta = $('#pagerMeta');
const btnPrev = $('#btnPrev');
const btnNext = $('#btnNext');
const toast = $('#toast');
const tabSeries = $('#tabSeries');
const tabMovies = $('#tabMovies');
const btnApplyAll = $('#btnApplyAll');
function esc(value) {
const div = document.createElement('div');
div.textContent = value ?? '';
return div.innerHTML;
}
function showToast(message, type) {
toast.textContent = message;
toast.className = `toast ${type} show`;
setTimeout(() => toast.classList.remove('show'), 2800);
}
function canBulkAssign(item) {
return Boolean(item.can_bulk_assign);
}
function updateBulkSelectionState() {
const count = state.selectedIds.size;
selectionMeta.textContent = `${count} selected`;
btnBulkApply.disabled = count === 0 || state.bulkApplying;
btnSelectEligible.disabled = state.bulkApplying || !state.items.some(canBulkAssign);
btnClearSelected.disabled = state.bulkApplying || count === 0;
btnApplyAll.disabled = state.bulkApplying;
}
function updatePager() {
const start = state.total === 0 ? 0 : ((state.page - 1) * state.limit) + 1;
const end = Math.min(state.page * state.limit, state.total);
pagerMeta.textContent = state.total ? `${start}-${end} of ${state.total} · Page ${state.page}` : 'No results';
btnPrev.disabled = state.page <= 1;
btnNext.disabled = state.page * state.limit >= state.total;
}
function selectEligibleOnPage() {
state.selectedIds = new Set(state.items.filter(canBulkAssign).map((item) => item.id));
renderCards(state.items);
updateBulkSelectionState();
}
function clearSelected() {
state.selectedIds.clear();
renderCards(state.items);
updateBulkSelectionState();
}
function renderCards(items) {
if (!items.length) {
const label = state.mode === 'movies' ? 'movies' : 'TV series';
results.innerHTML = `<div class="empty">No ${label} matched this search.</div>`;
updateBulkSelectionState();
return;
}
results.innerHTML = `
<div class="grid">
${items.map((item) => `
${(() => {
const applyAllowed = canBulkAssign(item);
const note = applyAllowed
? 'Ready to apply generated thumb artwork from Emby assets.'
: 'Requires Emby Logo and Backdrop images before bulk assign can apply.';
const poster = item.poster_url
? `<img class="card-poster" src="${esc(item.poster_url)}" alt="" loading="lazy" decoding="async">`
: '<div class="card-poster placeholder">No poster</div>';
return `
<article class="card">
${poster}
<div class="card-body">
<div class="card-top">
<div>
<h3 class="card-title">${esc(item.name)}</h3>
<div class="card-year">${item.year ? esc(String(item.year)) : '—'}</div>
</div>
<span class="pill ${applyAllowed ? 'pill-green' : 'pill-muted'}">
${applyAllowed ? 'Ready' : 'Missing assets'}
</span>
</div>
<div class="meta-list">
<span class="meta-chip ${item.has_primary ? 'ok' : ''}">Primary ${item.has_primary ? 'yes' : 'no'}</span>
<span class="meta-chip ${item.has_logo ? 'ok' : ''}">Logo ${item.has_logo ? 'yes' : 'no'}</span>
<span class="meta-chip ${item.has_backdrop ? 'ok' : ''}">Backdrop ${item.has_backdrop ? item.backdrop_count : 'no'}</span>
</div>
<div class="card-actions">
<label class="chip-toggle card-check" for="select-${esc(item.id)}">
<input
type="checkbox"
id="select-${esc(item.id)}"
data-select-id="${esc(item.id)}"
${applyAllowed ? '' : 'disabled'}
${state.selectedIds.has(item.id) ? 'checked' : ''}
>
<span>Select</span>
</label>
<button
class="btn btn-green"
data-apply-id="${esc(item.id)}"
data-apply-title="${esc(item.name)}"
${applyAllowed ? '' : 'disabled'}
>
${state.applyingId === item.id ? 'Applying…' : 'Apply Thumb'}
</button>
<span class="card-note">${note}</span>
</div>
</div>
</article>
`;
})()}
`).join('')}
</div>
`;
}
async function loadItems() {
const isMovies = state.mode === 'movies';
const label = isMovies ? 'movies' : 'series';
results.innerHTML = `<div class="empty">Loading ${label}…</div>`;
btnRefresh.disabled = true;
searchInput.placeholder = isMovies ? 'Search movies…' : 'Search TV series…';
countLabel.textContent = label;
try {
const start = (state.page - 1) * state.limit;
const endpoint = isMovies ? '/api/bulk-assign/movies' : '/api/bulk-assign/series';
const response = await fetch(`${endpoint}?q=${encodeURIComponent(state.query)}&start=${start}&limit=${state.limit}`);
const data = await response.json();
if (!response.ok) throw new Error(data.detail || `${response.status}`);
state.items = data.items;
state.total = data.total;
state.selectedIds.clear();
state.bulkApplying = false;
countText.textContent = data.total;
queryText.textContent = data.query || 'All';
renderCards(data.items);
updatePager();
} catch (error) {
results.innerHTML = `<div class="empty">Failed to load ${label}: ${esc(error.message)}</div>`;
state.items = [];
state.total = 0;
state.selectedIds.clear();
state.bulkApplying = false;
updatePager();
updateBulkSelectionState();
} finally {
btnRefresh.disabled = false;
updateBulkSelectionState();
}
}
results.addEventListener('click', async (event) => {
const button = event.target.closest('[data-apply-id]');
if (!button || button.disabled) return;
const itemId = button.dataset.applyId;
state.applyingId = itemId;
renderCards(state.items);
updateBulkSelectionState();
try {
const response = await fetch('/api/airing/apply-new-season/bulk', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
item_ids: [itemId],
generate_primary: false,
item_type: state.mode === 'movies' ? 'movie' : 'series',
}),
});
const data = await response.json();
if (!response.ok) throw new Error(data.detail || `${response.status}`);
if (data.applied_count !== 1) throw new Error('Item was not applied.');
showToast('Applied thumb', 'ok');
} catch (error) {
showToast(error.message, 'err');
} finally {
state.applyingId = null;
renderCards(state.items);
updateBulkSelectionState();
}
});
results.addEventListener('change', (event) => {
const checkbox = event.target.closest('[data-select-id]');
if (!checkbox) return;
const itemId = checkbox.dataset.selectId;
if (checkbox.checked) {
state.selectedIds.add(itemId);
} else {
state.selectedIds.delete(itemId);
}
updateBulkSelectionState();
});
searchInput.addEventListener('input', () => {
clearTimeout(state.searchTimer);
state.searchTimer = setTimeout(() => {
state.query = searchInput.value.trim();
state.page = 1;
loadItems();
}, 180);
});
btnRefresh.addEventListener('click', () => loadItems());
btnSelectEligible.addEventListener('click', selectEligibleOnPage);
btnClearSelected.addEventListener('click', clearSelected);
btnApplyAll.addEventListener('click', async () => {
if (state.bulkApplying) return;
const typeLabel = state.mode === 'movies' ? 'movies' : 'TV series';
const confirmed = window.confirm(
`Apply generated thumbs to ALL eligible ${typeLabel}?\n\nThis will process every item in your library that has a Logo and Backdrop in Emby — across all pages. This may take a while.`
);
if (!confirmed) return;
state.bulkApplying = true;
btnApplyAll.textContent = 'Applying…';
updateBulkSelectionState();
try {
const response = await fetch('/api/bulk-assign/apply-all', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ item_type: state.mode === 'movies' ? 'movie' : 'series' }),
});
const data = await response.json();
if (!response.ok) throw new Error(data.detail || `${response.status}`);
showToast(
`Apply All complete: ${data.applied_count}/${data.eligible_count} applied, ${data.failed_count} failed`,
data.failed_count ? 'err' : 'ok',
);
} catch (error) {
showToast(error.message, 'err');
} finally {
state.bulkApplying = false;
btnApplyAll.textContent = 'Apply All Eligible';
updateBulkSelectionState();
}
});
[tabSeries, tabMovies].forEach((btn) => {
btn.addEventListener('click', () => {
const mode = btn.dataset.mode;
if (mode === state.mode) return;
state.mode = mode;
state.page = 1;
state.query = '';
searchInput.value = '';
tabSeries.classList.toggle('active', mode === 'series');
tabMovies.classList.toggle('active', mode === 'movies');
loadItems();
});
});
btnBulkApply.addEventListener('click', async () => {
if (!state.selectedIds.size || state.bulkApplying) return;
const typeLabel = state.mode === 'movies' ? 'movies' : 'shows';
const confirmed = window.confirm(`Apply generated thumbs to ${state.selectedIds.size} selected ${typeLabel}?\n\nOnly items with Emby Logo and Backdrop assets will be updated.`);
if (!confirmed) return;
state.bulkApplying = true;
updateBulkSelectionState();
try {
const response = await fetch('/api/airing/apply-new-season/bulk', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
item_ids: Array.from(state.selectedIds),
generate_primary: false,
item_type: state.mode === 'movies' ? 'movie' : 'series',
}),
});
const data = await response.json();
if (!response.ok) throw new Error(data.detail || `${response.status}`);
showToast(
`Bulk complete: ${data.applied_count}/${data.requested_count} applied, ${data.skipped_missing_assets_count} skipped for missing assets, ${data.failed_count} failed`,
data.failed_count ? 'err' : 'ok',
);
clearSelected();
} catch (error) {
showToast(error.message, 'err');
} finally {
state.bulkApplying = false;
updateBulkSelectionState();
}
});
btnPrev.addEventListener('click', () => {
if (state.page <= 1) return;
state.page -= 1;
loadItems();
});
btnNext.addEventListener('click', () => {
if (state.page * state.limit >= state.total) return;
state.page += 1;
loadItems();
});
(async () => {
try {
const config = await (await fetch('/api/config')).json();
if (config.connected) {
$('#statusText').textContent = 'Connected to Emby';
} else {
$('#statusDot').classList.add('off');
$('#statusText').textContent = 'No API key';
}
} catch {
$('#statusDot').classList.add('off');
$('#statusText').textContent = 'Connection error';
}
})();
updateBulkSelectionState();
loadItems();
</script>
</body>
</html>
+80 -67
View File
@@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Emby Collection Artwork</title>
<title>EmbyToolkit</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<style>
@@ -13,13 +13,13 @@
--surface2: #1a2030;
--surface3: #222840;
--border: #252d3d;
--border-active: #4a6fff;
--border-active: #14b8a6;
--text: #e8ecf4;
--text-2: #8892a8;
--text-3: #4e5a70;
--accent: #4a6fff;
--accent-h: #6384ff;
--accent-glow: rgba(74,111,255,0.12);
--accent: #14b8a6;
--accent-h: #2dd4bf;
--accent-glow: rgba(20,184,166,0.12);
--green: #34d399;
--green-bg: rgba(52,211,153,0.08);
--red: #f87171;
@@ -31,88 +31,84 @@
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
min-height: 100vh;
min-height: 100svh;
background: var(--bg);
color: var(--text);
font-family: 'DM Sans', sans-serif;
display: flex;
flex-direction: column;
display: grid;
grid-template-columns: 220px 1fr;
height: 100vh;
height: 100svh;
overflow: hidden;
}
.header {
height: 56px;
padding: 0 24px;
/* ── App Nav Sidebar ── */
.app-nav {
display: flex;
flex-direction: column;
background: var(--surface);
border-right: 1px solid var(--border);
overflow: hidden;
}
.app-nav-brand {
padding: 18px 16px;
display: flex;
align-items: center;
gap: 14px;
gap: 10px;
border-bottom: 1px solid var(--border);
background: var(--surface);
flex-shrink: 0;
}
.header-logo {
width: 30px;
height: 30px;
border-radius: 7px;
display: grid;
place-items: center;
.app-nav-logo {
width: 32px; height: 32px;
background: var(--accent);
border-radius: 8px;
display: grid; place-items: center;
color: #fff;
font-size: 12px;
font-weight: 700;
flex-shrink: 0;
}
.header h1 {
.app-nav-name {
font-size: 15px;
font-weight: 600;
letter-spacing: -0.02em;
font-weight: 700;
letter-spacing: -0.03em;
}
.header-nav {
.app-nav-items {
list-style: none;
padding: 8px;
flex: 1;
overflow-y: auto;
margin: 0;
}
.app-nav-item {
display: flex;
align-items: center;
gap: 8px;
margin-left: 10px;
}
.nav-link {
padding: 6px 10px;
border-radius: 999px;
border: 1px solid var(--border);
gap: 10px;
padding: 9px 12px;
border-radius: 8px;
color: var(--text-2);
text-decoration: none;
font-size: 12px;
font-weight: 600;
transition: background 0.12s, border-color 0.12s, color 0.12s;
font-size: 13px;
font-weight: 500;
transition: background 0.12s, color 0.12s;
margin-bottom: 1px;
}
.nav-link:hover {
background: var(--surface2);
color: var(--text);
}
.nav-link.active {
background: var(--accent-glow);
border-color: var(--accent);
color: var(--text);
}
.header-status {
margin-left: auto;
.app-nav-item:hover { background: var(--surface2); color: var(--text); }
.app-nav-item.active { background: var(--accent); color: #fff; }
.app-nav-footer {
padding: 14px 16px;
border-top: 1px solid var(--border);
display: flex;
align-items: center;
gap: 7px;
font-size: 12px;
color: var(--text-2);
flex-shrink: 0;
}
.dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--green);
box-shadow: 0 0 6px var(--green);
}
.dot.off {
background: var(--red);
box-shadow: 0 0 6px var(--red);
width: 7px; height: 7px; border-radius: 50%;
background: var(--green); box-shadow: 0 0 6px var(--green);
}
.dot.off { background: var(--red); box-shadow: 0 0 6px var(--red); }
.body {
flex: 1;
min-height: 0;
display: grid;
grid-template-columns: 320px minmax(0, 1fr);
@@ -904,19 +900,36 @@
</head>
<body>
<header class="header">
<div class="header-logo">TG</div>
<h1>Emby Thumbnail Generator</h1>
<nav class="header-nav">
<a class="nav-link" href="/">Generator</a>
<a class="nav-link active" href="/collections">Collections</a>
<a class="nav-link" href="/airing">Airing</a>
</nav>
<div class="header-status">
<nav class="app-nav">
<div class="app-nav-brand">
<div class="app-nav-logo">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/><polyline points="3.29 7 12 12 20.71 7"/><line x1="12" y1="22" x2="12" y2="12"/></svg>
</div>
<span class="app-nav-name">EmbyToolkit</span>
</div>
<ul class="app-nav-items">
<li><a class="app-nav-item" href="/">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><path d="m21 15-5-5L5 21"/></svg>
<span>Generator</span>
</a></li>
<li><a class="app-nav-item active" href="/collections">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="14" y="14" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/></svg>
<span>Collections</span>
</a></li>
<li><a class="app-nav-item" href="/airing">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="7" width="20" height="15" rx="2"/><polyline points="17 2 12 7 7 2"/></svg>
<span>Airing</span>
</a></li>
<li><a class="app-nav-item" href="/bulk-assign">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"/></svg>
<span>Bulk Assign</span>
</a></li>
</ul>
<div class="app-nav-footer">
<span class="dot" id="statusDot"></span>
<span id="statusText">Checking…</span>
</div>
</header>
</nav>
<div class="body">
<aside class="sidebar">
+262 -99
View File
@@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Emby Thumbnail Generator</title>
<title>EmbyToolkit</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<style>
@@ -13,13 +13,13 @@
--surface2: #1a2030;
--surface3: #222840;
--border: #252d3d;
--border-active: #4a6fff;
--border-active: #14b8a6;
--text: #e8ecf4;
--text-2: #8892a8;
--text-3: #4e5a70;
--accent: #4a6fff;
--accent-h: #6384ff;
--accent-glow: rgba(74,111,255,0.12);
--accent: #14b8a6;
--accent-h: #2dd4bf;
--accent-glow: rgba(20,184,166,0.12);
--green: #34d399;
--green-bg: rgba(52,211,153,0.08);
--red: #f87171;
@@ -33,62 +33,73 @@
font-family: 'DM Sans', sans-serif;
background: var(--bg);
color: var(--text);
min-height: 100vh;
min-height: 100svh;
overflow: auto;
display: flex;
flex-direction: column;
display: grid;
grid-template-columns: 220px 1fr;
height: 100vh;
height: 100svh;
overflow: hidden;
}
/* ── Header ── */
.header {
height: 56px;
padding: 0 24px;
/* ── App Nav Sidebar ── */
.app-nav {
display: flex;
align-items: center;
gap: 14px;
border-bottom: 1px solid var(--border);
flex-direction: column;
background: var(--surface);
flex-shrink: 0;
border-right: 1px solid var(--border);
overflow: hidden;
}
.header-logo {
width: 30px; height: 30px;
background: var(--accent);
border-radius: 7px;
display: grid; place-items: center;
font-weight: 700; font-size: 12px; color: #fff;
flex-shrink: 0;
}
.header h1 { font-size: 15px; font-weight: 600; letter-spacing: -0.02em; }
.header-nav {
.app-nav-brand {
padding: 18px 16px;
display: flex;
align-items: center;
gap: 8px;
margin-left: 10px;
gap: 10px;
border-bottom: 1px solid var(--border);
flex-shrink: 0;
}
.nav-link {
padding: 6px 10px;
border-radius: 999px;
border: 1px solid var(--border);
.app-nav-logo {
width: 32px; height: 32px;
background: var(--accent);
border-radius: 8px;
display: grid; place-items: center;
color: #fff;
flex-shrink: 0;
}
.app-nav-name {
font-size: 15px;
font-weight: 700;
letter-spacing: -0.03em;
}
.app-nav-items {
list-style: none;
padding: 8px;
flex: 1;
overflow-y: auto;
margin: 0;
}
.app-nav-item {
display: flex;
align-items: center;
gap: 10px;
padding: 9px 12px;
border-radius: 8px;
color: var(--text-2);
text-decoration: none;
font-size: 13px;
font-weight: 500;
transition: background 0.12s, color 0.12s;
margin-bottom: 1px;
}
.app-nav-item:hover { background: var(--surface2); color: var(--text); }
.app-nav-item.active { background: var(--accent); color: #fff; }
.app-nav-footer {
padding: 14px 16px;
border-top: 1px solid var(--border);
display: flex;
align-items: center;
gap: 7px;
font-size: 12px;
font-weight: 600;
transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.nav-link:hover {
background: var(--surface2);
color: var(--text);
}
.nav-link.active {
background: var(--accent-glow);
border-color: var(--accent);
color: var(--text);
}
.header-status {
margin-left: auto;
display: flex; align-items: center; gap: 7px;
font-size: 12px; color: var(--text-2);
color: var(--text-2);
flex-shrink: 0;
}
.dot {
width: 7px; height: 7px; border-radius: 50%;
@@ -98,7 +109,6 @@
/* ── Body ── */
.body {
flex: 1;
display: grid;
grid-template-columns: 320px 1fr;
min-height: 0;
@@ -120,6 +130,55 @@
border-bottom: 1px solid var(--border);
flex-shrink: 0;
}
.studio-bulk-banner {
display: none;
margin-top: 10px;
align-items: center;
justify-content: space-between;
gap: 8px;
background: var(--surface2);
border: 1px solid var(--border);
border-radius: var(--r);
padding: 8px 10px;
}
.studio-bulk-banner.visible { display: flex; }
.studio-bulk-label {
font-size: 12px;
color: var(--text-2);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.studio-bulk-btn {
flex-shrink: 0;
padding: 5px 12px;
background: var(--accent);
color: #fff;
border: none;
border-radius: 6px;
font-size: 12px;
font-weight: 600;
font-family: inherit;
cursor: pointer;
transition: background 0.12s, opacity 0.12s;
}
.studio-bulk-btn:hover { background: var(--accent-h); }
.studio-bulk-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.studio-reset-btn {
flex-shrink: 0;
padding: 5px 10px;
background: transparent;
color: var(--red);
border: 1px solid var(--red);
border-radius: 6px;
font-size: 12px;
font-weight: 600;
font-family: inherit;
cursor: pointer;
transition: background 0.12s, opacity 0.12s;
}
.studio-reset-btn:hover { background: rgba(248,113,113,0.1); }
.studio-reset-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.search-inner { position: relative; }
.search-inner svg {
position: absolute; left: 11px; top: 50%;
@@ -809,12 +868,12 @@
.toast.err { background: rgba(248,113,113,.1); border: 1px solid var(--red); color: var(--red); }
@media (max-width: 1400px) {
.body { grid-template-columns: 280px minmax(0, 1fr); }
.body { grid-template-columns: 260px minmax(0, 1fr); }
.preview-shell { width: min(100%, 760px); }
}
@media (max-width: 1200px) {
.body { grid-template-columns: 248px minmax(0, 1fr); }
.body { grid-template-columns: 230px minmax(0, 1fr); }
.search-wrap,
.results-toolbar,
.results-footer,
@@ -876,19 +935,36 @@
</head>
<body>
<header class="header">
<div class="header-logo">TG</div>
<h1>Emby Thumbnail Generator</h1>
<nav class="header-nav">
<a class="nav-link active" href="/">Generator</a>
<a class="nav-link" href="/collections">Collections</a>
<a class="nav-link" href="/airing">Airing</a>
</nav>
<div class="header-status">
<nav class="app-nav">
<div class="app-nav-brand">
<div class="app-nav-logo">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/><polyline points="3.29 7 12 12 20.71 7"/><line x1="12" y1="22" x2="12" y2="12"/></svg>
</div>
<span class="app-nav-name">EmbyToolkit</span>
</div>
<ul class="app-nav-items">
<li><a class="app-nav-item active" href="/">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><path d="m21 15-5-5L5 21"/></svg>
<span>Generator</span>
</a></li>
<li><a class="app-nav-item" href="/collections">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="14" y="14" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/></svg>
<span>Collections</span>
</a></li>
<li><a class="app-nav-item" href="/airing">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="7" width="20" height="15" rx="2"/><polyline points="17 2 12 7 7 2"/></svg>
<span>Airing</span>
</a></li>
<li><a class="app-nav-item" href="/bulk-assign">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"/></svg>
<span>Bulk Assign</span>
</a></li>
</ul>
<div class="app-nav-footer">
<span class="dot" id="statusDot"></span>
<span id="statusText">Checking…</span>
</div>
</header>
</nav>
<div class="body">
@@ -899,6 +975,13 @@
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>
<input class="search-input" id="searchInput" type="text" placeholder="Search movies & shows…" autocomplete="off">
</div>
<div class="studio-bulk-banner" id="studioBulkBanner">
<span class="studio-bulk-label" id="studioBulkLabel">0 shows</span>
<div style="display:flex;gap:6px;flex-shrink:0">
<button class="studio-reset-btn" id="studioResetBtn">Reset All</button>
<button class="studio-bulk-btn" id="studioBulkBtn">Bulk Assign All</button>
</div>
</div>
</div>
<div class="results-toolbar" id="resultsToolbar" style="display:none">
<div class="results-count" id="resultsCount">0 results</div>
@@ -952,20 +1035,20 @@
<div class="primary-preview-shell" id="primaryPreviewShell">
<div class="primary-preview-head">
<span>Primary Preview</span>
<div class="primary-preview-tools">
<span>Primary Poster</span>
<div class="primary-preview-tools" id="primaryPreviewTools">
<button class="mini-link" id="btnPrimaryReset" type="button">Reset</button>
<span class="primary-preview-note" id="primaryPreviewMeta">100% · X 0 · Y -16</span>
</div>
</div>
<div class="primary-preview-frame" id="primaryPreviewFrame" title="Drag to position the poster crop. Use the mouse wheel to zoom.">
<div class="primary-preview-frame" id="primaryPreviewFrame" title="This applies the selected studio logo to the existing primary poster.">
<img id="primaryPreviewImg" src="" alt="">
<div class="primary-preview-zoom">
<div class="primary-preview-zoom" id="primaryPreviewZoom">
<button class="primary-preview-zoom-btn" id="btnPrimaryPreviewZoomOut" type="button" aria-label="Zoom out">-</button>
<button class="primary-preview-zoom-btn" id="btnPrimaryPreviewZoomIn" type="button" aria-label="Zoom in">+</button>
</div>
<div class="primary-preview-empty" id="primaryPreviewEmpty">Enable matching primary to edit the poster crop.</div>
<div class="primary-preview-hint">Drag to position • Wheel to zoom</div>
<div class="primary-preview-empty" id="primaryPreviewEmpty">Enable this to stamp the selected studio logo onto the existing primary poster.</div>
<div class="primary-preview-hint" id="primaryPreviewHint">No separate poster is generated.</div>
</div>
</div>
@@ -1074,9 +1157,9 @@
<div class="ctrl-group" id="studioPosGroup" style="display:none">
<label>Studio pos</label>
<div class="corner-grid" id="studioCornerGrid">
<button class="corner-btn" data-pos="top-left" title="Top left"></button>
<button class="corner-btn active" data-pos="top-left" title="Top left"></button>
<button class="corner-btn" data-pos="top-right" title="Top right"></button>
<button class="corner-btn active" data-pos="bottom-right" title="Bottom right"></button>
<button class="corner-btn" data-pos="bottom-right" title="Bottom right"></button>
<button class="corner-btn" data-pos="bottom-left" title="Bottom left"></button>
</div>
</div>
@@ -1096,10 +1179,10 @@
</div>
<div class="ctrl-group">
<label>Matching primary</label>
<label>Primary poster</label>
<label class="toggle-chip" for="matchPrimaryToggle">
<input type="checkbox" id="matchPrimaryToggle">
<span>Generate tall primary</span>
<span>Stamp studio logo onto existing poster</span>
</label>
</div>
@@ -1206,6 +1289,7 @@ const state = {
searchLimit: 12,
searchTotal: 0,
searchController: null,
studioKey: null,
categoriesLoaded: false,
};
@@ -1218,6 +1302,10 @@ const resultsList = $('#resultsList');
const resultsFooter = $('#resultsFooter');
const btnPrevPage = $('#btnPrevPage');
const btnNextPage = $('#btnNextPage');
const studioBulkBanner = $('#studioBulkBanner');
const studioBulkLabel = $('#studioBulkLabel');
const studioBulkBtn = $('#studioBulkBtn');
const studioResetBtn = $('#studioResetBtn');
const placeholder = $('#placeholder');
const previewFrame = $('#previewFrame');
const thumbImg = $('#thumbImg');
@@ -1226,6 +1314,9 @@ const primaryPreviewFrame = $('#primaryPreviewFrame');
const primaryPreviewImg = $('#primaryPreviewImg');
const primaryPreviewEmpty = $('#primaryPreviewEmpty');
const primaryPreviewMeta = $('#primaryPreviewMeta');
const primaryPreviewTools = $('#primaryPreviewTools');
const primaryPreviewZoom = $('#primaryPreviewZoom');
const primaryPreviewHint = $('#primaryPreviewHint');
const btnPrimaryReset = $('#btnPrimaryReset');
const btnPrimaryPreviewZoomOut = $('#btnPrimaryPreviewZoomOut');
const btnPrimaryPreviewZoomIn = $('#btnPrimaryPreviewZoomIn');
@@ -1440,9 +1531,12 @@ function updatePrimaryPreviewMeta() {
function setPrimaryPreviewVisible(visible) {
primaryPreviewShell.classList.toggle('visible', visible);
primaryZoomGroup.style.display = visible ? '' : 'none';
primaryPanXGroup.style.display = visible ? '' : 'none';
primaryPanYGroup.style.display = visible ? '' : 'none';
primaryZoomGroup.style.display = 'none';
primaryPanXGroup.style.display = 'none';
primaryPanYGroup.style.display = 'none';
primaryPreviewTools.style.display = 'none';
primaryPreviewZoom.style.display = 'none';
primaryPreviewHint.style.display = visible ? '' : 'none';
}
function syncPrimaryPreviewState() {
@@ -1450,18 +1544,15 @@ function syncPrimaryPreviewState() {
setPrimaryPreviewVisible(show);
if (!show) {
primaryPreviewImg.removeAttribute('src');
primaryPreviewEmpty.textContent = 'Enable matching primary to edit the poster crop.';
primaryPreviewEmpty.textContent = 'Enable this to stamp the selected studio logo onto the existing primary poster.';
primaryPreviewEmpty.style.display = '';
return;
}
if (state.cacheKey && state.primaryGenerated) {
primaryPreviewImg.src = `/api/cache/${state.cacheKey}/primary?t=${Date.now()}`;
primaryPreviewEmpty.style.display = 'none';
} else {
primaryPreviewImg.removeAttribute('src');
primaryPreviewEmpty.textContent = 'Generate to preview the tall poster crop.';
primaryPreviewEmpty.style.display = '';
}
primaryPreviewImg.removeAttribute('src');
primaryPreviewEmpty.textContent = selectedStudio === 'none'
? 'Select a studio to stamp its logo onto the existing primary poster. No separate poster is generated.'
: 'Applying will stamp the selected studio logo onto the existing primary poster. No separate poster is generated.';
primaryPreviewEmpty.style.display = '';
}
let primaryPreviewTimer;
@@ -1558,6 +1649,11 @@ async function doSearch(q, start = 0) {
resultsList.innerHTML = '<div class="empty"><div class="spinner" style="margin:0 auto 0"></div></div>';
resultsToolbar.style.display = 'flex';
resultsFooter.style.display = 'none';
studioBulkBanner.classList.remove('visible');
studioBulkBtn.disabled = false;
studioBulkBtn.textContent = 'Bulk Assign All';
studioResetBtn.disabled = false;
studioResetBtn.textContent = 'Reset All';
resultsCount.textContent = 'Searching...';
resultsPage.textContent = '';
try {
@@ -1570,6 +1666,13 @@ async function doSearch(q, start = 0) {
if (state.searchController !== controller) return;
state.searchTotal = data.total;
state.searchStart = data.start;
state.studioKey = data.studio_key || null;
if (state.studioKey && data.total > 0) {
studioBulkLabel.textContent = `${data.total} show${data.total !== 1 ? 's' : ''} — apply studio thumb to all`;
studioBulkBanner.classList.add('visible');
} else {
studioBulkBanner.classList.remove('visible');
}
if (!data.items.length) {
resultsList.innerHTML = '<div class="empty">No results</div>';
resultsCount.textContent = '0 results';
@@ -1598,6 +1701,7 @@ async function doSearch(q, start = 0) {
if (e.name === 'AbortError') return;
resultsToolbar.style.display = 'none';
resultsFooter.style.display = 'none';
studioBulkBanner.classList.remove('visible');
resultsList.innerHTML = `<div class="empty">Error: ${esc(e.message)}</div>`;
} finally {
if (state.searchController === controller) state.searchController = null;
@@ -1614,6 +1718,59 @@ btnNextPage.addEventListener('click', () => {
doSearch(state.searchQuery, state.searchStart + state.searchLimit);
});
studioResetBtn.addEventListener('click', async () => {
if (!state.studioKey) return;
if (!confirm(`Reset all ${state.searchQuery} thumbs and posters? This deletes custom images and reverts to Emby originals.`)) return;
studioResetBtn.disabled = true;
studioBulkBtn.disabled = true;
studioResetBtn.textContent = 'Resetting…';
try {
const r = await fetch('/api/bulk-reset/studio', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ studio_key: state.studioKey }),
});
const result = await r.json();
if (!r.ok) throw new Error(result?.detail || `${r.status}`);
studioBulkLabel.textContent = `✓ Reset ${result.reset} shows${result.skipped ? `, ${result.skipped} skipped` : ''}`;
studioResetBtn.textContent = 'Done';
} catch (e) {
studioBulkLabel.textContent = `Error: ${esc(e.message)}`;
studioResetBtn.textContent = 'Reset All';
studioResetBtn.disabled = false;
studioBulkBtn.disabled = false;
}
});
studioBulkBtn.addEventListener('click', async () => {
if (!state.studioKey) return;
studioBulkBtn.disabled = true;
studioBulkBtn.textContent = 'Fetching…';
try {
const r = await fetch(`/api/search?q=${encodeURIComponent(state.searchQuery)}&type=Series,Movie&start=0&limit=500`);
const data = await r.json();
if (!r.ok) throw new Error(data?.detail || `${r.status}`);
const ids = data.items.map(it => it.id);
if (!ids.length) throw new Error('No items found.');
studioBulkBtn.textContent = `Applying to ${ids.length}`;
const ar = await fetch('/api/bulk-assign/apply', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ item_ids: ids }),
});
const result = await ar.json();
if (!ar.ok) throw new Error(result?.detail || `${ar.status}`);
const n = result.applied_count ?? (result.applied || []).length;
const sk = result.skipped_missing_assets_count ?? (result.skipped_missing_assets || []).length;
studioBulkLabel.textContent = `✓ Applied to ${n}${sk ? `, skipped ${sk}` : ''}`;
studioBulkBtn.textContent = 'Done';
} catch (e) {
studioBulkLabel.textContent = `Error: ${esc(e.message)}`;
studioBulkBtn.textContent = 'Bulk Assign All';
studioBulkBtn.disabled = false;
}
});
// ── Select item ──
async function selectItem(item) {
// Don't re-select the same item
@@ -1650,6 +1807,7 @@ async function selectItem(item) {
newEpisodesToggle.checked = false;
seasonFinaleToggle.checked = false;
}
setStudioSelection(item.auto_studio || 'none', 'top-left');
// Clear stale image and start generating immediately
thumbImg.src = '';
@@ -1734,22 +1892,34 @@ darknessSlider.addEventListener('input', () => darknessVal.textContent = darknes
// Studio selector
let selectedStudio = 'none';
let studioPos = 'bottom-right';
let studioPos = 'top-left';
function setStudioSelection(studio, position = 'top-left') {
selectedStudio = studio;
studioPos = studio === 'appletv' ? 'top-right' : position;
studioGrid.querySelectorAll('.studio-btn').forEach(btn => {
btn.classList.toggle('active', btn.dataset.studio === selectedStudio);
});
studioPosGroup.style.display = selectedStudio === 'none' ? 'none' : '';
studioCornerGrid.querySelectorAll('.corner-btn').forEach(btn => {
btn.classList.toggle('active', btn.dataset.pos === studioPos);
});
syncPrimaryPreviewState();
}
studioGrid.querySelectorAll('.studio-btn').forEach(btn => {
btn.addEventListener('click', () => {
studioGrid.querySelectorAll('.studio-btn').forEach(b => b.classList.remove('active'));
btn.classList.add('active');
selectedStudio = btn.dataset.studio;
studioPosGroup.style.display = selectedStudio === 'none' ? 'none' : '';
setStudioSelection(btn.dataset.studio, studioPos);
});
});
studioCornerGrid.querySelectorAll('.corner-btn').forEach(btn => {
btn.addEventListener('click', () => {
if (selectedStudio === 'appletv' && btn.dataset.pos !== 'top-right') return;
studioCornerGrid.querySelectorAll('.corner-btn').forEach(b => b.classList.remove('active'));
btn.classList.add('active');
studioPos = btn.dataset.pos;
syncPrimaryPreviewState();
});
});
textColorPicker.addEventListener('input', () => textColorText.value = textColorPicker.value);
@@ -1758,7 +1928,6 @@ newEpisodesToggle.addEventListener('change', () => syncSeriesTagToggles('new'));
seasonFinaleToggle.addEventListener('change', () => syncSeriesTagToggles('finale'));
matchPrimaryToggle.addEventListener('change', () => {
syncPrimaryPreviewState();
if (state.item) generateThumb();
});
primaryZoomSlider.addEventListener('input', schedulePrimaryPreviewRegenerate);
primaryPanXSlider.addEventListener('input', schedulePrimaryPreviewRegenerate);
@@ -1960,13 +2129,7 @@ async function generateThumb({ silent = false } = {}) {
btnRegenerate.disabled = false;
updateBdUI();
if (!silent) {
if (matchPrimaryToggle.checked && primaryGenerated) {
showToast('Generated thumb + primary', 'ok');
} else if (matchPrimaryToggle.checked) {
showToast('Generated thumb', 'ok');
} else {
showToast('Generated', 'ok');
}
showToast('Generated thumb', 'ok');
}
} catch (e) {
if (e.name === 'AbortError') return;
@@ -2025,7 +2188,7 @@ btnApply.addEventListener('click', async () => {
if (!r.ok) throw new Error(await readErrorMessage(r));
const data = await r.json();
if (data.primary_attempted && data.primary_code) {
showToast('Applied thumb + primary poster', 'ok');
showToast('Applied thumb + studio logo to primary', 'ok');
} else if (data.primary_attempted && data.primary_error) {
showToast('Applied thumb only', 'ok');
} else {