Added support for atom feeds
Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
This commit is contained in:
parent
86f826b3e4
commit
8cf51e1004
10
main.go
10
main.go
@ -79,7 +79,7 @@ func getFeeds(requestURL string) ([]string, int) {
|
|||||||
} else if err != nil && err == gofeed.ErrFeedTypeNotDetected {
|
} else if err != nil && err == gofeed.ErrFeedTypeNotDetected {
|
||||||
res, err := http.Get(requestURL)
|
res, err := http.Get(requestURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Failed to fetch URL")
|
fmt.Printf("Failed to fetch URL %s", requestURL)
|
||||||
return feeds, fiber.StatusInternalServerError
|
return feeds, fiber.StatusInternalServerError
|
||||||
}
|
}
|
||||||
defer res.Body.Close()
|
defer res.Body.Close()
|
||||||
@ -95,9 +95,9 @@ func getFeeds(requestURL string) ([]string, int) {
|
|||||||
return feeds, fiber.StatusInternalServerError
|
return feeds, fiber.StatusInternalServerError
|
||||||
}
|
}
|
||||||
|
|
||||||
matches := doc.Find(`[rel="alternate"][type="application/rss+xml"]`)
|
matches := doc.Find(`[rel="alternate"][type="application/rss+xml"],[rel="alternate"][type="application/atom+xml"]`)
|
||||||
if matches.Length() == 0 {
|
if matches.Length() == 0 {
|
||||||
fmt.Println("No RSS feeds found on page")
|
fmt.Printf("No RSS feeds found on page %s\n", requestURL)
|
||||||
return feeds, fiber.StatusNotFound
|
return feeds, fiber.StatusNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,10 +106,10 @@ func getFeeds(requestURL string) ([]string, int) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if matches.Length() > 1 {
|
if matches.Length() > 1 {
|
||||||
fmt.Println("Multiple feeds found on page")
|
fmt.Printf("Multiple RSS feed found on page %s\n", requestURL)
|
||||||
return feeds, fiber.StatusMultipleChoices
|
return feeds, fiber.StatusMultipleChoices
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("Feed found on page")
|
fmt.Printf("Single RSS feed found on page %s\n", requestURL)
|
||||||
return feeds, fiber.StatusTemporaryRedirect
|
return feeds, fiber.StatusTemporaryRedirect
|
||||||
}
|
}
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user