Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env
**/.vscode/**
11 changes: 11 additions & 0 deletions sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ YOUTUBE_API_KEY=
# Comma-separated (without spaces) keywords to avoid, when filtering slskd results (default: live,remix,instrumental,extended,clean,acapella)
# FILTER_LIST=live,remix,instrumental,extended,clean,acapella

# === Lidarr Configuration ===

# LIDARR_API_KEY=
# LIDARR_RETRY=
# LIDARR_DL_ATTEMPTS=
# LIDARR_DIR=
# MIGRATE_DOWNLOADS=
# LIDARR_TIMEOUT=
# LIDARR_SCHEME=
# LIDARR_URL=

# === Metadata / Formatting ===

# Set to true to merge featured artists into title (recommended), false appends them to artist field (default: true)
Expand Down
21 changes: 20 additions & 1 deletion src/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ type Credentials struct {
}



type Lidarr struct {
APIKey string `env:"LIDARR_API_KEY"`
Retry int `env:"LIDARR_RETRY" env-default:"5"` // Number of times to check search status before skipping the track
DownloadAttempts int `env:"LIDARR_DL_ATTEMPTS" env-default:"3"` // Max number of files to attempt downloading per track
LidarrDir string `env:"LIDARR_DIR" env-default:"/lidarr/"`
MigrateDL bool `env:"MIGRATE_DOWNLOADS" env-default:"false"` // Move downloads from LidarrDir to DownloadDir
Timeout int `env:"LIDARR_TIMEOUT" env-default:"20"`
URL string `env:"LIDARR_URL"`
Filters Filters
MonitorConfig LidarrMon
}

type LidarrMon struct {
Interval time.Duration `env:"SLSKD_MONITOR_INTERVAL" env-default:"1m"`
Duration time.Duration `env:"SLSKD_MONITOR_DURATION" env-default:"15m"`
}

type SubsonicConfig struct {
Version string `env:"SUBSONIC_VERSION" env-default:"1.16.1"`
ID string `env:"CLIENT" env-default:"explo"`
Expand All @@ -70,6 +88,7 @@ type DownloadConfig struct {
Youtube Youtube
YoutubeMusic YoutubeMusic
Slskd Slskd
Lidarr Lidarr
ExcludeLocal bool
KeepPermissions bool `env:"KEEP_PERMISSIONS" env-default:"true"` // keep original file permissions when migrating download
RenameTrack bool `env:"RENAME_TRACK" env-default:"false"` // Rename track in {title}-{artist} format
Expand Down Expand Up @@ -134,7 +153,7 @@ func (cfg *Config) ReadEnv() {
if err != nil {
// If the error is because the file doesn't exist, fallback to env vars
if errors.Is(err, os.ErrNotExist) {
if err := cleanenv.ReadEnv(&cfg); err != nil {
if err := cleanenv.ReadEnv(cfg); err != nil {
slog.Error("failed to load config from env vars", "context", err.Error())
os.Exit(1)
}
Expand Down
4 changes: 4 additions & 0 deletions src/downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ func NewDownloader(cfg *cfg.DownloadConfig, httpClient *util.HttpClient, filterL
slskdClient := NewSlskd(cfg.Slskd, cfg.DownloadDir)
slskdClient.AddHeader()
downloader = append(downloader, slskdClient)
case "lidarr":
lidarrClient := NewLidarr(cfg.Lidarr, cfg.DownloadDir)
lidarrClient.AddHeader()
downloader = append(downloader, lidarrClient)
default:
return nil, fmt.Errorf("downloader '%s' not supported", service)
}
Expand Down
Loading