diff --git a/internal/reader/rss/adapter.go b/internal/reader/rss/adapter.go index 07d56059..134f15b2 100644 --- a/internal/reader/rss/adapter.go +++ b/internal/reader/rss/adapter.go @@ -123,11 +123,13 @@ func (r *RSSAdapter) BuildFeed(baseURL string) *model.Feed { // Populate entry categories. entry.Tags = append(entry.Tags, item.Categories...) entry.Tags = append(entry.Tags, item.MediaCategories.Labels()...) - entry.Tags = append(entry.Tags, r.rss.Channel.Categories...) - entry.Tags = append(entry.Tags, r.rss.Channel.GetItunesCategories()...) + if len(entry.Tags) == 0 { + entry.Tags = append(entry.Tags, r.rss.Channel.Categories...) + entry.Tags = append(entry.Tags, r.rss.Channel.GetItunesCategories()...) - if r.rss.Channel.GooglePlayCategory.Text != "" { - entry.Tags = append(entry.Tags, r.rss.Channel.GooglePlayCategory.Text) + if r.rss.Channel.GooglePlayCategory.Text != "" { + entry.Tags = append(entry.Tags, r.rss.Channel.GooglePlayCategory.Text) + } } feed.Entries = append(feed.Entries, entry) diff --git a/internal/reader/rss/parser_test.go b/internal/reader/rss/parser_test.go index 8d84e582..83e844cb 100644 --- a/internal/reader/rss/parser_test.go +++ b/internal/reader/rss/parser_test.go @@ -1890,11 +1890,11 @@ func TestParseEntryWithCategories(t *testing.T) { t.Fatal(err) } - if len(feed.Entries[0].Tags) != 3 { - t.Errorf("Incorrect number of tags, got: %d", len(feed.Entries[0].Tags)) + if len(feed.Entries[0].Tags) != 2 { + t.Fatalf("Incorrect number of tags, got: %d", len(feed.Entries[0].Tags)) } - expected := []string{"Category 1", "Category 2", "Category 3"} + expected := []string{"Category 1", "Category 2"} result := feed.Entries[0].Tags for i, tag := range result {