Skip to content

Commit

Permalink
fix: missing parsed feed properties causing panic
Browse files Browse the repository at this point in the history
  • Loading branch information
CondensedMilk7 authored and guyfedwards committed Jan 8, 2023
1 parent 0855432 commit 13cc59e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions internal/rss/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,16 @@ func Fetch(feedURL string) (RSS, error) {
items := make([]Item, 0)
for _, it := range feed.Items {
ni := Item{
Title: it.Title,
Link: it.Link,
Description: it.Description,
Author: it.Author.Name,
Title: it.Title,
Link: it.Link,
}
if it.Description != "" {
ni.Description = it.Description
}
if it.Author != nil {
if it.Author.Name != "" {
ni.Author = it.Author.Name
}
}
if it.Content == "" {
// If there's no content (as is the case for YouTube RSS items), fallback
Expand All @@ -86,7 +92,6 @@ func Fetch(feedURL string) (RSS, error) {
} else {
ni.Content = it.Content
}

// TODO: support multiple categories
if len(it.Categories) > 0 {
ni.Category = it.Categories[0]
Expand All @@ -101,7 +106,6 @@ func Fetch(feedURL string) (RSS, error) {
pd = pubDate{pt}
}
ni.PubDate = pd

items = append(items, ni)
}
rss := RSS{}
Expand Down

0 comments on commit 13cc59e

Please sign in to comment.