generated from alecodes/base-template
add an option to select how to archive the entries add an option for what entries to archive change the concurrentcy limit to a semaphore instead of a ticker
47 lines
960 B
Go
47 lines
960 B
Go
package miniflux
|
|
|
|
import (
|
|
"git.alecodes.page/alecodes/miniflux-archiver/internal/logger"
|
|
mfApi "miniflux.app/v2/client"
|
|
)
|
|
|
|
type Filter = mfApi.Filter
|
|
|
|
type MinifluxConfig struct {
|
|
Host string
|
|
User string
|
|
Token string
|
|
FeedId int64
|
|
FeedFilter *Filter
|
|
}
|
|
|
|
type Miniflux struct {
|
|
MinifluxConfig
|
|
client *mfApi.Client
|
|
}
|
|
|
|
func (mf *Miniflux) GetEntries() (*mfApi.EntryResultSet, error) {
|
|
mf.FeedFilter.Statuses = []string{mfApi.EntryStatusRead, mfApi.EntryStatusRemoved}
|
|
|
|
if mf.FeedId == -1 {
|
|
return mf.client.Entries(mf.FeedFilter)
|
|
} else {
|
|
return mf.client.FeedEntries(mf.FeedId, mf.FeedFilter)
|
|
}
|
|
}
|
|
|
|
func NewMiniflux(config MinifluxConfig) (*Miniflux, error) {
|
|
mf := &Miniflux{
|
|
MinifluxConfig: config,
|
|
client: mfApi.NewClient(config.Host, config.Token),
|
|
}
|
|
|
|
version, err := mf.client.Version()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
logger.Info("Miniflux server version: %v", version.Version)
|
|
|
|
return mf, nil
|
|
}
|