A podcast told in seasons can be listed one season at a time (#482)

GET /api/feeds/{id}/seasons counts a podcast's episodes and unread by
season, from the same FROM as its list, so a count is what picking it
shows; season= on its entries narrows the list to one, or to the
episodes naming none. The page puts the seasons under the tabs, as the
tabs' own track, when a podcast is told in them: two or more, holding
most of its episodes. That leaves out Ken and Robin, whose "seasons" are
years on a quarter of 767 episodes, and The Vintage RPG Podcast's 2 of
366. Listed all together by date, a heading marks where each season
starts.

A fixture podcast in seasons is in the browser suite, which now
configures six feeds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RqkrVAJFkEgz9cXG3jG1Zy
This commit is contained in:
2026-11-19 09:04:57 -05:00
parent 9ece0ff17c
commit a57820a078
17 changed files with 329 additions and 22 deletions

View File

@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- A podcast told in seasons has a season picker under its tabs, to list one season at a time or the episodes in none, and listed all together, newest or oldest first, each season's start is marked (#482).
- Smart playlists, in a folder of their own in the feed list: choose the podcasts, which of them play first, unplayed episodes only or all, newest or oldest first, and the playlist keeps itself up to date. Playing from one goes on through it once Up Next is empty (#476).
- Now Playing: tap the player bar to see what is playing with its artwork large, its podcast (a tap opens it), its show notes and what follows in Up Next; Esc or the bar closes it (#475).
- Podcasts: your podcasts as a shelf of their artwork, each with how many episodes are new; the search box narrows it, and a tap opens one (#474).

View File

@@ -989,6 +989,13 @@ kbd{font:inherit;font-size:12px;color:var(--fg);background:var(--panel2);border:
.tabs button.on{background:var(--raise);color:var(--fg);font-weight:500}
.tabs a{padding:5px 12px;border-radius:7px;font-size:13px;color:var(--dim);text-decoration:none}
.tabs a.on{background:var(--raise);color:var(--fg);font-weight:500}
/* A podcast's seasons (#482): the tabs' track, scrolled sideways when there are more than fit. */
.tabs.seasons{max-width:100%;overflow-x:auto;scrollbar-width:none}
.tabs.seasons::-webkit-scrollbar{display:none}
.tabs.seasons button{white-space:nowrap;flex:none}
/* Where a season starts in the list of every season. */
.sdiv{padding:14px 8px 5px;font-size:12px;font-weight:600;letter-spacing:.05em;text-transform:uppercase;color:var(--dim);border-bottom:1px solid var(--line)}
.sdiv:first-child{padding-top:4px}
/* ---------- the admin page (admin.html) ---------- */
/* One column that scrolls under the same header, rather than the app's fixed panes. */
@@ -1539,6 +1546,8 @@ body:has(#player.on) #status{padding-bottom:3px}
.tabs{flex:1 1 100%;border-radius:10px;padding:2px}
.tabs button,.tabs a{flex:1;text-align:center;padding:7px 4px;border-radius:8px;font-size:14px}
.tabs button.on,.tabs a.on{box-shadow:0 1px 3px rgba(0,0,0,.22)}
/* Seasons keep their own widths, scrolling past the edge, rather than squeezing eight into 390px. */
.tabs.seasons button{flex:none;padding:7px 12px}
/* Rows: taller, larger type, and a hairline between them that starts where the text does. */
.ep{padding:10px 8px;border-radius:10px;min-height:44px}

View File

@@ -29,7 +29,7 @@ const WEB_VERSION = JSON.parse(fs.readFileSync(path.join(here, '..', 'package.js
// The files are one script, concatenated in this order, not modules: they share one top-level
// scope, as the single inline script did, and code that runs at load needs what came before it.
const PAGES: Record<string, { script: string, src: string[] }> = {
'index.html': { script: 'app.js', src: ['util', 'wire', 'theme', 'feeds', 'feedpage', 'items', 'player', 'upnext', 'nowplaying', 'dialogs', 'signals', 'playlists', 'gestures', 'offline', 'events', 'native'] },
'index.html': { script: 'app.js', src: ['util', 'wire', 'theme', 'feeds', 'feedpage', 'items', 'seasons', 'player', 'upnext', 'nowplaying', 'dialogs', 'signals', 'playlists', 'gestures', 'offline', 'events', 'native'] },
'admin.html': { script: 'admin.js', src: ['util', 'wire', 'theme', 'admin'] },
'login.html': { script: 'login.js', src: ['login'] },
};

View File

@@ -99,6 +99,8 @@ function renderFeed(){
renderFeed(); loadEntries();
});
if(f) wireFailBanner(box,f);
// An OPML's page is many podcasts' episodes together, their seasons each their own.
if(f&&!kids.length) loadSeasons(f);
}
/// The item table's headings, each a button that sorts by its column. The first click goes the

View File

@@ -202,7 +202,7 @@ function renderFeeds(){
done();
}
function selectFeed(id: string){
S.feed=id; S.offset=0; S.sel=null; S.q=''; $<HTMLInputElement>('#epSearch').value='';
S.feed=id; S.offset=0; S.sel=null; S.q=''; S.season=''; $<HTMLInputElement>('#epSearch').value='';
try{ localStorage.setItem('ipx.feed',id); }catch{}
renderFeeds(); renderFeed(); loadEntries();
}

View File

@@ -14,10 +14,13 @@ const lists=new Map<string,ListPage>();
const LISTS_KEPT=40;
/// Lists on their way, so a click on one already being fetched ahead waits for that answer.
const fetching=new Map<string,Promise<ListPage>>();
const listKey=(feed: string, filter=S.filter)=>[feed,filter,S.sort.col,S.sort.dir,S.q].join('\n');
// A season is of the podcast open (#482): another feed's list, fetched ahead, is of every season.
const seasonFor=(feed: string)=>feed===S.feed?S.season:'';
const listKey=(feed: string, filter=S.filter)=>[feed,filter,S.sort.col,S.sort.dir,S.q,seasonFor(feed)].join('\n');
function listUrl(feed: string, filter=S.filter, offset=0){
const p=new URLSearchParams({offset:String(offset),limit:String(LIMIT),filter,sort:S.sort.col,dir:S.sort.dir});
if(S.q) p.set('q',S.q);
if(seasonFor(feed)) p.set('season',seasonFor(feed));
const sg=signalId(feed);
return feed===':all' ? `/api/entries?${p}`
: sg!==null ? `/api/signals/${sg}/entries?${p}`
@@ -155,7 +158,14 @@ function renderEntries(){
else if(sg&&S.filter==='all') box.innerHTML='<p class="empty">Nothing has come through yet. New items are read as your feeds are checked.</p>';
return;
}
for(const e of S.entries) box.appendChild(epEl(e));
const breaks=seasonBreaks();
let last: number|null|undefined;
S.entries.forEach((e,i)=>{
if(breaks&&(i===0||(e.season??null)!==(last??null)))
box.insertAdjacentHTML('beforeend',`<div class="sdiv" role="heading" aria-level="3">${seasonName(e.season)}</div>`);
last=e.season;
box.appendChild(epEl(e));
});
syncPlayButtons();
if(pane) pane.scrollTop=top;
if(hasMore()){

50
web/src/seasons.ts Normal file
View File

@@ -0,0 +1,50 @@
/* ---------------- seasons (#482) ---------------- */
/// A podcast's seasons, by feed id, as its page last fetched them, so going back to it draws its
/// picker at once while the counts are asked for again.
const seasonsOf=new Map<string,SeasonCount[]>();
/// Whether a podcast is told in seasons: two or more of them, holding most of its episodes. A few
/// numbered among hundreds (The Vintage RPG Podcast's 2 of 366), or years given as seasons on a
/// quarter of them (Ken and Robin's), are no seasons worth a picker.
function seasonsShown(list: SeasonCount[]|undefined): boolean{
if(!list) return false;
const numbered=list.filter(s=>s.season!=null);
const inOne=numbered.reduce((n,s)=>n+s.episodes,0), all=list.reduce((n,s)=>n+s.episodes,0);
return numbered.length>=2 && inOne*2>=all;
}
/// What the picker sends for a season: its number, or `none` for the episodes that name none.
const seasonKey=(s: SeasonCount)=>s.season==null?'none':String(s.season);
const seasonName=(s: number|null|undefined)=>s==null?'Other episodes':`Season ${s}`;
/// The picker, under the tabs: every season, one of them, or the episodes naming none.
function seasonsHTML(list: SeasonCount[]): string{
const chip=(key: string,label: string,title: string)=>
`<button data-season="${key}" class="${S.season===key?'on':''}" aria-pressed="${S.season===key}" title="${title}">${label}</button>`;
return `<div class="tabs seasons" role="group" aria-label="Seasons">${chip('','All seasons','Every season')}${
list.map(s=>chip(seasonKey(s),s.season==null?'Other':`Season ${s.season}`,
`${plural(s.episodes,'episode')}, ${s.unread} unread`)).join('')}</div>`;
}
function drawSeasons(f: Feed, list: SeasonCount[]|undefined){
const bar=$('#content .toolbar'); if(!bar||S.feed!==f.id) return;
bar.querySelector('.seasons')?.remove();
if(!list||!seasonsShown(list)) return;
bar.insertAdjacentHTML('beforeend',seasonsHTML(list));
$$<HTMLButtonElement>('.seasons button',bar).forEach(b=>b.onclick=()=>{
S.season=b.dataset.season!; S.offset=0;
renderFeed(); loadEntries();
});
// The dividers in the list wait on knowing the podcast is told in seasons.
if(S.entries.length) renderEntries();
}
/// A podcast's seasons onto its page: kept ones at once, then the server's.
async function loadSeasons(f: Feed){
drawSeasons(f,seasonsOf.get(f.id));
try{
const got: SeasonCount[]=await api(`/api/feeds/${encodeURIComponent(f.id)}/seasons`);
seasonsOf.set(f.id,got);
drawSeasons(f,got);
}catch{}
}
/// Where a season starts in the list, said above its first episode: only for every season at
/// once, newest or oldest first, where the episodes run season by season.
function seasonBreaks(): boolean{
return !S.season && S.sort.col==='published' && seasonsShown(seasonsOf.get(S.feed ?? ''));
}

View File

@@ -141,6 +141,9 @@ interface State {
/// Whether the server has more after the last page it sent, by that answer's own numbers.
more: boolean;
filter: string;
/// One season of the open podcast (#482): its number, `none` for the episodes naming none, or
/// empty for every season.
season: string;
q: string;
/// The selected item's guid.
sel: string | null;
@@ -148,6 +151,14 @@ interface State {
sort: {col: string, dir: 'asc' | 'desc'};
}
/// One season of a podcast, `/api/feeds/{id}/seasons` (db.rs SeasonCount, #482). No season is
/// the episodes that name none.
interface SeasonCount {
season?: number | null;
episodes: number;
unread: number;
}
/// A smart playlist, `/api/playlists` (db.rs PlaylistRow, #476).
interface Playlist {
id: number;

View File

@@ -345,7 +345,7 @@ const S: State = {
feed:(()=>{ try{ return localStorage.getItem('ipx.feed'); }catch{ return null; } })(),
entries:[], total:0, offset:0, more:false,
filter:(()=>{ try{ return localStorage.getItem('ipx.filter'); }catch{ return null; } })()||'all',
q:'', sel:null, me:null,
season:'', q:'', sel:null, me:null,
// The item table's order, kept across visits. The server sorts: a list arrives fifty at a time.
sort:(()=>{ try{ return JSON.parse(localStorage.getItem('ipx.sort')??'null'); }catch{ return null; } })()
||{col:'published',dir:'desc'},