Add JSON Feed support

- Detect JSON Feed format (jsonfeed.org) via version field
- Parse JSON Feed metadata and items
- Support application/feed+json MIME type for feed discovery
- Include "json" as valid feed type (not auto-denied)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
primal
2026-01-29 13:16:50 -05:00
parent 798f79bfe9
commit ad78c1a4c0
3 changed files with 158 additions and 4 deletions
+6 -2
View File
@@ -178,12 +178,12 @@ type Feed struct {
// saveFeed stores a feed in PostgreSQL
func (c *Crawler) saveFeed(feed *Feed) error {
// Default publishStatus to "held" if not set
// Auto-deny feeds with no language or non-RSS/Atom type
// Auto-deny feeds with no language or unsupported type
publishStatus := feed.PublishStatus
if publishStatus == "" {
if feed.Language == "" {
publishStatus = "deny"
} else if feed.Type != "rss" && feed.Type != "atom" {
} else if feed.Type != "rss" && feed.Type != "atom" && feed.Type != "json" {
publishStatus = "deny"
} else {
publishStatus = "held"
@@ -779,6 +779,8 @@ func (c *Crawler) processFeed(feedURL, sourceHost, body string, headers http.Hea
items = c.parseRSSMetadata(body, feed)
case "atom":
items = c.parseAtomMetadata(body, feed)
case "json":
items = c.parseJSONFeedMetadata(body, feed)
}
// Refine category based on parsed title (e.g., "Comments on:")
@@ -951,6 +953,8 @@ func (c *Crawler) CheckFeed(feed *Feed) (bool, error) {
items = c.parseRSSMetadata(body, feed)
case "atom":
items = c.parseAtomMetadata(body, feed)
case "json":
items = c.parseJSONFeedMetadata(body, feed)
}
// Content changed - reset backoff