diff --git a/conf/configuration.go b/conf/configuration.go index 2393db0d5..16068495d 100644 --- a/conf/configuration.go +++ b/conf/configuration.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "path/filepath" + "strings" "time" "github.com/deluan/navidrome/consts" @@ -39,11 +40,17 @@ type configOptions struct { AuthRequestLimit int AuthWindowLength time.Duration + Scanner scannerOptions + // DevFlags. These are used to enable/disable debugging and incomplete features DevLogSourceLine bool DevAutoCreateAdminPassword string } +type scannerOptions struct { + Extractor string +} + var Server = &configOptions{} func LoadFromFile(confFile string) { @@ -99,6 +106,8 @@ func init() { viper.SetDefault("authrequestlimit", 5) viper.SetDefault("authwindowlength", 20*time.Second) + viper.SetDefault("scanner.extractor", "ffmpeg") + // DevFlags. These are used to enable/disable debugging and incomplete features viper.SetDefault("devlogsourceline", false) viper.SetDefault("devautocreateadminpassword", "") @@ -118,6 +127,8 @@ func InitConfig(cfgFile string) { _ = viper.BindEnv("port") viper.SetEnvPrefix("ND") + replacer := strings.NewReplacer(".", "_") + viper.SetEnvKeyReplacer(replacer) viper.AutomaticEnv() err := viper.ReadInConfig() diff --git a/scanner/metadata/metadata.go b/scanner/metadata/metadata.go index 208bfdf6d..88b5a0908 100644 --- a/scanner/metadata/metadata.go +++ b/scanner/metadata/metadata.go @@ -9,6 +9,7 @@ import ( "strings" "time" + "github.com/deluan/navidrome/conf" "github.com/deluan/navidrome/log" ) @@ -17,7 +18,18 @@ type Extractor interface { } func Extract(files ...string) (map[string]Metadata, error) { - e := &taglibExtractor{} + var e Extractor + + switch conf.Server.Scanner.Extractor { + case "taglib": + e = &taglibExtractor{} + case "ffmpeg": + e = &ffmpegExtractor{} + default: + log.Warn("Invalid Scanner.Extractor option. Using default ffmpeg", "requested", conf.Server.Scanner.Extractor, + "validOptions", "ffmpeg,taglib") + e = &ffmpegExtractor{} + } return e.Extract(files...) }