diff --git a/internal/reader/media/media.go b/internal/reader/media/media.go
index 7fe4684d..a4b7d8af 100644
--- a/internal/reader/media/media.go
+++ b/internal/reader/media/media.go
@@ -13,11 +13,12 @@ var textLinkRegex = regexp.MustCompile(`(?mi)(\bhttps?:\/\/[-A-Z0-9+&@#\/%?=~_|!
// Specs: https://www.rssboard.org/media-rss
type MediaItemElement struct {
- MediaGroups []Group `xml:"http://search.yahoo.com/mrss/ group"`
- MediaContents []Content `xml:"http://search.yahoo.com/mrss/ content"`
- MediaThumbnails []Thumbnail `xml:"http://search.yahoo.com/mrss/ thumbnail"`
- MediaDescriptions DescriptionList `xml:"http://search.yahoo.com/mrss/ description"`
- MediaPeerLinks []PeerLink `xml:"http://search.yahoo.com/mrss/ peerLink"`
+ MediaCategories MediaCategoryList `xml:"http://search.yahoo.com/mrss/ category"`
+ MediaGroups []Group `xml:"http://search.yahoo.com/mrss/ group"`
+ MediaContents []Content `xml:"http://search.yahoo.com/mrss/ content"`
+ MediaThumbnails []Thumbnail `xml:"http://search.yahoo.com/mrss/ thumbnail"`
+ MediaDescriptions DescriptionList `xml:"http://search.yahoo.com/mrss/ description"`
+ MediaPeerLinks []PeerLink `xml:"http://search.yahoo.com/mrss/ peerLink"`
}
// AllMediaThumbnails returns all thumbnail elements merged together.
@@ -173,3 +174,20 @@ func (dl DescriptionList) First() string {
}
return ""
}
+
+type MediaCategoryList []MediaCategory
+
+func (mcl MediaCategoryList) Labels() []string {
+ var labels []string
+ for _, category := range mcl {
+ label := strings.TrimSpace(category.Label)
+ if label != "" {
+ labels = append(labels, label)
+ }
+ }
+ return labels
+}
+
+type MediaCategory struct {
+ Label string `xml:"label,attr"`
+}
diff --git a/internal/reader/rss/adapter.go b/internal/reader/rss/adapter.go
index 5c1785a9..fe1eed80 100644
--- a/internal/reader/rss/adapter.go
+++ b/internal/reader/rss/adapter.go
@@ -122,6 +122,7 @@ func (r *RSSAdapter) BuildFeed(feedURL 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()...)
diff --git a/internal/reader/rss/parser_test.go b/internal/reader/rss/parser_test.go
index 41b36e8e..7e9413b0 100644
--- a/internal/reader/rss/parser_test.go
+++ b/internal/reader/rss/parser_test.go
@@ -1681,6 +1681,42 @@ func TestParseFeedWithGooglePlayCategory(t *testing.T) {
}
}
+func TestParseEntryWithMediaCategories(t *testing.T) {
+ data := `
+
+
+ Example
+ https://example.org/
+ -
+ Test
+ https://example.org/item
+ visual_art
+ music/artist/album/song
+ ycantpark mobile
+ Arts/Movies/Titles/A/Ace_Ventura_Series/Ace_Ventura_ -_Pet_Detective
+
+
+ `
+
+ feed, err := Parse("https://example.org/", bytes.NewReader([]byte(data)))
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if len(feed.Entries[0].Tags) != 2 {
+ t.Errorf("Incorrect number of tags, got: %d", len(feed.Entries[0].Tags))
+ }
+
+ expected := []string{"Visual Art", "Ace Ventura - Pet Detective"}
+ result := feed.Entries[0].Tags
+
+ for i, tag := range result {
+ if tag != expected[i] {
+ t.Errorf("Incorrect tag, got: %q", tag)
+ }
+ }
+}
+
func TestParseFeedWithTTLField(t *testing.T) {
data := `