Directory: file a show under its iTunes subcategory where it has one

Apple puts every tabletop and gaming show under Leisure, so the top level
alone put most of this server's podcasts behind one chip. Games says what
they are; a show with no subcategory keeps its top-level one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-15 16:20:49 +00:00
parent 954173cacf
commit 017cfd7e28
2 changed files with 6 additions and 3 deletions

View File

@@ -13,7 +13,8 @@ The long form, with what was wrong before and how it was found, is in
### Added ### Added
- Directory has a row of chips above it: Podcasts, Blogs, and once Podcasts is picked, each - Directory has a row of chips above it: Podcasts, Blogs, and once Podcasts is picked, each
podcast's own iTunes category. Picking one filters the Directory in place. podcast's own iTunes category, the narrower one where a show gives two (Games, not Leisure).
Picking one filters the Directory in place.
### Changed ### Changed

View File

@@ -538,10 +538,12 @@ fn from_rss(ch: rss::Channel, bytes: &[u8]) -> ParsedFeed {
.map(str::to_owned) .map(str::to_owned)
.or_else(|| ch.image().map(|i| i.url().to_owned())), .or_else(|| ch.image().map(|i| i.url().to_owned())),
// Only the iTunes one: Apple's list is fixed, while a plain <category> is freeform and // Only the iTunes one: Apple's list is fixed, while a plain <category> is freeform and
// would fill the Directory with one-off tags. The top level only, for the same reason. // would fill the Directory with one-off tags. The subcategory where there is one: Apple
// files every tabletop and gaming show under Leisure, which says little; Games says it.
category: ch category: ch
.itunes_ext() .itunes_ext()
.and_then(|i| i.categories().first()) .and_then(|i| i.categories().first())
.map(|c| c.subcategory().filter(|s| !s.text().trim().is_empty()).unwrap_or(c))
.and_then(|c| non_empty(Some(c.text().trim()))), .and_then(|c| non_empty(Some(c.text().trim()))),
entries, entries,
} }
@@ -717,7 +719,7 @@ mod tests {
assert_eq!(feed.title.as_deref(), Some("Test Cast")); assert_eq!(feed.title.as_deref(), Some("Test Cast"));
assert_eq!(feed.ttl_mins, Some(45)); assert_eq!(feed.ttl_mins, Some(45));
assert_eq!(feed.category.as_deref(), Some("Technology"), "the first, top level only"); assert_eq!(feed.category.as_deref(), Some("Podcasting"), "the first, by its subcategory");
assert_eq!(feed.entries.len(), 3); assert_eq!(feed.entries.len(), 3);
let ep = &feed.entries[0]; let ep = &feed.entries[0];