feat(feeds): add generic RSS support (#410)

* feat(feeds): add generic rss support

* feat(feeds/web): add generic rss support

* implement rss downloading

* gosum + mod

* re-add size from Custom field.

* implement uploader + category

* sync

* remove double assignment (+torznab)

* didn't save the rss file >.>

* cleanup

* fixfeeds): create rss indexer

* fix(feeds): stop feed

* feat(feeds): support nexusphp rss enclosure link

* feat(feeds): check size for custom size

* fix(feeds): race condition and only stop enabled feeds

* fix(feeds): unify indexer implementation badge

Co-authored-by: Kyle Sanderson <kyle.leet@gmail.com>
This commit is contained in:
ze0s 2022-08-20 00:34:46 +02:00 committed by GitHub
parent b607aef63e
commit b50688159e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 498 additions and 89 deletions

View file

@ -1,6 +1,7 @@
package scheduler
import (
"sync"
"time"
"github.com/autobrr/autobrr/internal/logger"
@ -14,7 +15,6 @@ type Service interface {
Start()
Stop()
AddJob(job cron.Job, interval time.Duration, identifier string) (int, error)
RemoveJobByID(id cron.EntryID) error
RemoveJobByIdentifier(id string) error
}
@ -25,6 +25,7 @@ type service struct {
cron *cron.Cron
jobs map[string]cron.EntryID
m sync.RWMutex
}
func NewService(log logger.Logger, version string, notificationSvc notification.Service) Service {
@ -62,7 +63,9 @@ func (s *service) addAppJobs() {
lastCheckVersion: "",
}
s.AddJob(checkUpdates, time.Duration(36 * time.Hour), "app-check-updates")
if id, err := s.AddJob(checkUpdates, time.Duration(36*time.Hour), "app-check-updates"); err != nil {
s.log.Error().Err(err).Msgf("scheduler.addAppJobs: error adding job: %v", id)
}
}
func (s *service) Stop() {
@ -79,23 +82,18 @@ func (s *service) AddJob(job cron.Job, interval time.Duration, identifier string
s.log.Debug().Msgf("scheduler.AddJob: job successfully added: %v", id)
s.m.Lock()
// add to job map
s.jobs[identifier] = id
s.m.Unlock()
return int(id), nil
}
func (s *service) RemoveJobByID(id cron.EntryID) error {
v, ok := s.jobs[""]
if !ok {
return nil
}
s.cron.Remove(v)
return nil
}
func (s *service) RemoveJobByIdentifier(id string) error {
s.m.Lock()
defer s.m.Unlock()
v, ok := s.jobs[id]
if !ok {
return nil