diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts
index 4b0456f3..2fb0705a 100644
--- a/android/app/build.gradle.kts
+++ b/android/app/build.gradle.kts
@@ -9,8 +9,8 @@ android {
applicationId = "tv.orbit.classic"
minSdk = 26
targetSdk = 36
- versionCode = 245
- versionName = "0.108.85-smart-setup-v2"
+ versionCode = 246
+ versionName = "0.108.86-create-v3"
}
buildFeatures { compose = true }
// The finished build for the TVs (Paul, 6 November 2026: the test build stuttered on the box). Not debuggable, so
diff --git a/android/app/src/main/assets/phone/companion.html b/android/app/src/main/assets/phone/companion.html
index 896769f7..3be90507 100644
--- a/android/app/src/main/assets/phone/companion.html
+++ b/android/app/src/main/assets/phone/companion.html
@@ -70,6 +70,9 @@ nav div{max-width:460px;margin:0 auto;display:flex}
nav button{flex:1;display:flex;flex-direction:column;align-items:center;gap:3px;padding:6px 0;font-size:11px;color:var(--muted)}
nav button i{display:flex;align-items:center;justify-content:center;width:46px;height:28px;border-radius:999px}
nav button.on{color:var(--accent);font-weight:700}nav button.on i{background:var(--surface)}
+.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}
.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}
@@ -229,111 +232,199 @@ function rooms() {
return h;
}
function more() {
+ // More, reorganised (design/companion/build-create-v3.py): who's watching as faces, what needs you with a count, your
+ // channels as tiles, and settings as a short list.
const yours = state.channels, pr = state.profiles, kids = pr?.current?.kind === 'Kids';
- const who = pr ? `
Who's watching
${pr.profiles.map(p => ``).join('')}
-
${pr.current ? esc(pr.current.name) + ' is watching on the TV.' : 'Nobody chosen yet on the TV.'}${kids ? ' Making channels and the Director are for Adult.' : ''}
` : '';
- if (kids) return head('More') + who + `
About
Orbit Companion runs on the TV itself, over your home Wi-Fi. It works while Orbit is open on the TV.
`;
- return head('More') + who + `
Director's Chair
-
-
Your channels
- ${(yours?.channels || []).map(c => `
${c.number}${c.on ? 'On' : 'Off'}
-
${esc(c.name)}
${esc(c.styleTitle)} · ${esc(c.hoursLabel)}
-
`).join('')}
- ${!yours || yours.next ? '' : '
Every number from 701 to 799 is taken.
'}
- ${standalone() ? '' : ''}
-
Look
-
- ${(state.looks || []).map(l => ``).join('')}
-
Following the TV, each room's remote wears that room's look. Pick one to keep it on this phone instead, whatever the TV is set to.
-
About
Orbit Companion runs on the TV itself, over your home Wi-Fi. Nothing to install, no account. It works while Orbit is open on the TV.
- To stop this phone, remove it in Settings › Rooms and phones.
`;
+ const colours = ['#45B8F5', '#FF4FA3', '#6EDCAA', '#FFB347', '#B98CFF'];
+ let h = head('More');
+ if (pr) h += `
`;
+ const line = (label, value, attr, first) => ``;
+ h += `
Settings
+ ${line('Look', keptLook() ? esc(keptLook()) : 'Follows the TV', 'data-klook="1"', true)}
+ ${standalone() ? '' : line('Add to home screen', '', 'data-home="1"')}
+ ${line('About Orbit Companion', '', 'data-kabout="1"')}
`;
+ return h;
}
-// Create a channel (phase 3, from design/companion v2): five steps, Name, Shows, Style, Hours and Review, in the TV's look.
-// It saves through the same route as before, so the TV makes it exactly as Settings › Create your own does.
-const STYLES = [['Shaped','Shaped by the Director',"Recommended. Daytime, evening and late, like Orbit's own channels, with your core shows more often"],['Standard','Standard TV',"Shows take turns all day, episodes in order"],['Shuffled','Shuffled','Episodes in a mixed order, every one before any repeats'],
+// Create a channel, refined (Paul, 7 November 2026, design/companion/build-create-v3.py): start quick (the Director builds it)
+// or custom; one search for titles, collections, networks and genres; a collection page; the day in folding parts; and a
+// review where anything can be changed and two endings that never interrupt what's on. Long lists scroll; the action bar
+// stays at the foot and picks are kept. It saves through the same route as before.
+const STYLES = [['Shaped','Shaped by the Director',"Daytime, evening and late, like Orbit's own channels, with your core shows more often"],['Standard','Standard TV',"Shows take turns all day, episodes in order"],['Shuffled','Shuffled','Episodes in a mixed order, every one before any repeats'],
['Blocks','Blocks','A timetable: each show at its own times, every day'],['Marathon','Marathon','One show at a time, several episodes back to back']];
const HOURS = [[null,'All day'],[{from:18,to:0},'Evenings, 18:00 to midnight'],[{from:6,to:12},'Mornings, 06:00 to noon'],[{from:9,to:17},'Daytime, 09:00 to 17:00']];
-const STEPS = ['Name','Shows','Style','Hours','Review'];
+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};
const sameHours = (a, b) => JSON.stringify(a ?? null) === JSON.stringify(b ?? null);
+const room = () => state.now?.room || 'the TV';
+const backArrow = '';
+const fold = open => ``;
+const tick = on => `${on ? '✓' : ''}`;
+
+function cTop(title) {
+ const c = state.create, i = VIEWS[c.view];
+ const bar = i === undefined ? '' : `
${STEPS.map((n, k) => `
+
${n}
`).join('')}
`;
+ return `${esc(title)}` + bar;
+}
+// The action bar: fixed above the tabs, so the next step is always in reach however long the list.
+function cBar(primary, attr, secondary, attr2, note) {
+ return `
${note ? `
${note}
` : ''}
+
${secondary ? `` : ''}
`;
+}
+function rowTitle(x, on, sub) {
+ return ``;
+}
+const chosenNote = () => { const n = state.create.draft.shows.length; return n ? `${n} chosen · see them` : 'Nothing chosen yet'; };
+function searchBox(placeholder) {
+ const c = state.create;
+ return `
+
`;
+}
+function searchResults() {
+ const c = state.create, r = c.results, d = c.draft; if (!r) return '';
+ const label = s => `
${s}
`;
+ let h = '';
+ if (r.collections.length) h += label('Collections') + r.collections.map(k => ``).join('');
+ if (r.networks.length) h += label('Networks and studios') + r.networks.map(k => ``).join('');
+ if (r.genres.length) h += label('Genres') + `
${r.genres.map(g => ``).join('')}
`;
+ 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 = '
Nothing in your library matches that. Try a show, a collection like Crunchyroll, a network or a genre.
';
+ return h;
+}
+
function create() {
const c = state.create, d = c.draft;
- if (c.done) return `
Your Emby collections show here once Orbit has read them.
'}
- ${c.colInfo ? `
${c.colInfo.found} of ${c.colInfo.total} in ${esc(c.collection)} are in your library copy.${c.colInfo.complete ? '' : ' This collection is bigger than Orbit has read so far; the rest arrive as the library is read.'}
-
${c.mode === 'browse' ? 'Matching titles in your library, newest first.' : 'The Director suggests these from what you described and the shows you chose.'} Tap to add.
` : '');
- next = ``;
- } else if (c.step === 2) {
- body = `
How it plays
It shapes what's planned from then on, never what's already booked.
` +
- STYLES.map(([k, t, l]) => ``).join('') + '
';
- // Shaped: the Director's layout, to change. Tap a show to move it to the next slot; the star marks a core show.
- if (d.style === 'Shaped') {
- const sh = c.shape;
- // A film channel's stars are yours: the Director only suggests (Paul, 7 November 2026).
- if (sh?.suggestedCore?.length && !d.core.length) body += `
The Director would star ${sh.suggestedCore.map(id => esc(d.shows.find(x => x.id === id)?.title || '')).join(', ')} to come round more often.
-
`;
- if (sh && !Object.keys(d.slots).length) body += `
The Director's layout
Your picks are all one kind, so they play all day rather than being split into daytime, evening and late. ★ Core shows still come round more often.
${esc(STYLES.find(s => s[0] === d.style)[1])}: ${esc(STYLES.find(s => s[0] === d.style)[2])}. Change the style on Review.
`;
+ if (!sh) return '
The Director is laying out the day…
';
+ let h = '';
+ if (sh.suggestedCore?.length && !d.core.length && !c.coreSet) h += `
The Director would star ${sh.suggestedCore.map(id => esc(d.shows.find(x => x.id === id)?.title || '')).join(', ')} to come round more often.
+
`;
+ if (!Object.keys(d.slots).length) return h + `
Your picks are all one kind, so they play all day rather than being split into daytime, evening and late.
` +
+ d.shows.map(x => `
${esc(x.title)}
`).join('');
+ h += `
The Director balanced this for you. Open a part of the day to star a show or move it.${sh.notes?.length ? ' ' + esc(sh.notes.slice(0, 2).join(' ')) : ''}
`;
+ const hoursOf = id => (sh.runHours || {})[id] || 0;
+ for (const [slot, span] of SLOTS) {
+ const mine = d.shows.filter(x => (d.slots[x.id] || 'Evening') === slot), open = c.open?.[slot];
+ const hrs = Math.round(mine.reduce((a, x) => a + hoursOf(x.id), 0)), need = WEEK_HOURS[slot], frac = Math.min(1, hrs / (need * 3));
+ h += `
+ ${open ? (mine.length ? mine.map(x => `
+
+
${esc(x.title)}
+
`).join('')
+ : '
Nothing here: these hours share the daytime and evening shows.
') : ''}
`;
+ }
+ return h;
+}
+
+function reviewView() {
+ const c = state.create, d = c.draft, sh = c.shape;
+ const style = STYLES.find(s => s[0] === d.style)[1].replace(' by the Director', '');
+ const hours = HOURS.find(([h]) => sameHours(h, d.hours))?.[1]?.split(',')[0] || 'All day';
+ const pillBtn = (label, attr) => ``;
+ let h = cTop('Review') + `
Nothing changes on ${esc(room())} until you say. Create channel saves it and starts planning. Create & watch next switches to it after the programme on now.
`;
+ return h + `
+
`;
+}
+
+function doneView() {
+ const c = state.create, k = c.done;
+ return `
✓
+
${esc(k.name)} is ready on ${k.number}
+
${esc(k.message || '')}
+ ${c.watching ? `
${esc(c.watching)}
` : ''}
+ ${k.queued ? '' : ``}
+
`;
+}
+
// Who's watching (phase 3): Kids goes straight in; Adult asks for the PIN on the phone when one's set, as the TV does.
async function switchTo(id, pin) {
buzz();
@@ -374,7 +465,47 @@ function seasonPicker() {
${w ? `
From ${sel('fromDay', 31, w.fromDay)} ${sel('fromMonth', 12, w.fromMonth)} to ${sel('toDay', 31, w.toDay)} ${sel('toMonth', 12, w.toMonth)}
` : ''}
${sug && !w ? `
The Director suggests ${esc(sug.label)}, as most of these are Christmas titles.
` : ''}`;
}
-function startCreate(draft) { draft.slots = draft.slots || {}; draft.core = draft.core || []; state.create = {step: 0, draft, offered: [], note: '', busy: false, mode: 'describe', browse: {type: '', genre: '', studio: '', rating: ''}, shape: null}; render(); }
+function startCreate(draft) {
+ draft.slots = draft.slots || {}; draft.core = draft.core || [];
+ state.create = {view: draft.number ? 'shows' : 'start', draft, results: null, query: '', busy: false, note: '', shape: null, open: {}, quick: false,
+ tries: (state.collections || []).slice(0, 2).map(k => k.name).concat(['Cosy Christmas films']).slice(0, 3)};
+ render(); scrollTo(0, 0);
+ if (!state.collections) api('/api/collections').then(r => { state.collections = r.collections; if (state.create?.view === 'start') { const typed = $('#kdesc'); if (typed) state.create.draft.description = typed.value; state.create.tries = r.collections.slice(0, 2).map(k => k.name).concat(['Cosy Christmas films']); render(); } }).catch(() => {});
+}
+// Name the Director suggests: the collection's own name, or the description in a few words.
+const suggestName = text => text.replace(/\s+/g, ' ').trim().split(' ').slice(0, 3).map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' ').slice(0, 40);
+function goTo(view) { const c = state.create; c.view = view; c.note = ''; render(); scrollTo(0, 0);
+ if (view === 'shape' || (view === 'review' && !c.shape) || view === 'when') shapeShows(); if (view === 'review') checkClashes(); }
+async function runSearch() {
+ const c = state.create; c.query = ($('#kq')?.value || '').trim(); if (c.query.length < 2 || c.busy) return;
+ c.busy = true; render();
+ try { c.results = await api('/api/search?q=' + encodeURIComponent(c.query)); } catch (e) { c.note = e.message; }
+ c.busy = false; render();
+}
+async function openCollection(name) {
+ const c = state.create; c.busy = true; c.view = 'collection'; c.col = {name, refine: {type: '', band: ''}, items: [], shown: 60}; c.suggestedName = c.suggestedName || name; render(); scrollTo(0, 0);
+ try { const r = await api('/api/browse?collection=' + encodeURIComponent(name)); Object.assign(c.col, {items: r.items, complete: r.complete, total: r.total, found: r.found}); }
+ catch (e) { c.note = e.message; }
+ c.busy = false; render();
+}
+// Quick: the Director picks. A collection named in the description is taken whole; otherwise its suggestions.
+async function quickBuild() {
+ const c = state.create, d = c.draft; d.description = ($('#kdesc')?.value || '').trim(); if (!d.description || c.busy) return;
+ c.busy = true; render();
+ 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; }
+ 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');
+ } catch (e) { c.note = e.message; c.busy = false; render(); }
+}
+function chosenSheet() {
+ const d = state.create.draft;
+ openSheet(`
${d.shows.length} chosen
${d.shows.map(x => `
${esc(x.title)}
+
`).join('')}
`);
+}
// Smart setup: what the library has to browse by, and the Director's layout for the chosen shows.
async function loadFacets() {
if (!state.facets) try { state.facets = await api('/api/facets'); } catch (e) { state.create.note = e.message; }
@@ -430,13 +561,16 @@ async function watchNew(when) {
}
c.trying = false; if (c.watching === 'Planning its first programmes…') c.watching = "It's still planning. Try again in a minute, or find it in the Guide."; render();
}
-async function makeChannel() {
- const c = state.create, d = c.draft; if (c.busy) return; c.busy = true; render();
+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,
slots: d.style === 'Shaped' ? d.slots : undefined, core: d.style === 'Shaped' ? d.core : undefined, season: d.season || null});
- // Made: offer to watch it now, or straight after the programme on the TV (Paul, 7 November 2026).
- c.done = {number: r.number, name: d.name, message: r.message, edit: !!d.number}; c.busy = false; render(); load('more'); }
- catch (e) { c.note = e.message; c.busy = false; render(); }
+ c.done = {number: r.number, name: d.name, message: r.message, edit: !!d.number}; c.busy = false; render(); load('more');
+ // Create & watch next: queued for after the programme on now, never interrupting it (Paul, 7 November 2026).
+ if (ending === 'next') { await watchNew('next'); }
+ } catch (e) { c.note = e.message; c.busy = false; render(); }
}
// The Director's Chair on the phone (phase 3): Drive-In event ideas to approve, defer or dismiss, and titles to place on a
@@ -479,7 +613,7 @@ function offerHome() {
}
function render() {
tabs();
- $('#app').className = tab === 'remote' ? 'fit' : '';
+ $('#app').className = tab === 'remote' ? 'fit' : tab === 'more' && state.create ? 'kpad' : '';
$('#app').innerHTML = tab === 'more' && state.create ? create() : tab === 'more' && state.chair ? director() : ({remote, guide, catchup, rooms, more})[tab]();
}
function openSheet(html) { $('#sheetIn').innerHTML = html; $('#sheet').classList.add('open'); $('#shade').classList.add('open'); }
@@ -493,7 +627,8 @@ async function load(what) {
if (what === 'catchup') state.catchup = await api('/api/catchup');
if (what === 'rooms') state.rooms = await api('/api/rooms');
if (what === 'more') { const [l, c, p] = await Promise.all([api('/api/looks'), api('/api/channels').catch(() => null), api('/api/profiles').catch(() => null)]);
- state.looks = l.looks; state.channels = c; state.profiles = p; look(state.now?.look); }
+ state.looks = l.looks; state.channels = c; state.profiles = p; look(state.now?.look);
+ if (p?.current?.kind !== 'Kids') api('/api/director').then(r => { state.directorCount = r.ready ? r.ideas.filter(i => i.decision !== 'approved').length + r.choices.length : 0; if (tab === 'more' && !state.create && !state.chair) render(); }).catch(() => {}); }
if (what === 'director') state.director = await api('/api/director');
offline = false;
} catch (e) { if (!offline) toast(e.message === 'Failed to fetch' ? "Orbit isn't open on the TV" : e.message); offline = true; }
@@ -503,12 +638,20 @@ async function load(what) {
let offline = false;
const send = (path, body, done) => { buzz(); api(path, body).then(j => { done?.(j); setTimeout(() => load('now'), 600); }).catch(e => toast(e.message === 'Failed to fetch' ? "Orbit isn't open on the TV" : e.message)); };
+document.addEventListener('keydown', e => {
+ if (e.key !== 'Enter') return;
+ if (e.target.id === 'kq') { e.preventDefault(); runSearch(); }
+ if (e.target.id === 'kdesc') { e.preventDefault(); quickBuild(); }
+});
document.addEventListener('change', e => {
+ const mv = e.target.dataset?.kmove;
+ if (mv && state.create) { const c = state.create; c.draft.slots[mv] = e.target.value; c.moved = {...(c.moved || {}), [mv]: true}; render(); return; }
const k = e.target.dataset?.cseason; if (!k || !state.create?.draft.season) return;
state.create.draft.season[k] = +e.target.value; render();
});
document.addEventListener('click', e => {
- const b = e.target.closest('button,[data-tab]'); if (!b) return;
+ const b = e.target.closest('button,[data-tab],a[data-kseechosen],a[data-kusename]'); if (!b) return;
+ if (b.tagName === 'A') e.preventDefault();
const d = b.dataset;
if (d.tab) { if (d.tab !== 'more' || tab === 'more') { state.create = null; state.chair = false; } tab = d.tab; try { localStorage.setItem('orbit.tab', tab); } catch {} closeSheet(); render(); if (tab !== 'remote') load(tab); return; }
if (d.key) send('/api/key', {key: d.key});
@@ -516,7 +659,7 @@ document.addEventListener('click', e => {
if (d.ch) send('/api/channel', {step: +d.ch});
if (d.sheet) openSheet(moreControls());
if (d.go) send('/api/section', {section: d.go}, () => { closeSheet(); toast('On the TV now'); });
- if (d.look !== undefined) { try { d.look ? localStorage.setItem('orbit.look', d.look) : localStorage.removeItem('orbit.look'); } catch {} look(state.now?.look); render(); return; }
+ if (d.look !== undefined) { closeSheet(); try { d.look ? localStorage.setItem('orbit.look', d.look) : localStorage.removeItem('orbit.look'); } catch {} look(state.now?.look); render(); return; }
if (d.director) { state.chair = true; state.director = null; render(); load('director'); return; }
if (d.chairback) { state.chair = false; render(); return; }
if (d.idea) { const cut = d.idea.lastIndexOf(':'), signature = d.idea.slice(0, cut), decision = d.idea.slice(cut + 1); send('/api/director/idea', {signature, decision}, j => { toast(j.message); load('director'); }); return; }
@@ -524,6 +667,44 @@ document.addEventListener('click', e => {
if (d.drop) { send('/api/director/drop', {id: d.drop}, j => { toast(j.message); state.director.choices = state.director.choices.filter(c => c.id !== d.drop); render(); }); return; }
if (d.profile) { switchTo(d.profile); return; }
if (d.pinok) { switchTo(d.pinok, $('#pin').value); return; }
+ if (d.kback) { const c = state.create, v = c.view;
+ if (v === 'start' || (v === 'shows' && c.draft.number)) state.create = null;
+ else if (v === 'collection') c.view = 'shows'; else if (v === 'shows') c.view = c.draft.number ? 'shows' : 'start';
+ else c.view = {shape: 'shows', when: 'shape', review: 'when'}[v];
+ render(); scrollTo(0, 0); return; }
+ if (d.klook) { openSheet(`
Look
Following the TV, each room's remote wears that room's look. Pick one to keep it on this phone instead.
+
+ ${(state.looks || []).map(l => ``).join('')}
`); return; }
+ if (d.kabout) { openSheet(`
Orbit Companion
It runs on the TV itself, over your home Wi-Fi: nothing to install, no account. It works while Orbit is open on the TV. To stop this phone, remove it in Settings › Rooms and phones on the TV.
`); return; }
+ if (d.kquick) { quickBuild(); return; }
+ if (d.ktry) { $('#kdesc').value = d.ktry; quickBuild(); return; }
+ if (d.kcustom) { const c = state.create; c.quick = false; c.view = 'shows'; render(); setTimeout(() => $('#kq')?.focus(), 50); return; }
+ 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 { 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; }
+ if (d.knet) { const c = state.create; c.busy = true; render();
+ api('/api/browse?studio=' + encodeURIComponent(d.knet)).then(items => { c.results = {collections: [], networks: [], genres: [], titles: items}; c.query = d.knet; }).catch(e => c.note = e.message).finally(() => { c.busy = false; render(); }); return; }
+ if (d.kgenre) { const c = state.create; c.busy = true; render();
+ 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; }
+ 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; }
+ if (d.kcoldone) { state.create.view = 'shows'; render(); scrollTo(0, 0); return; }
+ if (d.knext) { goTo(d.knext); return; }
+ if (d.kfold) { const c = state.create; c.open = {...c.open, [d.kfold]: !c.open?.[d.kfold]}; render(); return; }
+ if (d.kgo) { state.create.draft.name = ($('#kname')?.value || state.create.draft.name || '').trim(); goTo(d.kgo); return; }
+ if (d.kstyles) { const c = state.create; c.draft.name = ($('#kname')?.value || c.draft.name || '').trim(); c.styleOpen = !c.styleOpen; render(); return; }
+ if (d.kstyle) { const c = state.create; c.draft.name = ($('#kname')?.value || c.draft.name || '').trim(); c.draft.style = d.kstyle; c.styleOpen = false; render(); if (d.kstyle === 'Shaped') shapeShows(); return; }
+ if (d.kusename) { state.create.draft.name = state.create.suggestedName; render(); return; }
+ if (d.kseechosen) { chosenSheet(); return; }
+ if (d.kunpick) { const dr = state.create.draft; dr.shows = dr.shows.filter(x => x.id !== d.kunpick); chosenSheet(); render(); return; }
+ if (d.kmake) { makeChannel(d.kmake); return; }
if (d.create) { startCreate({name: '', description: '', style: 'Shaped', hours: null, shows: [], skipped: []}); return; }
if (d.edit) { const ch = state.channels?.channels.find(x => x.number === +d.edit); if (!ch) return;
api('/api/shows?number=' + ch.number).then(shows => {
diff --git a/android/app/src/main/java/tv/orbit/classic/CatalogueStore.kt b/android/app/src/main/java/tv/orbit/classic/CatalogueStore.kt
index b1dd731a..88ec5a9e 100644
--- a/android/app/src/main/java/tv/orbit/classic/CatalogueStore.kt
+++ b/android/app/src/main/java/tv/orbit/classic/CatalogueStore.kt
@@ -187,6 +187,15 @@ internal class CatalogueStore(context: Context, private val file: File) : Catalo
buildList { while (c.moveToNext()) add(ShapeRow(c.getString(0), c.getString(1), c.getString(2), if (c.isNull(3)) null else c.getInt(3), c.getString(4), c.getString(5).split('|').filter { it.isNotBlank() }.toSet())) }
}
}
+ /** Networks and studios whose names contain [text], with how many titles each has: for Create's one search. Read only. */
+ @Synchronized fun studiosMatching(text: String, limit: Int = 5): List> {
+ val q = text.trim().take(60); if (q.length < 2) return emptyList()
+ val counts = HashMap()
+ readableDatabase.rawQuery("SELECT studios FROM items WHERE type IN ('Movie','Series') AND studios LIKE ?", arrayOf("%$q%")).use { c ->
+ while (c.moveToNext()) c.getString(0).split('|').filter { it.contains(q, ignoreCase = true) }.forEach { counts.merge(it, 1, Int::plus) }
+ }
+ return counts.entries.sortedByDescending { it.value }.take(limit).map { it.key to it.value }
+ }
/** Films' running times by item, for Smart setup's hours estimate. Read only. */
@Synchronized fun runTimes(ids: Collection): Map = ids.distinct().chunked(400).flatMap { chunk ->
readableDatabase.rawQuery("SELECT id, runtime_ms FROM items WHERE runtime_ms IS NOT NULL AND id IN (${chunk.joinToString(",") { "?" }})", chunk.toTypedArray()).use { c ->
diff --git a/android/app/src/main/java/tv/orbit/classic/CreateChannel.kt b/android/app/src/main/java/tv/orbit/classic/CreateChannel.kt
index 1d954549..f4314f26 100644
--- a/android/app/src/main/java/tv/orbit/classic/CreateChannel.kt
+++ b/android/app/src/main/java/tv/orbit/classic/CreateChannel.kt
@@ -56,7 +56,9 @@ internal class ChannelMaker(
/** Your Emby collections, for Browse › From a collection: each one's name, members and whether all of them were read. */
val collections: suspend () -> List = { emptyList() },
/** Titles by item from the catalogue alone, quickly, for listing a collection. */
- val rowsOf: suspend (List) -> List = { emptyList() })
+ val rowsOf: suspend (List) -> List = { emptyList() },
+ /** Networks and studios by name, with their title counts. */
+ val studios: suspend (String) -> List> = { emptyList() })
/** One of the library's collections as Orbit read it. [complete] is false when it stopped short of [total]. */
internal class LibraryCollection(val name: String, val members: List, val total: Int, val complete: Boolean)
diff --git a/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt b/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt
index c89f52e5..396a8bcc 100644
--- a/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt
+++ b/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt
@@ -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 = when (kind) {
- ServerKind.Emby -> mapOf("X-Emby-Authorization" to "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.85\"") +
+ ServerKind.Emby -> mapOf("X-Emby-Authorization" to "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.86\"") +
(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.85\"" +
+ ServerKind.Jellyfin -> mapOf("Authorization" to "MediaBrowser Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.86\"" +
(token?.let { ", Token=\"$it\"" } ?: ""))
}
/** One picture from the provider, or nothing. Same fixed origin and no redirects, and failures are never shown or logged. */
diff --git a/android/app/src/main/java/tv/orbit/classic/EmbyConnectionScreen.kt b/android/app/src/main/java/tv/orbit/classic/EmbyConnectionScreen.kt
index 7c8a7897..81ffa6dd 100644
--- a/android/app/src/main/java/tv/orbit/classic/EmbyConnectionScreen.kt
+++ b/android/app/src/main/java/tv/orbit/classic/EmbyConnectionScreen.kt
@@ -553,6 +553,7 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea
} },
collections = { withContext(Dispatchers.IO) { readCollections(scheduleStore.collectionsFile()) } },
rowsOf = { ids -> withContext(Dispatchers.IO) { catalogue.shapeRows(ids) } },
+ studios = { text -> withContext(Dispatchers.IO) { catalogue.studiosMatching(text) } },
runTime = { rows -> rows.takeIf { r -> r.isNotEmpty() && r.all { it.runMs != null } }?.sumOf { it.runMs ?: 0L } },
carriedBy = { picks, number -> titlesCarriedBy(picks, scheduledChannels.values.filter { it.number != number }) },
create = { asked, shows ->
diff --git a/android/app/src/main/java/tv/orbit/classic/PhoneLink.kt b/android/app/src/main/java/tv/orbit/classic/PhoneLink.kt
index c0afb1d7..f2e79da1 100644
--- a/android/app/src/main/java/tv/orbit/classic/PhoneLink.kt
+++ b/android/app/src/main/java/tv/orbit/classic/PhoneLink.kt
@@ -310,6 +310,20 @@ internal object PhoneLink {
val (genres, studios) = runBlocking { h.maker.facets() }
json(out, 200, JSONObject().put("genres", JSONArray(genres)).put("studios", JSONArray(studios)).put("ratings", JSONArray(RatingGroups.keys.toList())))
}
+ // Create's one search (Paul, 7 November 2026: "search could include the collections"): titles, collections, networks
+ // and genres together.
+ "GET /api/search" -> {
+ val q = r.query["q"].orEmpty().trim().take(80)
+ if (q.length < 2) return json(out, 200, JSONObject().put("collections", JSONArray()).put("networks", JSONArray()).put("genres", JSONArray()).put("titles", JSONArray()))
+ val cols = runBlocking { h.maker.collections() }.filter { it.name.contains(q, ignoreCase = true) }.sortedBy { !it.name.startsWith(q, ignoreCase = true) }.take(5)
+ val nets = runBlocking { h.maker.studios(q) }
+ val genres = runBlocking { h.maker.facets() }.first.filter { it.contains(q, ignoreCase = true) }.take(4)
+ val titles = runBlocking { h.maker.search(q) }.take(20)
+ json(out, 200, JSONObject()
+ .put("collections", JSONArray(cols.map { c -> JSONObject().put("name", c.name).put("count", c.members.size).put("total", c.total).put("complete", c.complete) }))
+ .put("networks", JSONArray(nets.map { (n, k) -> JSONObject().put("name", n).put("count", k) })).put("genres", JSONArray(genres))
+ .put("titles", JSONArray(titles.map(::suggestionJson))))
+ }
"GET /api/collections" -> {
val all = runBlocking { h.maker.collections() }
json(out, 200, JSONObject().put("collections", JSONArray(all.map { c -> JSONObject().put("name", c.name).put("count", c.members.size).put("total", c.total).put("complete", c.complete) })))
@@ -319,7 +333,7 @@ internal object PhoneLink {
val c = runBlocking { h.maker.collections() }.firstOrNull { it.name == r.query["collection"] } ?: return json(out, 404, JSONObject().put("error", "That collection isn't in the library copy yet."))
val rows = runBlocking { h.maker.rowsOf(c.members.take(1000)) }
json(out, 200, JSONObject().put("complete", c.complete).put("total", c.total).put("found", rows.size).put("items", JSONArray(rows.map { row -> suggestionJson(Suggestion(row.id, row.title, row.year, row.type, "",
- listOfNotNull(row.genres.take(2).joinToString(", ").ifEmpty { null }, row.rating.ifEmpty { null }).joinToString(" · ").ifEmpty { "In ${c.name}" })) })))
+ listOfNotNull(row.genres.take(2).joinToString(", ").ifEmpty { null }, row.rating.ifEmpty { null }).joinToString(" · ").ifEmpty { "In ${c.name}" })).put("band", ratingBand(row.rating).name) })))
} else {
val rows = runBlocking { h.maker.browse(r.query["genre"]?.take(60), r.query["studio"]?.take(80), RatingGroups[r.query["rating"]].orEmpty(), r.query["type"]?.takeIf { it == "Movie" || it == "Series" }) }
json(out, 200, JSONArray(rows.map { row -> suggestionJson(Suggestion(row.id, row.title, row.year, row.type, "",
@@ -340,7 +354,8 @@ internal object PhoneLink {
.put("suggestedCore", JSONArray(shape.suggestedCore.toList())).put("notes", JSONArray(shape.notes))
.put("suggestedSeason", shape.suggestedSeason?.let { it.toJson().put("label", it.label) } ?: JSONObject.NULL)
.put("week", total?.takeIf { it > 0 }?.let { weekLine(it, hoursPerDay) } ?: weekCheck(series, films) ?: JSONObject.NULL)
- .put("hours", total?.let { it / 3_600_000.0 } ?: JSONObject.NULL))
+ .put("hours", total?.let { it / 3_600_000.0 } ?: JSONObject.NULL)
+ .put("runHours", JSONObject(rows.filter { it.runMs != null }.associate { it.id to it.runMs!! / 3_600_000.0 })))
}
"POST /api/clashes" -> {
val o = runCatching { JSONObject(r.body) }.getOrNull() ?: return json(out, 400, JSONObject())
diff --git a/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt b/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt
index 7b9e1aea..1297da74 100644
--- a/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt
+++ b/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt
@@ -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.85")
+ next.setRequestProperty("User-Agent", "OrbitTV/0.108.86")
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()) {
diff --git a/android/app/src/test/java/tv/orbit/classic/PhoneLinkTest.kt b/android/app/src/test/java/tv/orbit/classic/PhoneLinkTest.kt
index f5a4f302..587c55fd 100644
--- a/android/app/src/test/java/tv/orbit/classic/PhoneLinkTest.kt
+++ b/android/app/src/test/java/tv/orbit/classic/PhoneLinkTest.kt
@@ -258,10 +258,19 @@ class PhoneLinkTest {
val rows = listOf(ShapeRow("a1", "Series", "Bluey", 2018, "TV-Y", setOf("Animation")), ShapeRow("a2", "Series", "Line of Duty", 2012, "TV-MA", setOf("Drama")))
PhoneLink.handler = PhoneHandler(ChannelMaker({ _, _, _ -> emptyList() }, { emptyList() }, { c, s -> made = c to s; "${c.name} is ready" }, { emptyList() },
browse = { genre, _, ratings, _ -> rows.filter { genre == null || genre in it.genres }.filter { ratings.isEmpty() || it.rating in ratings } },
- facets = { listOf("Drama", "Animation") to listOf("BBC One") }, shapeOf = { ids -> rows.filter { it.id in ids } }), { false }, { })
+ facets = { listOf("Drama", "Animation") to listOf("BBC One") }, shapeOf = { ids -> rows.filter { it.id in ids } },
+ collections = { listOf(LibraryCollection("Crunchyroll", listOf("a1"), 1567, false)) }, rowsOf = { ids -> rows.filter { it.id in ids } },
+ studios = { q -> listOf("Crunchyroll" to 15).filter { it.first.contains(q, ignoreCase = true) } }), { false }, { })
val cookie = joinedCookie()
assertEquals("Drama", JSONObject(call("/api/facets", cookie = cookie).body).getJSONArray("genres").getString(0))
assertEquals(1, JSONArray(call("/api/browse?rating=Kids", cookie = cookie).body).length())
+ // One search finds the collection and the network by name (Paul: "it didn't find crunchyroll").
+ val found = JSONObject(call("/api/search?q=crunch", cookie = cookie).body)
+ assertEquals("Crunchyroll", found.getJSONArray("collections").getJSONObject(0).getString("name"))
+ assertFalse(found.getJSONArray("collections").getJSONObject(0).getBoolean("complete"))
+ assertEquals(15, found.getJSONArray("networks").getJSONObject(0).getInt("count"))
+ val members = JSONObject(call("/api/browse?collection=Crunchyroll", cookie = cookie).body)
+ assertEquals("Kids", members.getJSONArray("items").getJSONObject(0).getString("band")); assertFalse(members.getBoolean("complete"))
val shape = JSONObject(call("/api/shape", "POST", """{"ids":["a1","a2"]}""", cookie = cookie).body)
assertEquals("Daytime", shape.getJSONObject("slots").getString("a1")); assertEquals("Late", shape.getJSONObject("slots").getString("a2"))
assertFalse(shape.isNull("week")) // two shows: it says so