miniflux client
This commit is contained in:
parent
296744940d
commit
ca0d74b5d8
|
@ -0,0 +1,47 @@
|
|||
package feed
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"miniflux.app/client"
|
||||
)
|
||||
|
||||
type Miniflux struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
func NewMiniflux(url, apiKey string) *Miniflux {
|
||||
return &Miniflux{
|
||||
client: client.New(url, apiKey),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Miniflux) Feeds() error {
|
||||
|
||||
feeds, err := m.client.Feeds()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return err
|
||||
}
|
||||
fmt.Println(feeds)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type Entry struct {
|
||||
ChannelID int
|
||||
Title string
|
||||
URL string
|
||||
}
|
||||
|
||||
func (m *Miniflux) Unread() ([]Entry, error) {
|
||||
result, err := m.client.Entries(&client.Filter{Status: "unread"})
|
||||
if err != nil {
|
||||
return []Entry{}, err
|
||||
}
|
||||
|
||||
for _, entry := range result.Entries {
|
||||
fmt.Println(entry.ID, entry.Title, entry.URL)
|
||||
}
|
||||
|
||||
return []Entry{}, nil
|
||||
}
|
5
go.mod
5
go.mod
|
@ -2,4 +2,7 @@ module ewintr.nl/yogai
|
|||
|
||||
go 1.20
|
||||
|
||||
require github.com/lib/pq v1.10.9
|
||||
require (
|
||||
github.com/lib/pq v1.10.9
|
||||
miniflux.app v0.0.0-20230505000442-88062ab9f959
|
||||
)
|
||||
|
|
2
go.sum
2
go.sum
|
@ -1,2 +1,4 @@
|
|||
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
|
||||
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||
miniflux.app v0.0.0-20230505000442-88062ab9f959 h1:YzOQqdFtI6HYRmz8+xVZbqcrVoaC3X4x/pB2DDID//c=
|
||||
miniflux.app v0.0.0-20230505000442-88062ab9f959/go.mod h1:VWCACdWTG2GzFFifM2i9hVK91mZxmPvZCdHzYGheNOE=
|
||||
|
|
13
service.go
13
service.go
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"database/sql"
|
||||
"ewintr.nl/yogai/feed"
|
||||
"ewintr.nl/yogai/storage"
|
||||
"fmt"
|
||||
"os"
|
||||
|
@ -27,12 +28,22 @@ func main() {
|
|||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
_, err = storage.NewPostgres(db)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
mlxInfo := struct {
|
||||
Endpoint string
|
||||
ApiKey string
|
||||
}{
|
||||
Endpoint: getParam("MINIFLUX_ENDPOINT", "http://localhost/v1"),
|
||||
ApiKey: getParam("MINIFLUX_APIKEY", ""),
|
||||
}
|
||||
mflx := feed.NewMiniflux(mlxInfo.Endpoint, mlxInfo.ApiKey)
|
||||
_, err = mflx.Unread()
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
func getParam(param, def string) string {
|
||||
|
|
Loading…
Reference in New Issue