Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
node_modules/
.devdata/
# A second dev instance beside the first (another port, another data folder).
.devdata-*/
.dockerdata/
*.log
.DS_Store
Expand Down
66 changes: 66 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,72 @@ changes what your listeners see, it says so.
(libheif and librsvg), music-metadata 11.16.1 (crafted MP4, EBML and DSF files could crash
the scanner — and the scanner reads whatever is dropped on the share). `npm audit` is clean.

### Fixed — things you could do that gave no answer, or the wrong one

- **Remove or delete from an episode's own page now works.** The response re-targeted the
episode table, which only the show page has; on the episode page htmx refused it and the
page went on showing an episode that was gone. Both actions now take you to the show, with
the confirmation, when they were started on the episode page.
- **Check now, Pause, Resume and Stop following on the Subscription page do something you
can see.** They used to post into a redirect the browser swallowed; the page re-reads
itself now and says what happened. Stop following asks first, like every other action
that cannot be undone.
- **A password change is confirmed with a real notice.** The toast arrived as bare text with
a × that threw.
- **A button that is working says so.** Every decision, teach, check, rescan and settings
button is held while its request is out and shows a ring; a second press while one is in
flight is dropped rather than queued. A request that gets no answer at all — offline, a
tunnel that dropped, an extension in the way — now says so instead of failing in silence,
and a session that has run out no longer flashes "Something went wrong" on its way to the
sign-in page.
- **Check now and Teach no longer hold the page for the whole pass.** The panel comes back at
once with a note, and the work strip follows the pass; the plain-form path still waits.
- **A background refresh no longer wipes what you are typing.** The Adverts panel and the
episode's cuts card re-read themselves after every pass, scheduled ones included, and used
to throw away a half-typed boundary and close the settings fold under you. A refresh now
waits while a field inside it is in use, and is taken once it is not; a fold you opened
stays open; and the second render after every decision — the stream announcing what the
response already carried — is gone.
- **The Show page topbar fits a phone**: the actions take a row of their own under the
breadcrumb instead of pushing it onto four lines and "Follow a feed" off the edge.
- **The access log and the statistics tables are readable on a phone**: each row is a block
with its column names, like the episode table already was, rather than a six-column table
scrolling sideways. The column headers stay for screen readers.
- **The scan-progress strip sent over the live stream could be left behind forever** when
the stream dropped mid-scan: the streamed copy omitted the poll the clicked one has. It is
the same strip now.
- "New show" no longer opens with "New show" already typed into the name, and a refused form
keeps what you typed. The upload queue's success line is no longer painted red. The
dashboard is highlighted in the sidebar when you are on it — and `aria-current` on the
sidebar's current item is now a real attribute rather than escaped text. Settings toggles
and inline saves confirm themselves. The cut pill in the episode table links to the
episode page, where the bar always is, rather than to an anchor the Adverts page may have
paged away.

### Changed

- **A date at the start of a filename is the episode's publish date.** `2026-09-01-…`,
`2026_09_01…` or `20260901…` is taken as that day at midnight in `TZ`, unless the file's
modification time already falls on that day, in which case the time of day is kept. Three
dated files copied onto the share together used to land on the one minute they were
copied. Undated files keep the modification time, and a date set on the episode page is
never changed by a rescan. README, *How it finds new episodes*.
- **Colour and size, for people and thumbs.** Primary buttons, accent-coloured text and
selected chips use the darker terracotta (`#B84A1E`, 7.4:1 on white) rather than the one
that fell short of AA for text; the signal colour stays on bars, dots and marks. Muted
grey text that carried information — the "· test" affordance, stat-card hints, timestamps,
label hints — is a shade darker. On a touch screen every control is at least 44px: the
stretch ▶, the toast ×, chips, sign-out, the menu button, the small decision buttons, and
the cut bar gets a taller area to tap without looking any different.
- **Keyboard focus survives a swap.** After saving a setting, sorting the log, restoring an
episode or closing a modal, focus goes back to the control it was on — or to the control
that opened the modal — rather than to the top of the page. Errors are announced as alerts
and stay until dismissed; other notices stay six seconds plus fifty milliseconds a
character, and pausing with the pointer resumes when it leaves. The two Settings switches
have accessible names, card titles are real headings, a refused field says so to assistive
technology, the current breadcrumb is marked, and a refused sign-in puts the cursor on the
password.

## 1.9.1 — 2026-09-16

### Fixed
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ of it can be changed later in **Settings** without touching the container.
|---|---|---|
| `PUBLIC_BASE_URL` | — | The address your proxy serves SelfPod on, e.g. `https://podcast.example.com`. Every feed and media URL is built from it. No trailing slash. Can also be set in the setup wizard. |
| `PUID` / `PGID` | `1000` | The user and group SelfPod runs as. Match the owner of your audio files. |
| `TZ` | `UTC` | Used for displayed dates and an episode's default publish date. |
| `TZ` | `UTC` | Used for displayed dates and an episode's default publish date — see [How it finds new episodes](#how-it-finds-new-episodes). |
| `PORT` | `8080` | Port inside the container. |
| `RESCAN_INTERVAL_SECONDS` | `300` | How often the whole library is re-checked as a fallback. 60–21600. |
| `MISSING_GRACE_SECONDS` | `86400` | How long an episode whose file vanished stays in the feed, so a brief share outage doesn't drop episodes. |
Expand Down Expand Up @@ -471,6 +471,15 @@ shows the current mode. It deliberately does not sit in a banner across every pa
a banner that is always there is a banner nobody reads when something is actually
wrong.

**The publish date** of a new episode comes from its filename when the name starts
with a date — `2026-09-01-episode-one.mp3`, `2026_09_01 …` or `20260901 …` — at
midnight in your `TZ`. Otherwise it is the file's modification time, which is right
for a file that was just recorded and wrong for three dated files copied onto the
share together, which would all land on the minute they were copied. A modification
time that already falls on the named day is kept, because it also carries the time
of day. Either way it is only a starting point: the date you set on the episode page
is never changed by a rescan.

## Security

SelfPod is built to be published to the internet, so the design assumes the address
Expand Down
7 changes: 6 additions & 1 deletion doc/selfpod-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,12 @@ Required behavior:
used only as a *suggested* title if the user hasn't set one, never
silently overwrites a user-edited title on rescan.
- Compute/assign a stable GUID (§7.2).
- Insert into the database with `pub_date` defaulting to file mtime.
- Insert into the database with `pub_date` defaulting to the date the filename
starts with (`YYYY-MM-DD`, with `-`, `_`, `.` or nothing between the parts,
at midnight in `TZ`) when there is one and the file mtime falls on another
day; otherwise to the file mtime. First insert only — a rescan never
rewrites `pub_date`, and a user-set date (`pub_date_is_custom`) is never
touched.
3. For each file previously known but no longer present on disk, mark
the episode `missing` (soft state, not deleted) rather than removing
it from the feed immediately — avoids apps re-downloading/duplicating
Expand Down
16 changes: 16 additions & 0 deletions src/services/ad-pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,22 @@ export function createAdPipeline({
timers.clear();
},

/**
* Resolves once nothing is running or queued.
*
* A pass started from a page is not awaited by the request that started it, so a
* test — or anything else tearing the app down — has to be able to wait for it:
* closing the database under a pass that is half-way through cutting an episode
* is how a test run came to hang at exit. Loops because a pass can queue another.
*/
async idle() {
// eslint-disable-next-line no-unmodified-loop-condition
while (active !== null || waiting.size) {
await chain;
await Promise.allSettled([...waiting.values()]);
}
},

/**
* Everything a show needs, in order: fingerprint, detect, cut, publish.
*
Expand Down
6 changes: 5 additions & 1 deletion src/services/adverts-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,11 @@ export function createAdvertsView({ db, adDetect, transcriber, episodes, shows }
if (data.off) return summaries;
for (const episode of episodes.listByShow(show.id)) {
const state = api.episodeState(episode, api.stretchesOf(episode, data), data);
if (state) summaries.set(episode.id, { ...state, url: `/shows/${encodeURIComponent(show.slug)}/adverts#ep-${episode.id}` });
// The episode's own page, where the same bar is drawn under #episode-cuts. The
// Adverts page used to be the link, with `#ep-<id>` as the anchor — but that
// page shows thirty episodes at a time, so for anything older the anchor was
// not there and the link landed at the top.
if (state) summaries.set(episode.id, { ...state, url: `/shows/${encodeURIComponent(show.slug)}/episodes/${encodeURIComponent(episode.id)}#episode-cuts` });
}
return summaries;
},
Expand Down
45 changes: 42 additions & 3 deletions src/services/scanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
imageMimeType,
isSupportedAudioFile,
} from '../constants.js';
import { nowIso } from '../lib/dates.js';
import { fromLocalInputValue, nowIso, toLocalInputValue } from '../lib/dates.js';
import { EVENTS } from '../lib/events.js';
import { initialPublishHold } from '../lib/publish-hold.js';
import { computeIdentityKey } from '../lib/identity.js';
Expand Down Expand Up @@ -385,7 +385,9 @@ export function createScanner({
mtimeIso = nowIso();
warnings.push({
file: filename,
message: `\`${filename}\` has a modification time SelfPod cannot read, so today's date is used as its publish date. You can set the publish date yourself on the episode page.`,
message: dateInFilename(filename)
? `\`${filename}\` has a modification time SelfPod cannot read, so its publish date is the date its name starts with. You can set the publish date yourself on the episode page.`
: `\`${filename}\` has a modification time SelfPod cannot read, so today's date is used as its publish date. You can set the publish date yourself on the episode page.`,
});
} else {
errors.push(activity.formatFileError(filename, err));
Expand Down Expand Up @@ -566,7 +568,9 @@ export function createScanner({
description: meta.description ?? '',
season: meta.season ?? null,
episode_number: meta.episodeNumber ?? null,
pub_date: mtimeIso,
// First sight only. A rescan never touches pub_date, so a date set on the
// episode page stays, whatever the file or its name says afterwards.
pub_date: publishDateFor(filename, mtimeIso, config.timeZone),
duration_seconds: meta.durationSeconds,
bitrate_kbps: meta.bitrateKbps,
file_size_bytes: stats.size,
Expand Down Expand Up @@ -931,6 +935,41 @@ function returnedFromExpiry(filename) {
return `\`${filename}\` is back after being gone longer than the grace period, so it has returned to the feed with its original episode identity — subscribers keep their played state.`;
}

/**
* The date a filename starts with, as `YYYY-MM-DD` — the same prefix titleFromFilename
* strips, and the one the remote fetcher writes. Null when there is none, or when the
* digits are not a day that exists.
*/
export function dateInFilename(filename) {
const match = String(filename ?? '').match(/^(\d{4})[-_.]?(\d{2})[-_.]?(\d{2})/);
if (!match) return null;
const [, y, m, d] = match;
const probe = new Date(Date.UTC(+y, +m - 1, +d));
if (probe.getUTCFullYear() !== +y || probe.getUTCMonth() !== +m - 1 || probe.getUTCDate() !== +d) return null;
return `${y}-${m}-${d}`;
}

/**
* The publish date an episode gets when it is first seen.
*
* A file named `2026-09-01-…` says when it was published, and that beats the
* modification time: three dated files copied onto the share together all carry the
* moment they were copied, which put them in the feed as one episode on the same
* minute. The name wins unless the modification time already falls on that day — in
* the instance's zone or in UTC — in which case it is kept, because it also carries
* the time of day and the remote fetcher sets it to the exact moment of publication.
* Without a date in the name the modification time is the answer, as it always was.
*/
export function publishDateFor(filename, mtimeIso, timeZone) {
const dated = dateInFilename(filename);
if (!dated) return mtimeIso;
const sameDay =
toLocalInputValue(mtimeIso, { timeZone }).slice(0, 10) === dated ||
String(mtimeIso ?? '').slice(0, 10) === dated;
if (sameDay) return mtimeIso;
return fromLocalInputValue(`${dated}T00:00`, { timeZone }) ?? mtimeIso;
}

/** "2026-08-07-episode-one.m4a" → "Episode One" (a suggestion, never a lock). */
function titleFromFilename(filename) {
const withoutExt = filename.replace(/\.[^.]+$/, '');
Expand Down
Loading