🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Rename env vars prefix to ND_
Deluanbff6f3a4bd76
diff --git a/Dockerfile b/Dockerfileindex a252f2261..c28c0477e 100644--- a/Dockerfile+++ b/Dockerfile@@ -44,9 +44,9 @@ COPY --from=gobuilder /src/navidrome /app/COPY --from=gobuilder /tmp/ffmpeg*/ffmpeg /usr/bin/VOLUME ["/data", "/music"]-ENV SONIC_DBPATH /data/navidrome.db-ENV SONIC_MUSICFOLDER /music-ENV SONIC_LOGLEVEL info+ENV ND_DBPATH /data/navidrome.db+ENV ND_MUSICFOLDER /music+ENV ND_LOGLEVEL infoEXPOSE 4533WORKDIR /appdiff --git a/README.md b/README.mdindex db9ff6a77..3620d255d 100644--- a/README.md+++ b/README.md@@ -50,10 +50,10 @@ services:- "4533:4533"environment:# All options with their default values:- SONIC_MUSICFOLDER: /music- SONIC_PORT: 4533- SONIC_SCANINTERVAL: 10s- SONIC_LOGLEVEL: debug+ ND_MUSICFOLDER: /music+ ND_PORT: 4533+ ND_SCANINTERVAL: 10s+ ND_LOGLEVEL: debugvolumes:- "./data:/data"- "/Users/deluan/Music/iTunes/iTunes Media/Music:/music"diff --git a/conf/configuration.go b/conf/configuration.goindex 147b7881f..185c371d0 100644--- a/conf/configuration.go+++ b/conf/configuration.go@@ -8,7 +8,7 @@ import ("github.com/koding/multiconfig")-type sonic struct {+type nd struct {Port string `default:"4533"`MusicFolder string `default:"./music"`DbPath string `default:"./data/navidrome.db"`@@ -30,20 +30,20 @@ type sonic struct {DevInitialPassword string `default:""`}-var Sonic *sonic+var Server *ndfunc LoadFromFlags() {l := &multiconfig.FlagLoader{}- l.Load(Sonic)+ l.Load(Server)}func LoadFromEnv() {port := os.Getenv("PORT")if port != "" {- Sonic.Port = port+ Server.Port = port}l := &multiconfig.EnvironmentLoader{}- err := l.Load(Sonic)+ err := l.Load(Server)if err != nil {log.Error("Error parsing configuration from environment")}@@ -51,12 +51,12 @@ func LoadFromEnv() {func LoadFromTags() {l := &multiconfig.TagLoader{}- l.Load(Sonic)+ l.Load(Server)}func LoadFromFile(tomlFile string) {l := &multiconfig.TOMLLoader{Path: tomlFile}- err := l.Load(Sonic)+ err := l.Load(Server)if err != nil {log.Error("Error loading configuration file", "file", tomlFile, err)}@@ -72,10 +72,10 @@ func Load() {LoadFromLocalFile()LoadFromEnv()LoadFromFlags()- log.SetLogLevelString(Sonic.LogLevel)+ log.SetLogLevelString(Server.LogLevel)}func init() {- Sonic = new(sonic)+ Server = new(nd)LoadFromTags()}diff --git a/docker-compose.yml b/docker-compose.ymlindex d45a8b83c..95326d48b 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -8,9 +8,9 @@ services:- "4533:4533"environment:# See all options and defaults in conf/configuration.go- SONIC_PORT: 4533- SONIC_SCANINTERVAL: 5s- SONIC_LOGLEVEL: debug+ ND_PORT: 4533+ ND_SCANINTERVAL: 5s+ ND_LOGLEVEL: debugvolumes:- "./data:/data"- "/Users/deluan/Music/iTunes/iTunes Media/Music:/music"diff --git a/engine/stream.go b/engine/stream.goindex a902f1541..fa12c9a72 100644--- a/engine/stream.go+++ b/engine/stream.go@@ -16,7 +16,7 @@ import (func Stream(ctx context.Context, path string, bitRate int, maxBitRate int, w io.Writer) error {var f io.Readervar err error- enabled := !conf.Sonic.DisableDownsampling+ enabled := !conf.Server.DisableDownsamplingif enabled && maxBitRate > 0 && bitRate > maxBitRate {f, err = downsample(ctx, path, maxBitRate)} else {@@ -46,7 +46,7 @@ func downsample(ctx context.Context, path string, maxBitRate int) (f io.Reader,}func createDownsamplingCommand(path string, maxBitRate int) (string, []string) {- cmd := conf.Sonic.DownsampleCommand+ cmd := conf.Server.DownsampleCommandsplit := strings.Split(cmd, " ")for i, s := range split {diff --git a/main.go b/main.goindex 00530d9a7..175c2c5f5 100644--- a/main.go+++ b/main.go@@ -8,12 +8,12 @@ import (func main() {conf.Load()- if !conf.Sonic.DevDisableBanner {+ if !conf.Server.DevDisableBanner {server.ShowBanner()}- a := CreateServer(conf.Sonic.MusicFolder)+ a := CreateServer(conf.Server.MusicFolder)a.MountRouter("/rest", CreateSubsonicAPIRouter())a.MountRouter("/app", CreateAppRouter("/app"))- a.Run(":" + conf.Sonic.Port)+ a.Run(":" + conf.Server.Port)}diff --git a/persistence/artist_repository.go b/persistence/artist_repository.goindex 29a3fab4c..9b6986ca2 100644--- a/persistence/artist_repository.go+++ b/persistence/artist_repository.go@@ -28,7 +28,7 @@ type artistRepository struct {func NewArtistRepository(o orm.Ormer) model.ArtistRepository {r := &artistRepository{}r.ormer = o- r.indexGroups = utils.ParseIndexGroups(conf.Sonic.IndexGroups)+ r.indexGroups = utils.ParseIndexGroups(conf.Server.IndexGroups)r.tableName = "artist"return r}diff --git a/persistence/mediafolders_repository.go b/persistence/mediafolders_repository.goindex 2b4298333..50932d517 100644--- a/persistence/mediafolders_repository.go+++ b/persistence/mediafolders_repository.go@@ -15,7 +15,7 @@ func NewMediaFolderRepository(o orm.Ormer) model.MediaFolderRepository {}func (*mediaFolderRepository) GetAll() (model.MediaFolders, error) {- mediaFolder := model.MediaFolder{ID: "0", Path: conf.Sonic.MusicFolder}+ mediaFolder := model.MediaFolder{ID: "0", Path: conf.Server.MusicFolder}mediaFolder.Name = "Music Library"result := make(model.MediaFolders, 1)result[0] = mediaFolderdiff --git a/persistence/persistence.go b/persistence/persistence.goindex ceffe1634..308af361a 100644--- a/persistence/persistence.go+++ b/persistence/persistence.go@@ -27,7 +27,7 @@ type SQLStore struct {func New() model.DataStore {once.Do(func() {- dbPath := conf.Sonic.DbPath+ dbPath := conf.Server.DbPathif dbPath == ":memory:" {dbPath = "file::memory:?cache=shared"}@@ -114,7 +114,7 @@ func (db *SQLStore) getOrmer() orm.Ormer {}func initORM(dbPath string) error {- verbose := conf.Sonic.LogLevel == "trace"+ verbose := conf.Server.LogLevel == "trace"orm.Debug = verboseif strings.Contains(dbPath, "postgres") {driver = "postgres"diff --git a/persistence/persistence_suite_test.go b/persistence/persistence_suite_test.goindex 3f72002e2..9a64c7e03 100644--- a/persistence/persistence_suite_test.go+++ b/persistence/persistence_suite_test.go@@ -60,9 +60,9 @@ func P(path string) string {var _ = Describe("Initialize test DB", func() {BeforeSuite(func() {//log.SetLevel(log.LevelTrace)- //conf.Sonic.DbPath, _ = ioutil.TempDir("", "navidrome_tests")- //os.MkdirAll(conf.Sonic.DbPath, 0700)- conf.Sonic.DbPath = ":memory:"+ //conf.Server.DbPath, _ = ioutil.TempDir("", "navidrome_tests")+ //os.MkdirAll(conf.Server.DbPath, 0700)+ conf.Server.DbPath = ":memory:"ds := New()artistRepo := ds.Artist()for _, a := range testArtists {diff --git a/scanner/metadata_ffmpeg.go b/scanner/metadata_ffmpeg.goindex ff453793a..a993095a2 100644--- a/scanner/metadata_ffmpeg.go+++ b/scanner/metadata_ffmpeg.go@@ -216,7 +216,7 @@ func (m *Metadata) parseDuration(tagName string) int {}func createProbeCommand(inputs []string) (string, []string) {- cmd := conf.Sonic.ProbeCommand+ cmd := conf.Server.ProbeCommandsplit := strings.Split(cmd, " ")args := make([]string, 0)diff --git a/scanner/scanner_suite_test.go b/scanner/scanner_suite_test.goindex d87b0d70e..61ac52bde 100644--- a/scanner/scanner_suite_test.go+++ b/scanner/scanner_suite_test.go@@ -20,7 +20,7 @@ func xTestScanner(t *testing.T) {var _ = XDescribe("TODO: REMOVE", func() {It("WORKS!", func() {- conf.Sonic.DbPath = "./testDB"+ conf.Server.DbPath = "./testDB"log.SetLevel(log.LevelDebug)ds := persistence.New()diff --git a/server/app/app.go b/server/app/app.goindex 3f20c2c5e..ca4504aea 100644--- a/server/app/app.go+++ b/server/app/app.go@@ -45,7 +45,7 @@ func (app *Router) routes() http.Handler {r.Post("/login", Login(app.ds))r.Route("/api", func(r chi.Router) {- if !conf.Sonic.DevDisableAuthentication {+ if !conf.Server.DevDisableAuthentication {r.Use(jwtauth.Verifier(TokenAuth))r.Use(Authenticator)}diff --git a/server/initial_setup.go b/server/initial_setup.goindex 5bbb200c4..043f8eee9 100644--- a/server/initial_setup.go+++ b/server/initial_setup.go@@ -53,8 +53,8 @@ func createDefaultUser(ds model.DataStore) error {id, _ := uuid.NewRandom()random, _ := uuid.NewRandom()initialPassword := random.String()- if conf.Sonic.DevInitialPassword != "" {- initialPassword = conf.Sonic.DevInitialPassword+ if conf.Server.DevInitialPassword != "" {+ initialPassword = conf.Server.DevInitialPassword}log.Warn("Creating initial user. Please change the password!", "user", consts.InitialUserName, "password", initialPassword)initialUser := model.User{diff --git a/server/server.go b/server/server.goindex 3aaec6546..4fd51e614 100644--- a/server/server.go+++ b/server/server.go@@ -68,9 +68,9 @@ func (a *Server) initRoutes() {}func (a *Server) initScanner() {- interval, err := time.ParseDuration(conf.Sonic.ScanInterval)+ interval, err := time.ParseDuration(conf.Server.ScanInterval)if err != nil {- log.Error("Invalid interval specification. Using default of 5m", "conf", conf.Sonic.ScanInterval, err)+ log.Error("Invalid interval specification. Using default of 5m", "conf", conf.Server.ScanInterval, err)interval = 5 * time.Minute} else {log.Info("Starting scanner", "interval", interval.String())@@ -80,7 +80,7 @@ func (a *Server) initScanner() {for {err := a.Scanner.RescanAll(false)if err != nil {- log.Error("Error scanning media folder", "folder", conf.Sonic.MusicFolder, err)+ log.Error("Error scanning media folder", "folder", conf.Server.MusicFolder, err)}time.Sleep(interval)}diff --git a/server/subsonic/api.go b/server/subsonic/api.goindex a3d73f664..fe1920eb9 100644--- a/server/subsonic/api.go+++ b/server/subsonic/api.go@@ -48,7 +48,7 @@ func (api *Router) routes() http.Handler {r.Use(checkRequiredParameters)// Add validation middleware if not disabled- if !conf.Sonic.DevDisableAuthentication {+ if !conf.Server.DevDisableAuthentication {r.Use(authenticate(api.Users))// TODO Validate version}diff --git a/server/subsonic/browsing.go b/server/subsonic/browsing.goindex b8565d73d..2d6ec63ad 100644--- a/server/subsonic/browsing.go+++ b/server/subsonic/browsing.go@@ -41,7 +41,7 @@ func (c *BrowsingController) getArtistIndex(r *http.Request, ifModifiedSince tim}res := &responses.Indexes{- IgnoredArticles: conf.Sonic.IgnoredArticles,+ IgnoredArticles: conf.Server.IgnoredArticles,LastModified: fmt.Sprint(utils.ToMillis(lastModified)),}diff --git a/utils/strings.go b/utils/strings.goindex 99e4baa21..b0e6ca0ef 100644--- a/utils/strings.go+++ b/utils/strings.go@@ -7,7 +7,7 @@ import ()func NoArticle(name string) string {- articles := strings.Split(conf.Sonic.IgnoredArticles, " ")+ articles := strings.Split(conf.Server.IgnoredArticles, " ")for _, a := range articles {n := strings.TrimPrefix(name, a+" ")if n != name {