diff --git a/conf/configuration.go b/conf/configuration.go index 1d98daffd..a583b14c8 100644 --- a/conf/configuration.go +++ b/conf/configuration.go @@ -214,7 +214,7 @@ func init() { viper.SetDefault("reverseproxyuserheader", "Remote-User") viper.SetDefault("reverseproxywhitelist", "") - viper.SetDefault("scanner.extractor", "taglib") + viper.SetDefault("scanner.extractor", DefaultScannerExtractor) viper.SetDefault("scanner.genreseparators", ";/,") viper.SetDefault("agents", "lastfm,spotify") diff --git a/conf/defaults.go b/conf/defaults.go new file mode 100644 index 000000000..283449bf8 --- /dev/null +++ b/conf/defaults.go @@ -0,0 +1,5 @@ +// +build !windows + +package conf + +const DefaultScannerExtractor = "taglib" diff --git a/conf/defaults_win.go b/conf/defaults_win.go new file mode 100644 index 000000000..53091285e --- /dev/null +++ b/conf/defaults_win.go @@ -0,0 +1,5 @@ +// +build windows + +package conf + +const DefaultScannerExtractor = "ffmpeg" diff --git a/scanner/metadata/metadata.go b/scanner/metadata/metadata.go index 3df64b100..9b2a8734a 100644 --- a/scanner/metadata/metadata.go +++ b/scanner/metadata/metadata.go @@ -23,20 +23,20 @@ type Parser interface { Parse(files ...string) (map[string]map[string][]string, error) } -func Extract(files ...string) (map[string]*Tags, error) { - var e Parser +var parsers = map[string]Parser{ + "ffmpeg": &ffmpeg.Parser{}, + "taglib": &taglib.Parser{}, +} - switch conf.Server.Scanner.Extractor { - case "taglib": - e = &taglib.Parser{} - case "ffmpeg": - e = &ffmpeg.Parser{} - default: - log.Warn("Invalid 'Scanner.Extractor' option. Using default 'taglib'", "requested", conf.Server.Scanner.Extractor, - "validOptions", "ffmpeg,taglib") - e = &taglib.Parser{} +func Extract(files ...string) (map[string]*Tags, error) { + p, ok := parsers[conf.Server.Scanner.Extractor] + if !ok { + log.Warn("Invalid 'Scanner.Extractor' option. Using default", "requested", conf.Server.Scanner.Extractor, + "validOptions", "ffmpeg,taglib", "default", conf.DefaultScannerExtractor) + p = parsers[conf.DefaultScannerExtractor] } - extractedTags, err := e.Parse(files...) + + extractedTags, err := p.Parse(files...) if err != nil { return nil, err }