Skip to content

Commit

Permalink
add itunes:image tag
Browse files Browse the repository at this point in the history
add media:thumbnail tag
  • Loading branch information
Artur committed Apr 1, 2022
1 parent 0d104d0 commit deb180b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
11 changes: 10 additions & 1 deletion app/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ func (s *Server) getFeedCtrl(w http.ResponseWriter, r *http.Request) {

rss := feed.Rss2{
Version: "2.0",
NsItunes: "http://www.itunes.com/dtds/podcast-1.0.dtd",
NsMedia: "http://search.yahoo.com/mrss/",
ItemList: items,
Title: s.Conf.Feeds[feedName].Title,
Description: s.Conf.Feeds[feedName].Description,
Expand All @@ -147,7 +149,14 @@ func (s *Server) getFeedCtrl(w http.ResponseWriter, r *http.Request) {

// replace link to UI page
if s.Conf.System.BaseURL != "" {
rss.Link = s.Conf.System.BaseURL + "/feed/" + feedName
baseURL := s.Conf.System.BaseURL
rss.Link = baseURL + "/feed/" + feedName
rss.ItunesImage = feed.ItunesImg{
URL: baseURL + "/image/" + feedName,
}
rss.MediaThumbnail = feed.MediaThumbnail{
URL: baseURL + "/image/" + feedName,
}
}

b, err := xml.MarshalIndent(&rss, "", " ")
Expand Down
30 changes: 22 additions & 8 deletions app/feed/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,32 @@ import (

// Rss2 feed
type Rss2 struct {
XMLName xml.Name `xml:"rss"`
Version string `xml:"version,attr"`
Title string `xml:"channel>title"`
Language string `xml:"channel>language"`
Link string `xml:"channel>link"`
Description string `xml:"channel>description"`
PubDate string `xml:"channel>pubDate"`
LastBuildDate string `xml:"channel>lastBuildDate"`
XMLName xml.Name `xml:"rss"`
NsItunes string `xml:"xmlns:itunes,attr"`
NsMedia string `xml:"xmlns:media,attr"`
Version string `xml:"version,attr"`
Title string `xml:"channel>title"`
Language string `xml:"channel>language"`
Link string `xml:"channel>link"`
Description string `xml:"channel>description"`
PubDate string `xml:"channel>pubDate"`
LastBuildDate string `xml:"channel>lastBuildDate"`
ItunesImage ItunesImg `xml:"channel>itunes:image"`
MediaThumbnail MediaThumbnail `xml:"channel>media:thumbnail"`

ItemList []Item `xml:"channel>item"`
}

// ItunesImg image element for iTunes
type ItunesImg struct {
URL string `xml:"href,attr"`
}

// MediaThumbnail image element for media
type MediaThumbnail struct {
URL string `xml:"url,attr"`
}

// Enclosure element from item
type Enclosure struct {
URL string `xml:"url,attr"`
Expand Down

0 comments on commit deb180b

Please sign in to comment.