mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 16:59:12 +00:00
Feature: Lidarr (#15)
* feat(web): add lidarr download client * feat: add lidarr download client
This commit is contained in:
parent
fce6c7149a
commit
e6cfc77e85
16 changed files with 582 additions and 15 deletions
65
internal/action/lidarr.go
Normal file
65
internal/action/lidarr.go
Normal file
|
@ -0,0 +1,65 @@
|
|||
package action
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/autobrr/autobrr/internal/domain"
|
||||
"github.com/autobrr/autobrr/pkg/lidarr"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
func (s *service) lidarr(announce domain.Announce, action domain.Action) error {
|
||||
log.Trace().Msg("action LIDARR")
|
||||
|
||||
// TODO validate data
|
||||
|
||||
// get client for action
|
||||
client, err := s.clientSvc.FindByID(action.ClientID)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msgf("error finding client: %v", action.ClientID)
|
||||
return err
|
||||
}
|
||||
|
||||
// return early if no client found
|
||||
if client == nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// initial config
|
||||
cfg := lidarr.Config{
|
||||
Hostname: client.Host,
|
||||
APIKey: client.Settings.APIKey,
|
||||
}
|
||||
|
||||
// only set basic auth if enabled
|
||||
if client.Settings.Basic.Auth {
|
||||
cfg.BasicAuth = client.Settings.Basic.Auth
|
||||
cfg.Username = client.Settings.Basic.Username
|
||||
cfg.Password = client.Settings.Basic.Password
|
||||
}
|
||||
|
||||
r := lidarr.New(cfg)
|
||||
|
||||
release := lidarr.Release{
|
||||
Title: announce.TorrentName,
|
||||
DownloadUrl: announce.TorrentUrl,
|
||||
Size: 0,
|
||||
Indexer: announce.Site,
|
||||
DownloadProtocol: "torrent",
|
||||
Protocol: "torrent",
|
||||
PublishDate: time.Now().String(),
|
||||
}
|
||||
|
||||
err = r.Push(release)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msgf("lidarr: failed to push release: %v", release)
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO save pushed release
|
||||
|
||||
log.Debug().Msgf("lidarr: successfully pushed release: %v, indexer %v to %v", release.Title, release.Indexer, client.Host)
|
||||
|
||||
return nil
|
||||
}
|
|
@ -80,6 +80,13 @@ func (s *service) RunActions(torrentFile string, hash string, filter domain.Filt
|
|||
log.Error().Err(err).Msg("error sending torrent to sonarr")
|
||||
}
|
||||
}()
|
||||
case domain.ActionTypeLidarr:
|
||||
go func() {
|
||||
err := s.lidarr(announce, action)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("error sending torrent to lidarr")
|
||||
}
|
||||
}()
|
||||
|
||||
default:
|
||||
log.Warn().Msgf("unsupported action: %v type: %v", action.Name, action.Type)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue