Podcasts shelf: your podcasts as their artwork (#474)

A place beside Up Next listing every feed with audio or video as a grid of
its artwork, with how many episodes are new, as Overcast's home screen
does. It is drawn from the feed list the page already holds; the feed list
gains `podcast`, an EXISTS per subscription over enclosures, which stops at
a podcast's first episode and is one index probe for a feed with no files.
Its cost on production's database is not measured: the EXPLAIN was not run.

The iOS app's generated messages (ios/Sources/Wire) are not regenerated:
there is no protoc here. Nothing in the app reads the new fields, and a
proto3 reader skips a field it does not know.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 14:37:53 +00:00
parent c65b80a06c
commit 1fb1edd6b0
11 changed files with 77 additions and 5 deletions

View File

@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- A feed in `/api/feeds` says whether it has audio or video (`podcast`), for the page's Podcasts shelf (#474).
- Up Next, a queue of episodes kept per account so every device shares it: `GET /api/queue` lists it in order, `PUT /api/queue` sets it, and an episode leaves it once it is 90% played (#473).
- The API answers in protobuf as well as JSON: a client that sends `Accept: application/x-protobuf` gets protobuf, and one that sends `Content-Type: application/x-protobuf` may send its body so; JSON stays the default for a client that does not ask, and an answer of null stays JSON. The messages are in `crates/wire/proto/ipx.proto`. ipx's own calls to the directory and ipx-play go in protobuf too, so both need their protobuf releases first. Answers and those calls go through structs generated from the `.proto` files, about four times quicker to read than the JSON (#465, #470).
- Sharing an episode gives a link to its page on ipx-play, which anyone can open and play, set up in Admin, Directory, Sharing episodes; private and paid feeds still share their own address (#447).

View File

@@ -611,6 +611,16 @@ impl Db {
),
vec![user_id.into(), one()],
);
// Whether a feed has any audio or video, for the Podcasts shelf (#474). EXISTS, so a podcast
// stops at its first episode, and a feed with no files is one probe of enclosures_entry.
let media = counts(
"media",
"SELECT sub.feed_id, CAST(1 AS BIGINT) AS n FROM subscriptions sub
WHERE sub.user_id = $1 AND (CAST($2 AS TEXT) IS NULL OR sub.feed_id = $2)
AND EXISTS (SELECT 1 FROM enclosures x WHERE x.feed_id = sub.feed_id
AND (lower(x.mime) LIKE 'audio/%' OR lower(x.mime) LIKE 'video/%'))",
vec![user_id.into(), one()],
);
let blocked = Instrument::instrument(
blocklists::Entity::find().filter(blocklists::Column::UserId.eq(user_id)).all(&self.orm),
step("blocked"),
@@ -620,10 +630,11 @@ impl Db {
rows = rows.filter(feeds::Column::Id.eq(id));
}
let rows = Instrument::instrument(rows.all(&self.orm), step("feeds"));
let (entries, downloaded, unread, blocked, rows) = tokio::try_join!(
let (entries, downloaded, unread, media, blocked, rows) = tokio::try_join!(
entries,
downloaded,
unread,
media,
async { blocked.await.map_err(anyhow::Error::from) },
async { rows.await.map_err(anyhow::Error::from) },
)?;
@@ -649,6 +660,7 @@ impl Db {
ttl_mins: f.ttl_mins.map(|t| t.max(0) as u64),
blocked: blocked.remove(&id).unwrap_or_default(),
unread: unread.get(&id).copied().unwrap_or(0),
podcast: media.contains_key(&id),
};
(id, listing)
})
@@ -663,6 +675,8 @@ pub struct FeedListing {
pub ttl_mins: Option<u64>,
pub blocked: Vec<String>,
pub unread: i64,
/// It has an audio or video file, so it is on the Podcasts shelf (#474).
pub podcast: bool,
}
/// Everything `fetch` needs to decide whether to poll a feed, and how.
@@ -3639,12 +3653,15 @@ mod tests {
INSERT INTO entries (feed_id, guid, first_seen) VALUES ('f','a',0),('f','b',0),('f','c',0),('g','d',0),('h','e',0);
INSERT INTO entry_state (user_id, feed_id, guid, read) VALUES (1,'f','a',true),(2,'f','b',true);
INSERT INTO hidden (user_id, feed_id, guid) VALUES (1,'f','c');
INSERT INTO enclosures (id, feed_id, guid, url, path, state) VALUES
(1,'f','a','u1','/tmp/a','done'),(2,'f','b','u2',null,'pending');
INSERT INTO enclosures (id, feed_id, guid, url, path, state, mime) VALUES
(1,'f','a','u1','/tmp/a','done','Audio/MPEG'),(2,'f','b','u2',null,'pending',null),
(3,'g','d','u3',null,'skipped','image/jpeg');
INSERT INTO blocklists (user_id, feed_id, words) VALUES (1,'g','[\"spoiler\"]');",
).await
.unwrap();
let list = db.feed_list(1, None).await.unwrap();
// On the Podcasts shelf by having sound, whatever the case of its type; a picture is not (#474).
assert!(list["f"].podcast && !list["g"].podcast);
let g = db.feed_list(1, Some("g")).await.unwrap();
assert_eq!(g.keys().collect::<Vec<_>>(), ["g"]);
assert_eq!(

View File

@@ -1004,6 +1004,8 @@ struct FeedRow {
private: bool,
/// Private whatever it is marked, for a login or an address with a key in it.
private_by_address: bool,
/// Has an audio or video file: on the Podcasts shelf (#474).
podcast: bool,
}
#[derive(Serialize)]
@@ -1052,7 +1054,8 @@ async fn feed_rows(state: &WebState, user: &crate::db::User, only: Option<&str>)
let up = feed.group.as_deref().and_then(|g| mine.get(g));
let Some(mine) = mine.get(id) else { continue };
// A feed not scanned yet has no row: blank, as feed_summary gave it.
let crate::db::FeedListing { summary: s, ttl_mins, blocked, unread } = listed.remove(id).unwrap_or_default();
let crate::db::FeedListing { summary: s, ttl_mins, blocked, unread, podcast } =
listed.remove(id).unwrap_or_default();
out.push(FeedRow {
private: feed.private,
private_by_address: crate::directory::looks_private(&crate::config::Feed {
@@ -1115,6 +1118,7 @@ async fn feed_rows(state: &WebState, user: &crate::db::User, only: Option<&str>)
kept: kept.contains(id),
hide_from_all: hidden.contains(id),
hide_from_signals: quiet.contains(id),
podcast,
});
}
Ok(out)

View File

@@ -134,6 +134,8 @@ message FeedRow {
bool hide_from_signals = 32;
bool private = 33;
bool private_by_address = 34;
// Has an audio or video file: on the Podcasts shelf (#474).
bool podcast = 35;
}
// GET /api/feeds.