mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-01 19:47:37 +03:00
feat(scanner): allow disabling tags with Tags.<tag>.Ignore=true
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
parent
b952672877
commit
2838ac36df
2 changed files with 22 additions and 8 deletions
|
@ -140,6 +140,7 @@ type subsonicOptions struct {
|
|||
}
|
||||
|
||||
type TagConf struct {
|
||||
Ignore bool `yaml:"ignore"`
|
||||
Aliases []string `yaml:"aliases"`
|
||||
Type string `yaml:"type"`
|
||||
MaxLength int `yaml:"maxLength"`
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"maps"
|
||||
"regexp"
|
||||
"slices"
|
||||
|
@ -186,19 +187,31 @@ func loadTagMappings() {
|
|||
|
||||
// Overwrite the default mappings with the ones from the config
|
||||
for tag, cfg := range conf.Server.Tags {
|
||||
if len(cfg.Aliases) == 0 {
|
||||
if cfg.Ignore {
|
||||
delete(_mappings.Main, TagName(tag))
|
||||
delete(_mappings.Additional, TagName(tag))
|
||||
continue
|
||||
}
|
||||
c := TagConf{
|
||||
Aliases: cfg.Aliases,
|
||||
Type: TagType(cfg.Type),
|
||||
MaxLength: cfg.MaxLength,
|
||||
Split: cfg.Split,
|
||||
Album: cfg.Album,
|
||||
SplitRx: compileSplitRegex(TagName(tag), cfg.Split),
|
||||
oldValue, ok := _mappings.Main[TagName(tag)]
|
||||
if !ok {
|
||||
oldValue = _mappings.Additional[TagName(tag)]
|
||||
}
|
||||
aliases := cfg.Aliases
|
||||
if len(aliases) == 0 {
|
||||
aliases = oldValue.Aliases
|
||||
}
|
||||
split := cfg.Split
|
||||
if len(split) == 0 {
|
||||
split = oldValue.Split
|
||||
}
|
||||
c := TagConf{
|
||||
Aliases: aliases,
|
||||
Split: split,
|
||||
Type: cmp.Or(TagType(cfg.Type), oldValue.Type),
|
||||
MaxLength: cmp.Or(cfg.MaxLength, oldValue.MaxLength),
|
||||
Album: cmp.Or(cfg.Album, oldValue.Album),
|
||||
}
|
||||
c.SplitRx = compileSplitRegex(TagName(tag), c.Split)
|
||||
if _, ok := _mappings.Main[TagName(tag)]; ok {
|
||||
_mappings.Main[TagName(tag)] = c
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue