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
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
branches:
- dev
- feat/add-lidarr-download-config
pull_request:
branches: ['*']
workflow_dispatch:
Expand Down Expand Up @@ -133,7 +134,7 @@ jobs:
build-dev:
name: Build/publish dev image
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/dev'
if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/feat/add-lidarr-download-config'
permissions:
contents: read
packages: write
Expand Down
11 changes: 11 additions & 0 deletions sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@ LIBRARY_NAME=
# 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
24 changes: 22 additions & 2 deletions src/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ type DownloadConfig struct {
Youtube Youtube
YoutubeMusic YoutubeMusic
Slskd Slskd
Lidarr Lidarr
ExcludeLocal bool
DownloadLimiter int `env:"DOWNLOAD_LIMITER" env-default:"1"` // rate limit download operations
OverwriteMetadata bool `env:"OVERWRITE_METADATA" env-default:"false"` // overwrite metadata when migrating downloads
Expand Down Expand Up @@ -151,10 +152,27 @@ type SlskdMon struct {
Duration int `env:"SLSKD_MONITOR_DURATION" env-default:"15"`
}

type Lidarr struct {
APIKey string `env:"LIDARR_API_KEY"`
Retry int `env:"LIDARR_RETRY" env-default:"8"` // Number of times to check search status before skipping the track
LidarrDir string `env:"LIDARR_DIR" env-default:"/lidarr/"`
MigrateDL bool `env:"LIDARR_MIGRATE_DOWNLOADS" env-default:"false"` // Move downloads from LidarrDir to DownloadDir
Timeout int `env:"LIDARR_TIMEOUT" env-default:"20"`
URL string `env:"LIDARR_URL"`
RootFolder string `env:"LIDARR_ROOT_FOLDER" env-default:"Music"` // Root folder name to use in Lidarr
Filters Filters
MonitorConfig LidarrMon
}

type LidarrMon struct {
Interval int `env:"LIDARR_MONITOR_INTERVAL" env-default:"1"`
Duration int `env:"LIDARR_MONITOR_DURATION" env-default:"20"`
}

type DiscoveryConfig struct {
Discovery string `env:"DISCOVERY_SERVICE" env-default:"listenbrainz"`
Discovery string `env:"DISCOVERY_SERVICE" env-default:"listenbrainz"`
ArtistBlacklist []string `env:"ARTIST_BLACKLIST"`
Listenbrainz Listenbrainz
Listenbrainz Listenbrainz
}
type Listenbrainz struct {
Discovery string `env:"LISTENBRAINZ_DISCOVERY" env-default:"playlist"`
Expand Down Expand Up @@ -224,6 +242,7 @@ func (cfg *Config) CommonFixes() {
cfg.DownloadCfg.Youtube.CoversDir = filepath.Join(filepath.Dir(cfg.ServerCfg.WebDataDir), "cache", "covers")
cfg.ClientCfg.URL = fixBaseURL(cfg.ClientCfg.URL)
cfg.DownloadCfg.Slskd.URL = fixBaseURL(cfg.DownloadCfg.Slskd.URL)
cfg.DownloadCfg.Lidarr.URL = fixBaseURL(cfg.DownloadCfg.Lidarr.URL)
cfg.NormalizeDir()
}

Expand All @@ -232,6 +251,7 @@ func (cfg *Config) NormalizeDir() {
cfg.ClientCfg.PlaylistDir = fixDir(cfg.ClientCfg.PlaylistDir)
}
cfg.DownloadCfg.Slskd.SlskdDir = fixDir(cfg.DownloadCfg.Slskd.SlskdDir)
cfg.DownloadCfg.Lidarr.LidarrDir = fixDir(cfg.DownloadCfg.Lidarr.LidarrDir)
cfg.DownloadCfg.DownloadDir = fixDir(cfg.DownloadCfg.DownloadDir)
}

Expand Down
16 changes: 8 additions & 8 deletions src/discovery/listenbrainz.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type Metadata struct {
Artist struct {
ArtistCreditID int `json:"artist_credit_id"`
Artists []struct {
ArtistMbid string `json:"artist_mbid"`
MusicBrainzArtistID string `json:"artist_mbid"`
BeginYear int `json:"begin_year"`
EndYear int `json:"end_year,omitempty"`
JoinPhrase string `json:"join_phrase"`
Expand Down Expand Up @@ -121,7 +121,7 @@ type Exploration struct {
AdditionalMetadata struct {
Artists []struct {
ArtistCreditName string `json:"artist_credit_name"`
ArtistMbid string `json:"artist_mbid"`
MusicBrainzArtistID string `json:"artist_mbid"`
JoinPhrase string `json:"join_phrase"`
} `json:"artists"`
CaaID int64 `json:"caa_id"`
Expand Down Expand Up @@ -360,7 +360,7 @@ func (c *ListenBrainz) getTracks(mbids []string, singleArtist bool) ([]*models.T
MusicBrainzTrackID: mbTrackID,
MusicBrainzAlbumID: rel.CaaReleaseMbid,
MusicBrainzReleaseGroupID: rel.ReleaseGroupMbid,
MusicBrainzArtistID: recArtists[0].ArtistMbid,
MusicBrainzArtistID: recArtists[0].MusicBrainzArtistID,
})
}

Expand Down Expand Up @@ -409,7 +409,7 @@ func (c *ListenBrainz) enrichTracks(tracks []*models.Track, singleArtist bool) (
mainArtist := recording.Artist.Name
mainArtistID := ""
if len(recording.Artist.Artists) > 0 {
mainArtistID = recording.Artist.Artists[0].ArtistMbid
mainArtistID = recording.Artist.Artists[0].MusicBrainzArtistID
}

recArtists := recording.Artist.Artists
Expand Down Expand Up @@ -563,7 +563,7 @@ func (c *ListenBrainz) enrichTracks(tracks []*models.Track, singleArtist bool) (
if len(recArtists) == 0 {
return ""
}
return recArtists[0].ArtistMbid
return recArtists[0].MusicBrainzArtistID
}(),
}
}
Expand Down Expand Up @@ -705,9 +705,9 @@ func (c *ListenBrainz) parsePlaylist(identifier string, singleArtist bool) (stri
recordingMBID = parts[len(parts)-1]
}

artistMBID := ""
MusicBrainzArtistID := ""
if len(trackMeta.Artists) > 0 {
artistMBID = trackMeta.Artists[0].ArtistMbid
MusicBrainzArtistID = trackMeta.Artists[0].MusicBrainzArtistID
}

tracks = append(tracks, &models.Track{
Expand All @@ -719,7 +719,7 @@ func (c *ListenBrainz) parsePlaylist(identifier string, singleArtist bool) (stri
Duration: track.Duration,
CoverURL: coverURL,
MusicBrainzTrackID: recordingMBID,
MusicBrainzArtistID: artistMBID,
MusicBrainzArtistID: MusicBrainzArtistID,
MusicBrainzAlbumID: trackMeta.CaaReleaseMbid,
})
}
Expand Down
7 changes: 7 additions & 0 deletions src/downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,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 Expand Up @@ -124,6 +128,9 @@ func (c *DownloadClient) needsDownloadDir() bool {
return true
}
}
if c.Cfg.Lidarr.MigrateDL {
return c.Cfg.Lidarr.MigrateDL
}
return c.Cfg.Slskd.MigrateDL
}

Expand Down
Loading
Loading