diff --git a/cmd/root.go b/cmd/root.go index 879444d5..9bed2286 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -83,6 +83,7 @@ func init() { rootCmd.Flags().Bool("enabletranscodingconfig", viper.GetBool("enabletranscodingconfig"), "enables transcoding configuration in the UI") rootCmd.Flags().String("transcodingcachesize", viper.GetString("transcodingcachesize"), "size of transcoding cache") rootCmd.Flags().String("imagecachesize", viper.GetString("imagecachesize"), "size of image (art work) cache. set to 0 to disable cache") + rootCmd.Flags().Bool("autoimportplaylists", viper.GetBool("autoimportplaylists"), "enable/disable .m3u playlist auto-import`") _ = viper.BindPFlag("address", rootCmd.Flags().Lookup("address")) _ = viper.BindPFlag("port", rootCmd.Flags().Lookup("port")) diff --git a/conf/configuration.go b/conf/configuration.go index ea0c85f4..0e3a9b4a 100644 --- a/conf/configuration.go +++ b/conf/configuration.go @@ -26,6 +26,7 @@ type configOptions struct { EnableTranscodingConfig bool TranscodingCacheSize string ImageCacheSize string + AutoImportPlaylists bool IgnoredArticles string IndexGroups string @@ -83,6 +84,7 @@ func init() { viper.SetDefault("enabletranscodingconfig", false) viper.SetDefault("transcodingcachesize", "100MB") viper.SetDefault("imagecachesize", "100MB") + viper.SetDefault("autoimportplaylists", true) // Config options only valid for file/env configuration viper.SetDefault("ignoredarticles", "The El La Los Las Le Les Os As O A") diff --git a/scanner/tag_scanner.go b/scanner/tag_scanner.go index 7372f4ca..ddbd91ef 100644 --- a/scanner/tag_scanner.go +++ b/scanner/tag_scanner.go @@ -8,6 +8,7 @@ import ( "strings" "time" + "github.com/deluan/navidrome/conf" "github.com/deluan/navidrome/log" "github.com/deluan/navidrome/model" "github.com/deluan/navidrome/model/request" @@ -104,19 +105,23 @@ func (s *TagScanner) Scan(ctx context.Context, lastModifiedSince time.Time) erro } } - // Now that all mediafiles are imported/updated, search for and import playlists - u, _ := request.UserFrom(ctx) plsCount := 0 - for _, dir := range changedDirs { - info := allFSDirs[dir] - if info.hasPlaylist { - if !u.IsAdmin { - log.Warn("Playlists will not be imported, as there are no admin users yet, "+ - "Please create an admin user first, and then update the playlists for them to be imported", "dir", dir) - } else { - plsCount = s.plsSync.processPlaylists(ctx, dir) + if conf.Server.AutoImportPlaylists { + // Now that all mediafiles are imported/updated, search for and import playlists + u, _ := request.UserFrom(ctx) + for _, dir := range changedDirs { + info := allFSDirs[dir] + if info.hasPlaylist { + if !u.IsAdmin { + log.Warn("Playlists will not be imported, as there are no admin users yet, "+ + "Please create an admin user first, and then update the playlists for them to be imported", "dir", dir) + } else { + plsCount = s.plsSync.processPlaylists(ctx, dir) + } } } + } else { + log.Debug("Playlist auto-import is disabled") } err = s.ds.GC(log.NewContext(ctx))