Use ffmpeg extractor by default on Windows

This is to avoid issue with unicode chars in filenames. See #810
This commit is contained in:
Deluan 2021-07-24 11:35:49 -04:00
parent d3975d206a
commit 4ed01bad86
4 changed files with 23 additions and 13 deletions

View file

@ -214,7 +214,7 @@ func init() {
viper.SetDefault("reverseproxyuserheader", "Remote-User") viper.SetDefault("reverseproxyuserheader", "Remote-User")
viper.SetDefault("reverseproxywhitelist", "") viper.SetDefault("reverseproxywhitelist", "")
viper.SetDefault("scanner.extractor", "taglib") viper.SetDefault("scanner.extractor", DefaultScannerExtractor)
viper.SetDefault("scanner.genreseparators", ";/,") viper.SetDefault("scanner.genreseparators", ";/,")
viper.SetDefault("agents", "lastfm,spotify") viper.SetDefault("agents", "lastfm,spotify")

5
conf/defaults.go Normal file
View file

@ -0,0 +1,5 @@
// +build !windows
package conf
const DefaultScannerExtractor = "taglib"

5
conf/defaults_win.go Normal file
View file

@ -0,0 +1,5 @@
// +build windows
package conf
const DefaultScannerExtractor = "ffmpeg"

View file

@ -23,20 +23,20 @@ type Parser interface {
Parse(files ...string) (map[string]map[string][]string, error) Parse(files ...string) (map[string]map[string][]string, error)
} }
func Extract(files ...string) (map[string]*Tags, error) { var parsers = map[string]Parser{
var e Parser "ffmpeg": &ffmpeg.Parser{},
"taglib": &taglib.Parser{},
}
switch conf.Server.Scanner.Extractor { func Extract(files ...string) (map[string]*Tags, error) {
case "taglib": p, ok := parsers[conf.Server.Scanner.Extractor]
e = &taglib.Parser{} if !ok {
case "ffmpeg": log.Warn("Invalid 'Scanner.Extractor' option. Using default", "requested", conf.Server.Scanner.Extractor,
e = &ffmpeg.Parser{} "validOptions", "ffmpeg,taglib", "default", conf.DefaultScannerExtractor)
default: p = parsers[conf.DefaultScannerExtractor]
log.Warn("Invalid 'Scanner.Extractor' option. Using default 'taglib'", "requested", conf.Server.Scanner.Extractor,
"validOptions", "ffmpeg,taglib")
e = &taglib.Parser{}
} }
extractedTags, err := e.Parse(files...)
extractedTags, err := p.Parse(files...)
if err != nil { if err != nil {
return nil, err return nil, err
} }