Create: save big collections, say the 200-title limit, more room between boxes

Crunchyroll's 1,567 titles made the save too big for the TV to take in, so Sakura was refused.
The phone now sends only what the TV keeps, stops at 200 titles and says so, and stacked
boxes on Create and other screens have room between them. 0.108.88.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-11-07 13:03:18 +00:00
co-authored by Claude Opus 5.5
parent 3cad392cd5
commit 1bc38e7c86
4 changed files with 28 additions and 14 deletions
+2 -2
View File
@@ -9,8 +9,8 @@ android {
applicationId = "tv.orbit.classic"
minSdk = 26
targetSdk = 36
versionCode = 247
versionName = "0.108.87-mistletoe-sakura"
versionCode = 248
versionName = "0.108.88-big-collections"
}
buildFeatures { compose = true }
// The finished build for the TVs (Paul, 6 November 2026: the test build stuttered on the box). Not debuggable, so
@@ -73,6 +73,12 @@ nav button.on{color:var(--accent);font-weight:700}nav button.on i{background:var
.kbar{position:fixed;left:0;right:0;bottom:calc(64px + env(safe-area-inset-bottom));z-index:3;background:var(--deep);border-top:1px solid var(--surface);padding:10px 16px}
.kbarin{max-width:460px;margin:0 auto}
main.kpad{padding-bottom:230px}
/* Room between stacked boxes (Paul, 7 November 2026: "boxes close together"). */
main .card+.card,main .card+.ch,main .ch+.card,main .card+.label{margin-top:12px}
main.kpad .ch{margin-bottom:10px;padding:13px 16px}
main.kpad .ch .then{white-space:normal}
/* Above Create's action bar, never over its button. */
body:has(main.kpad) .toast{bottom:calc(250px + env(safe-area-inset-bottom))}
.toast{position:fixed;left:50%;bottom:90px;transform:translateX(-50%);background:var(--accent);color:var(--on-accent);padding:9px 16px;border-radius:999px;font-weight:700;font-size:13px;z-index:9;display:none;max-width:90vw;text-align:center}
.empty{color:var(--muted);text-align:center;padding:30px 10px}
</style></head><body>
@@ -268,6 +274,9 @@ const STEPS = ['Shows','Shape','When','Review'];
const VIEWS = {shows: 0, collection: 0, shape: 1, when: 2, review: 3};
const SLOTS = [['Daytime','06:00 to 17:00'],['Evening','17:00 to 22:00'],['Late','22:00 to 06:00']];
const WEEK_HOURS = {Daytime: 77, Evening: 35, Late: 56};
// A channel carries up to 200 titles, as the TV keeps them; past that the phone says so rather than dropping them quietly.
const CHANNEL_MAX = 200;
const titles = n => `${n.toLocaleString()} title${n === 1 ? '' : 's'}`;
const sameHours = (a, b) => JSON.stringify(a ?? null) === JSON.stringify(b ?? null);
const room = () => state.now?.room || 'the TV';
const backArrow = '<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><path d="M15 6l-6 6 6 6"/></svg>';
@@ -289,7 +298,7 @@ function rowTitle(x, on, sub) {
return `<button class="ch" data-ktoggle="${esc(x.id)}"><div class="grow"><div class="what">${esc(x.title)}</div>
<div class="then">${sub ?? `${x.type === 'Movie' ? 'Film' : 'Series'}${x.year ? ' · ' + x.year : ''}${x.reason ? ' · ' + esc(x.reason) : ''}`}</div></div>${tick(on)}</button>`;
}
const chosenNote = () => { const n = state.create.draft.shows.length; return n ? `${n} chosen · <a href="#" data-kseechosen="1" style="color:var(--accent)">see them</a>` : 'Nothing chosen yet'; };
const chosenNote = () => { const n = state.create.draft.shows.length; return n ? `${n} chosen${n >= CHANNEL_MAX ? ', the most a channel carries' : ''} · <a href="#" data-kseechosen="1" style="color:var(--accent)">see them</a>` : 'Nothing chosen yet'; };
function searchBox(placeholder) {
const c = state.create;
return `<div style="display:flex;gap:8px;margin-bottom:12px"><input id="kq" value="${esc(c.query || '')}" placeholder="${placeholder}" enterkeyhint="search"
@@ -301,8 +310,8 @@ function searchResults() {
const label = s => `<div class="label">${s}</div>`;
let h = '';
if (r.collections.length) h += label('Collections') + r.collections.map(k => `<button class="ch" data-kcol="${esc(k.name)}"><div class="grow"><div class="what">${esc(k.name)}</div>
<div class="then">${k.count.toLocaleString()} titles${k.complete ? '' : ' · still being read'}</div></div>${fold(false).replace('M6 9l6 6 6-6', 'M9 6l6 6-6 6')}</button>`).join('');
if (r.networks.length) h += label('Networks and studios') + r.networks.map(k => `<button class="ch" data-knet="${esc(k.name)}"><div class="grow"><div class="what">${esc(k.name)}</div></div><span class="small">${k.count} titles</span></button>`).join('');
<div class="then">${titles(k.count)}${k.complete ? '' : ' · still being read'}</div></div>${fold(false).replace('M6 9l6 6 6-6', 'M9 6l6 6-6 6')}</button>`).join('');
if (r.networks.length) h += label('Networks and studios') + r.networks.map(k => `<button class="ch" data-knet="${esc(k.name)}"><div class="grow"><div class="what">${esc(k.name)}</div></div><span class="small">${titles(k.count)}</span></button>`).join('');
if (r.genres.length) h += label('Genres') + `<div class="chips" style="flex-wrap:wrap">${r.genres.map(g => `<button data-kgenre="${esc(g)}">${esc(g)}</button>`).join('')}</div>`;
if (r.titles.length) h += label('Titles') + r.titles.map(x => rowTitle(x, d.shows.some(y => y.id === x.id))).join('');
if (!h) h = '<div class="empty">Nothing in your library matches that. Try a show, a collection like Crunchyroll, a network or a genre.</div>';
@@ -346,7 +355,7 @@ function create() {
<div class="label">Age</div><div class="chips" style="flex-wrap:wrap">${chip('band', '', 'Any')}${chip('band', 'Kids', 'Kids')}${chip('band', 'Family', 'Family')}${chip('band', 'Teen', 'Teen')}${chip('band', 'Adult', 'Grown-up')}${chip('band', 'Unknown', 'Unrated')}</div></div>` : ''}
${note}${items.slice(0, k.shown || 60).map(x => rowTitle(x, d.shows.some(y => y.id === x.id))).join('')}
${items.length > (k.shown || 60) ? `<button class="btn" data-kmore="1" style="margin:6px 0 10px">Show ${Math.min(60, items.length - (k.shown || 60))} more of ${items.length}</button>` : ''}` +
cBar('Done with this collection', 'data-kcoldone="1"', null, null, `${chosenHere} of these chosen · ${chosenNote()}`);
cBar('Done with this collection', 'data-kcoldone="1"', null, null, `${chosenHere} from here · ${chosenNote()}`);
}
if (c.view === 'shape') return cTop('Shape the day') + shapeView() + note + cBar('Next: when it’s on', 'data-knext="when"', null, null, d.style === 'Shaped' ? '★ comes round more often' : '');
if (c.view === 'when') {
@@ -375,7 +384,7 @@ function shapeView() {
h += `<div class="rm" style="padding:12px 14px"><button data-kfold="${slot}" style="width:100%;text-align:left;display:block">
<div style="display:flex;align-items:center;gap:8px"><b style="font-size:16px">${slot}</b><span class="small">${span}</span><span style="margin-left:auto">${fold(open)}</span></div>
<div style="display:flex;align-items:center;gap:8px;margin-top:8px"><div style="flex:1;height:6px;border-radius:3px;background:var(--deep)"><div style="width:${hrs ? frac * 100 : 0}%;height:100%;border-radius:3px;background:${hrs >= need || !hrs ? 'var(--mint)' : 'var(--accent)'}"></div></div>
<span class="small">${mine.length} titles${hrs ? ' · ' + hrs + ' h' : ''}</span></div></button>
<span class="small">${titles(mine.length)}${hrs ? ' · ' + hrs + ' h' : ''}</span></div></button>
${open ? (mine.length ? mine.map(x => `<div style="display:flex;align-items:center;gap:8px;margin-top:10px">
<button data-ccore="${esc(x.id)}" aria-label="Core" style="font-size:20px;color:${d.core.includes(x.id) ? 'var(--accent)' : 'var(--muted)'}">${d.core.includes(x.id) ? '★' : '☆'}</button>
<div class="grow"><div style="font-weight:700">${esc(x.title)}</div></div>
@@ -500,10 +509,11 @@ async function quickBuild() {
try {
const col = (state.collections || []).find(k => k.name.toLowerCase() === d.description.toLowerCase());
let picks;
if (col) { const r = await api('/api/browse?collection=' + encodeURIComponent(col.name)); picks = r.items.slice(0, 200); c.suggestedName = col.name; }
if (col) { const r = await api('/api/browse?collection=' + encodeURIComponent(col.name)); picks = r.items.slice(0, CHANNEL_MAX); c.suggestedName = col.name;
if (r.items.length > CHANNEL_MAX) c.capNote = `${col.name} has ${titles(r.found)}. A channel carries up to ${CHANNEL_MAX}, so the Director took the first ${CHANNEL_MAX}. Untick any, or build it yourself to choose.`; }
else { picks = await api('/api/suggest?d=' + encodeURIComponent(d.description) + '&chosen=&skipped='); c.suggestedName = suggestName(d.description); }
if (!picks.length) { c.note = 'Nothing in your library fits that yet. Try other words, a collection or a network, or build it yourself.'; c.busy = false; render(); return; }
d.shows = picks; c.quick = true; c.results = null; c.busy = false; goTo('shows');
d.shows = picks; c.quick = true; c.results = null; c.busy = false; goTo('shows'); if (c.capNote) { c.note = c.capNote; c.capNote = ''; render(); }
} catch (e) { c.note = e.message; c.busy = false; render(); }
}
function chosenSheet() {
@@ -570,7 +580,7 @@ async function makeChannel(ending) {
const c = state.create, d = c.draft; if (c.busy) return;
d.name = ($('#kname')?.value || d.name || '').trim(); if (!d.name) { toast('Give it a name first'); return; }
c.busy = true; render();
try { const r = await api('/api/channels', {number: d.number, name: d.name, description: d.description, style: d.style, hours: d.hours, shows: d.shows,
try { const r = await api('/api/channels', {number: d.number, name: d.name, description: d.description, style: d.style, hours: d.hours, shows: d.shows.map(x => ({id: x.id, title: x.title, year: x.year ?? null, type: x.type})),
slots: d.style === 'Shaped' ? d.slots : undefined, core: d.style === 'Shaped' ? d.core : undefined, season: d.season || null,
brand: d.brand !== undefined ? d.brand : undefined});
c.done = {number: r.number, name: d.name, message: r.message, edit: !!d.number}; c.busy = false; render(); load('more');
@@ -688,6 +698,7 @@ document.addEventListener('click', e => {
if (d.ksearch) { runSearch(); return; }
if (d.ktoggle) { const dr = state.create.draft, id = d.ktoggle, c = state.create;
if (dr.shows.some(x => x.id === id)) dr.shows = dr.shows.filter(x => x.id !== id);
else if (dr.shows.length >= CHANNEL_MAX) toast(`A channel carries up to ${CHANNEL_MAX} titles`);
else { const x = [...(c.results?.titles || []), ...(c.col?.items || [])].find(x => x.id === id); if (x) dr.shows.push(x); }
render(); return; }
if (d.kcol) { openCollection(d.kcol); return; }
@@ -697,7 +708,10 @@ document.addEventListener('click', e => {
api('/api/browse?genre=' + encodeURIComponent(d.kgenre)).then(items => { c.results = {collections: [], networks: [], genres: [], titles: items}; c.query = d.kgenre; }).catch(e => c.note = e.message).finally(() => { c.busy = false; render(); }); return; }
if (d.kaddall) { const c = state.create, rf = c.col.refine;
const items = c.col.items.filter(x => (!rf.type || x.type === rf.type) && (!rf.band || x.band === rf.band));
items.forEach(x => { if (!c.draft.shows.some(y => y.id === x.id)) c.draft.shows.push(x); }); toast(`Added ${items.length}`); render(); return; }
const fresh = items.filter(x => !c.draft.shows.some(y => y.id === x.id)), room = Math.max(0, CHANNEL_MAX - c.draft.shows.length);
fresh.slice(0, room).forEach(x => c.draft.shows.push(x));
c.note = fresh.length > room ? `A channel carries up to ${CHANNEL_MAX} titles, so ${room ? `the first ${room} of these ${fresh.length.toLocaleString()} were added` : 'none more could be added'}. Refine to Shows, Films or an age to choose a different ${CHANNEL_MAX}.` : '';
toast(`Added ${Math.min(room, fresh.length)}`); render(); return; }
if (d.krefine) { state.create.col.refineOpen = !state.create.col.refineOpen; render(); return; }
if (d.kref) { const cut = d.kref.indexOf(':'), k = d.kref.slice(0, cut), v = d.kref.slice(cut + 1); state.create.col.refine[k] = v; render(); return; }
if (d.kmore) { state.create.col.shown = (state.create.col.shown || 60) + 60; render(); return; }
@@ -62,9 +62,9 @@ internal class HttpsEmbyTransport(internal val deviceId: String = UUID.randomUUI
}
/** The sign-in headers for this kind of server. */
internal fun authHeaders(token: String?): Map<String, String> = when (kind) {
ServerKind.Emby -> mapOf("X-Emby-Authorization" to "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.87\"") +
ServerKind.Emby -> mapOf("X-Emby-Authorization" to "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.88\"") +
(token?.let { mapOf("X-Emby-Token" to it) } ?: emptyMap())
ServerKind.Jellyfin -> mapOf("Authorization" to "MediaBrowser Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.87\"" +
ServerKind.Jellyfin -> mapOf("Authorization" to "MediaBrowser Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.88\"" +
(token?.let { ", Token=\"$it\"" } ?: ""))
}
/** One picture from the provider, or nothing. Same fixed origin and no redirects, and failures are never shown or logged. */
@@ -39,7 +39,7 @@ internal class SecureMediaDataSource(private val session: EmbySampleSession) : B
next.instanceFollowRedirects = false
next.connectTimeout = 10_000
next.readTimeout = 20_000
next.setRequestProperty("User-Agent", "OrbitTV/0.108.87")
next.setRequestProperty("User-Agent", "OrbitTV/0.108.88")
next.setRequestProperty("Accept-Encoding", "identity")
session.mediaHeaders(address).forEach { (key, value) -> next.setRequestProperty(key, value) }
if (dataSpec.position != 0L || dataSpec.length != C.LENGTH_UNSET.toLong()) {