1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-26 18:21:01 +00:00

Add RSS-Bridge integration

This commit is contained in:
Ryan Stafford 2023-10-22 14:10:56 -04:00 committed by GitHub
parent 5e6c054345
commit 120aabfbce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 161 additions and 5 deletions

View file

@ -0,0 +1,45 @@
package rssbridge // import "miniflux.app/integration/rssbridge"
import (
"encoding/json"
"fmt"
"net/http"
"net/url"
)
type Bridge struct {
URL string `json:"url"`
BridgeMeta BridgeMeta `json:"bridgeMeta"`
}
type BridgeMeta struct {
Name string `json:"name"`
}
func DetectBridges(rssbridgeURL, websiteURL string) (bridgeResponse []Bridge, err error) {
u, err := url.Parse(rssbridgeURL)
if err != nil {
return nil, err
}
values := u.Query()
values.Add("action", "findfeed")
values.Add("format", "atom")
values.Add("url", websiteURL)
u.RawQuery = values.Encode()
response, err := http.Get(u.String())
if err != nil {
return nil, err
}
defer response.Body.Close()
if response.StatusCode == http.StatusNotFound {
return
}
if response.StatusCode > 400 {
return nil, fmt.Errorf("RSS-Bridge: server failure (%d)", response.StatusCode)
}
if err := json.NewDecoder(response.Body).Decode(&bridgeResponse); err != nil {
return nil, fmt.Errorf("RSS-Bridge: unable to decode bridge response: %w", err)
}
return
}