Compare commits
2 Commits
a8b6f6353f
...
681d9e38bc
| Author | SHA1 | Date | |
|---|---|---|---|
| 681d9e38bc | |||
| 0078532d78 |
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
|
@ -132,17 +133,13 @@ func FeedItems(fetcher FetcherFunc, fetchURL, contentType string, body io.Reader
|
||||||
|
|
||||||
items = append(items, r)
|
items = append(items, r)
|
||||||
}
|
}
|
||||||
} else if strings.HasPrefix(contentType, "application/json") { // json feed?
|
} else if strings.HasPrefix(contentType, "application/json") && strings.HasPrefix(contentType, "application/feed+json") { // json feed?
|
||||||
var feed jsonfeed.Feed
|
var feed jsonfeed.Feed
|
||||||
dec := json.NewDecoder(body)
|
err := json.NewDecoder(body).Decode(&feed)
|
||||||
err := dec.Decode(&feed)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error while parsing json feed: %s\n", err)
|
return items, fmt.Errorf("could not parse as jsonfeed: %v", err)
|
||||||
return items, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("%#v\n", feed)
|
|
||||||
|
|
||||||
author := µsub.Card{}
|
author := µsub.Card{}
|
||||||
author.Type = "card"
|
author.Type = "card"
|
||||||
author.Name = feed.Author.Name
|
author.Name = feed.Author.Name
|
||||||
|
|
@ -180,13 +177,11 @@ func FeedItems(fetcher FetcherFunc, fetchURL, contentType string, body io.Reader
|
||||||
} else if strings.HasPrefix(contentType, "text/xml") || strings.HasPrefix(contentType, "application/rss+xml") || strings.HasPrefix(contentType, "application/atom+xml") || strings.HasPrefix(contentType, "application/xml") {
|
} else if strings.HasPrefix(contentType, "text/xml") || strings.HasPrefix(contentType, "application/rss+xml") || strings.HasPrefix(contentType, "application/atom+xml") || strings.HasPrefix(contentType, "application/xml") {
|
||||||
body, err := ioutil.ReadAll(body)
|
body, err := ioutil.ReadAll(body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error while parsing rss/atom feed: %s\n", err)
|
return items, fmt.Errorf("could not read feed for rss/atom: %v", err)
|
||||||
return items, err
|
|
||||||
}
|
}
|
||||||
feed, err := rss.Parse(body)
|
feed, err := rss.Parse(body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error while parsing rss/atom feed: %s\n", err)
|
return items, fmt.Errorf("while parsing rss/atom feed: %v", err)
|
||||||
return items, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
baseURL, _ := url.Parse(fetchURL)
|
baseURL, _ := url.Parse(fetchURL)
|
||||||
|
|
@ -222,7 +217,7 @@ func FeedItems(fetcher FetcherFunc, fetchURL, contentType string, body io.Reader
|
||||||
items = append(items, item)
|
items = append(items, item)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Printf("Unknown Content-Type: %s\n", contentType)
|
return items, fmt.Errorf("unknown content-type %s for url %s", contentType, fetchURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, v := range items {
|
for i, v := range items {
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ func simplifyToItem(itemType string, item map[string][]interface{}, author micro
|
||||||
|
|
||||||
for k, v := range item {
|
for k, v := range item {
|
||||||
switch k {
|
switch k {
|
||||||
case "bookmark-of", "like-of", "repost-of", "in-reply-to":
|
case "bookmark-of", "like-of", "repost-of", "in-reply-to", "quotation-of", "read-of":
|
||||||
u, withItem, refItem := simplifyRefItem(k, v)
|
u, withItem, refItem := simplifyRefItem(k, v)
|
||||||
|
|
||||||
if resultPtr := itemPtr(&feedItem, k); resultPtr != nil {
|
if resultPtr := itemPtr(&feedItem, k); resultPtr != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user