mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-04 13:07:36 +03:00
Add config option to select tag extractor (taglib, ffmpeg)
This commit is contained in:
parent
506899b083
commit
34eda3c8fc
2 changed files with 24 additions and 1 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/deluan/navidrome/consts"
|
"github.com/deluan/navidrome/consts"
|
||||||
|
@ -39,11 +40,17 @@ type configOptions struct {
|
||||||
AuthRequestLimit int
|
AuthRequestLimit int
|
||||||
AuthWindowLength time.Duration
|
AuthWindowLength time.Duration
|
||||||
|
|
||||||
|
Scanner scannerOptions
|
||||||
|
|
||||||
// DevFlags. These are used to enable/disable debugging and incomplete features
|
// DevFlags. These are used to enable/disable debugging and incomplete features
|
||||||
DevLogSourceLine bool
|
DevLogSourceLine bool
|
||||||
DevAutoCreateAdminPassword string
|
DevAutoCreateAdminPassword string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type scannerOptions struct {
|
||||||
|
Extractor string
|
||||||
|
}
|
||||||
|
|
||||||
var Server = &configOptions{}
|
var Server = &configOptions{}
|
||||||
|
|
||||||
func LoadFromFile(confFile string) {
|
func LoadFromFile(confFile string) {
|
||||||
|
@ -99,6 +106,8 @@ func init() {
|
||||||
viper.SetDefault("authrequestlimit", 5)
|
viper.SetDefault("authrequestlimit", 5)
|
||||||
viper.SetDefault("authwindowlength", 20*time.Second)
|
viper.SetDefault("authwindowlength", 20*time.Second)
|
||||||
|
|
||||||
|
viper.SetDefault("scanner.extractor", "ffmpeg")
|
||||||
|
|
||||||
// DevFlags. These are used to enable/disable debugging and incomplete features
|
// DevFlags. These are used to enable/disable debugging and incomplete features
|
||||||
viper.SetDefault("devlogsourceline", false)
|
viper.SetDefault("devlogsourceline", false)
|
||||||
viper.SetDefault("devautocreateadminpassword", "")
|
viper.SetDefault("devautocreateadminpassword", "")
|
||||||
|
@ -118,6 +127,8 @@ func InitConfig(cfgFile string) {
|
||||||
|
|
||||||
_ = viper.BindEnv("port")
|
_ = viper.BindEnv("port")
|
||||||
viper.SetEnvPrefix("ND")
|
viper.SetEnvPrefix("ND")
|
||||||
|
replacer := strings.NewReplacer(".", "_")
|
||||||
|
viper.SetEnvKeyReplacer(replacer)
|
||||||
viper.AutomaticEnv()
|
viper.AutomaticEnv()
|
||||||
|
|
||||||
err := viper.ReadInConfig()
|
err := viper.ReadInConfig()
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/deluan/navidrome/conf"
|
||||||
"github.com/deluan/navidrome/log"
|
"github.com/deluan/navidrome/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -17,7 +18,18 @@ type Extractor interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Extract(files ...string) (map[string]Metadata, error) {
|
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...)
|
return e.Extract(files...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue