Implement MonitorAlbum: search, parse, filter by quality, add best to qbittorrent
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package torrent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"homelab.lan/music-agregator/internal/config"
|
||||
)
|
||||
|
||||
func NewTorrentClient(cfg config.Config) (TorrentClient, error) {
|
||||
var client TorrentClient
|
||||
|
||||
switch cfg.Torrent.ClientType {
|
||||
case config.TorrentClientQbittorrent:
|
||||
client = NewQbittorrentClient(cfg.Torrent.Url)
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown torrent client type: %s", cfg.Torrent.ClientType)
|
||||
}
|
||||
|
||||
if _, err := client.Login(cfg.Torrent.Username, cfg.Torrent.Password); err != nil {
|
||||
return nil, fmt.Errorf("torrent client login failed: %w", err)
|
||||
}
|
||||
|
||||
log.Info().Str("client", string(cfg.Torrent.ClientType)).Str("url", cfg.Torrent.Url).Msg("torrent client connected")
|
||||
|
||||
return client, nil
|
||||
}
|
||||
Reference in New Issue
Block a user