Also parse text/xml

This commit is contained in:
Peter Stuifzand 2018-04-07 21:21:21 +02:00
parent b8034af2aa
commit a99048c9ab
2 changed files with 7 additions and 6 deletions

View File

@ -145,7 +145,7 @@ func (b *memoryBackend) Fetch3(channel, fetchURL string) error {
item.Published = feedItem.DatePublished item.Published = feedItem.DatePublished
b.channelAddItem(channel, item) b.channelAddItem(channel, item)
} }
} else if strings.HasPrefix(contentType, "application/rss+xml") || strings.HasPrefix(contentType, "application/atom+xml") { } else if strings.HasPrefix(contentType, "text/xml") || strings.HasPrefix(contentType, "application/rss+xml") || strings.HasPrefix(contentType, "application/atom+xml") {
body, err := ioutil.ReadAll(resp.Body) body, err := ioutil.ReadAll(resp.Body)
if err != nil { if err != nil {
log.Printf("Error while parsing rss/atom feed: %s\n", err) log.Printf("Error while parsing rss/atom feed: %s\n", err)
@ -161,6 +161,7 @@ func (b *memoryBackend) Fetch3(channel, fetchURL string) error {
var item microsub.Item var item microsub.Item
item.Name = feedItem.Title item.Name = feedItem.Title
item.Content.HTML = feedItem.Content item.Content.HTML = feedItem.Content
item.Content.Text = feedItem.Content
item.URL = feedItem.Link item.URL = feedItem.Link
item.Summary = []string{feedItem.Summary} item.Summary = []string{feedItem.Summary}
item.Id = feedItem.ID item.Id = feedItem.ID

View File

@ -39,14 +39,14 @@ type Channel struct {
type Author struct { type Author struct {
Filled bool `json:"-"` Filled bool `json:"-"`
Type string `json:"type"` Type string `json:"type"`
Name string `json:"name"` Name string `json:"name,omitempty"`
URL string `json:"url"` URL string `json:"url,omitempty"`
Photo string `json:"photo"` Photo string `json:"photo,omitempty"`
} }
type Content struct { type Content struct {
Text string `json:"text"` Text string `json:"text,omitempty"`
HTML string `json:"html"` HTML string `json:"html,omitempty"`
} }
// Item is a post object // Item is a post object