feat(server): group Subsonic config options together

Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
Deluan 2025-03-05 12:29:30 -08:00
parent 637c909e93
commit 8ab2a11d22
4 changed files with 17 additions and 12 deletions

View file

@ -59,8 +59,6 @@ type configOptions struct {
PreferSortTags bool
IgnoredArticles string
IndexGroups string
SubsonicArtistParticipations bool
DefaultReportRealPath bool
FFmpegPath string
MPVPath string
MPVCmdTemplate string
@ -93,6 +91,7 @@ type configOptions struct {
Backup backupOptions
PID pidOptions
Inspect inspectOptions
Subsonic subsonicOptions
Agents string
LastFM lastfmOptions
@ -121,7 +120,6 @@ type configOptions struct {
DevScannerThreads uint
DevInsightsInitialDelay time.Duration
DevEnablePlayerInsights bool
DevOpenSubsonicDisabledClients string
}
type scannerOptions struct {
@ -133,6 +131,12 @@ type scannerOptions struct {
GroupAlbumReleases bool // Deprecated: BFR Update docs
}
type subsonicOptions struct {
ArtistParticipations bool
DefaultReportRealPath bool
LegacyClients string
}
type TagConf struct {
Aliases []string `yaml:"aliases"`
Type string `yaml:"type"`
@ -431,8 +435,6 @@ func init() {
viper.SetDefault("prefersorttags", false)
viper.SetDefault("ignoredarticles", "The El La Los Las Le Les Os As O A")
viper.SetDefault("indexgroups", "A B C D E F G H I J K L M N O P Q R S T U V W X-Z(XYZ) [Unknown]([)")
viper.SetDefault("subsonicartistparticipations", false)
viper.SetDefault("defaultreportrealpath", false)
viper.SetDefault("ffmpegpath", "")
viper.SetDefault("mpvcmdtemplate", "mpv --audio-device=%d --no-audio-display --pause %f --input-ipc-server=%s")
@ -477,6 +479,10 @@ func init() {
viper.SetDefault("scanner.watcherwait", consts.DefaultWatcherWait)
viper.SetDefault("scanner.scanonstartup", true)
viper.SetDefault("subsonic.artistparticipations", false)
viper.SetDefault("subsonic.defaultreportrealpath", false)
viper.SetDefault("subsonic.legacyclients", "DSub")
viper.SetDefault("agents", "lastfm,spotify")
viper.SetDefault("lastfm.enabled", true)
viper.SetDefault("lastfm.language", "en")
@ -521,7 +527,6 @@ func init() {
viper.SetDefault("devscannerthreads", 5)
viper.SetDefault("devinsightsinitialdelay", consts.InsightsInitialDelay)
viper.SetDefault("devenableplayerinsights", true)
viper.SetDefault("devopensubsonicdisabledclients", "DSub")
}
func InitConfig(cfgFile string) {

View file

@ -53,7 +53,7 @@ func (p *players) Register(ctx context.Context, playerID, client, userAgent, ip
UserId: user.ID,
Client: client,
ScrobbleEnabled: true,
ReportRealPath: conf.Server.DefaultReportRealPath,
ReportRealPath: conf.Server.Subsonic.DefaultReportRealPath,
}
log.Info(ctx, "Registering new player", "id", plr.ID, "client", client, "username", username, "type", userAgent)
}

View file

@ -50,7 +50,7 @@ func AlbumsByArtistID(artistId string) Options {
filters := []Sqlizer{
persistence.Exists("json_tree(Participants, '$.albumartist')", Eq{"value": artistId}),
}
if conf.Server.SubsonicArtistParticipations {
if conf.Server.Subsonic.ArtistParticipations {
filters = append(filters,
persistence.Exists("json_tree(Participants, '$.artist')", Eq{"value": artistId}),
)

View file

@ -110,7 +110,7 @@ func toArtistID3(r *http.Request, a model.Artist) responses.ArtistID3 {
func toOSArtistID3(ctx context.Context, a model.Artist) *responses.OpenSubsonicArtistID3 {
player, _ := request.PlayerFrom(ctx)
if strings.Contains(conf.Server.DevOpenSubsonicDisabledClients, player.Client) {
if strings.Contains(conf.Server.Subsonic.LegacyClients, player.Client) {
return nil
}
artist := responses.OpenSubsonicArtistID3{
@ -197,7 +197,7 @@ func childFromMediaFile(ctx context.Context, mf model.MediaFile) responses.Child
func osChildFromMediaFile(ctx context.Context, mf model.MediaFile) *responses.OpenSubsonicChild {
player, _ := request.PlayerFrom(ctx)
if strings.Contains(conf.Server.DevOpenSubsonicDisabledClients, player.Client) {
if strings.Contains(conf.Server.Subsonic.LegacyClients, player.Client) {
return nil
}
child := responses.OpenSubsonicChild{}
@ -301,7 +301,7 @@ func childFromAlbum(ctx context.Context, al model.Album) responses.Child {
func osChildFromAlbum(ctx context.Context, al model.Album) *responses.OpenSubsonicChild {
player, _ := request.PlayerFrom(ctx)
if strings.Contains(conf.Server.DevOpenSubsonicDisabledClients, player.Client) {
if strings.Contains(conf.Server.Subsonic.LegacyClients, player.Client) {
return nil
}
child := responses.OpenSubsonicChild{}
@ -376,7 +376,7 @@ func buildAlbumID3(ctx context.Context, album model.Album) responses.AlbumID3 {
func buildOSAlbumID3(ctx context.Context, album model.Album) *responses.OpenSubsonicAlbumID3 {
player, _ := request.PlayerFrom(ctx)
if strings.Contains(conf.Server.DevOpenSubsonicDisabledClients, player.Client) {
if strings.Contains(conf.Server.Subsonic.LegacyClients, player.Client) {
return nil
}
dir := responses.OpenSubsonicAlbumID3{}