mirror of
https://github.com/nkanaev/yarr.git
synced 2025-05-24 00:33:14 +00:00
podcasts
This commit is contained in:
parent
5335863488
commit
51cbdea31f
@ -77,7 +77,7 @@ func ParseAtom(r io.Reader) (*Feed, error) {
|
||||
Title: srcitem.Title.String(),
|
||||
Content: firstNonEmpty(srcitem.Content.String(), srcitem.firstMediaDescription()),
|
||||
ImageURL: srcitem.firstMediaThumbnail(),
|
||||
PodcastURL: "",
|
||||
AudioURL: "",
|
||||
})
|
||||
}
|
||||
return dstfeed, nil
|
||||
|
@ -46,7 +46,7 @@ func TestAtom(t *testing.T) {
|
||||
Title: "Atom-Powered Robots Run Amok",
|
||||
Content: `<div xmlns="http://www.w3.org/1999/xhtml"><p>This is the entry content.</p></div>`,
|
||||
ImageURL: "",
|
||||
PodcastURL: "",
|
||||
AudioURL: "",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -16,5 +16,5 @@ type Item struct {
|
||||
|
||||
Content string
|
||||
ImageURL string
|
||||
PodcastURL string
|
||||
AudioURL string
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ type rssItem struct {
|
||||
Link string `xml:"link"`
|
||||
Description string `xml:"rss description"`
|
||||
PubDate string `xml:"pubDate"`
|
||||
EnclosureLinks []rssEnclosure `xml:"enclosure"`
|
||||
Enclosures []rssEnclosure `xml:"enclosure"`
|
||||
|
||||
DublinCoreDate string `xml:"http://purl.org/dc/elements/1.1/ date"`
|
||||
ContentEncoded string `xml:"http://purl.org/rss/1.0/modules/content/ encoded"`
|
||||
@ -69,12 +69,21 @@ func ParseRSS(r io.Reader) (*Feed, error) {
|
||||
SiteURL: srcfeed.Link,
|
||||
}
|
||||
for _, srcitem := range srcfeed.Items {
|
||||
podcastURL := ""
|
||||
for _, e := range srcitem.Enclosures {
|
||||
if e.Type == "audio/mpeg" || e.Type == "audio/x-m4a" {
|
||||
podcastURL = e.URL
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
dstfeed.Items = append(dstfeed.Items, Item{
|
||||
GUID: firstNonEmpty(srcitem.GUID, srcitem.Link),
|
||||
Date: dateParse(firstNonEmpty(srcitem.DublinCoreDate, srcitem.PubDate)),
|
||||
URL: srcitem.Link,
|
||||
Title: srcitem.Title,
|
||||
Content: srcitem.Description,
|
||||
AudioURL: podcastURL,
|
||||
})
|
||||
}
|
||||
return dstfeed, nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user