mirror of
https://github.com/nkanaev/yarr.git
synced 2025-07-08 16:00:11 +00:00
feed fetch changes
This commit is contained in:
parent
6bb7bf4157
commit
c5b9309a52
@ -173,7 +173,10 @@ func FeedListHandler(rw http.ResponseWriter, req *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
feedUrl := feed.Url
|
feedUrl := feed.Url
|
||||||
res, err := http.Get(feedUrl)
|
feedreq, _ := http.NewRequest("GET", feedUrl, nil)
|
||||||
|
feedreq.Header.Set("user-agent", req.Header.Get("user-agent"))
|
||||||
|
feedclient := &http.Client{}
|
||||||
|
res, err := feedclient.Do(feedreq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
handler(req).log.Print(err)
|
handler(req).log.Print(err)
|
||||||
writeJSON(rw, map[string]string{"status": "notfound"})
|
writeJSON(rw, map[string]string{"status": "notfound"})
|
||||||
@ -191,7 +194,7 @@ func FeedListHandler(rw http.ResponseWriter, req *http.Request) {
|
|||||||
sources, err := FindFeeds(res)
|
sources, err := FindFeeds(res)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
handler(req).log.Print(err)
|
handler(req).log.Print(err)
|
||||||
rw.WriteHeader(http.StatusBadRequest)
|
writeJSON(rw, map[string]string{"status": "notfound"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(sources) == 0 {
|
if len(sources) == 0 {
|
||||||
@ -211,13 +214,14 @@ func FeedListHandler(rw http.ResponseWriter, req *http.Request) {
|
|||||||
}
|
}
|
||||||
writeJSON(rw, map[string]string{"status": "success"})
|
writeJSON(rw, map[string]string{"status": "success"})
|
||||||
}
|
}
|
||||||
} else if strings.HasPrefix(contentType, "text/xml") || strings.HasPrefix(contentType, "application/xml") || strings.HasPrefix(contentType, "application/rss+xml") {
|
} else if strings.Contains(contentType, "xml") {
|
||||||
|
// text/xml, application/xml, application/rss+xml, application/atom+xml
|
||||||
err = createFeed(db(req), feedUrl, feed.FolderID)
|
err = createFeed(db(req), feedUrl, feed.FolderID)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
writeJSON(rw, map[string]string{"status": "success"})
|
writeJSON(rw, map[string]string{"status": "success"})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rw.WriteHeader(http.StatusBadRequest)
|
writeJSON(rw, map[string]string{"status": "notfound"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user