navidrome/conf/configuration.go

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

411 lines
13 KiB
Go
Raw Normal View History

2016-03-30 06:05:57 +02:00
package conf
import (
"fmt"
"net/url"
2016-03-30 06:05:57 +02:00
"os"
"path/filepath"
"runtime"
"strings"
2020-07-02 22:41:54 +02:00
"time"
2016-03-30 06:05:57 +02:00
2020-10-25 03:55:19 +01:00
"github.com/kr/pretty"
2020-01-24 01:44:08 +01:00
"github.com/navidrome/navidrome/consts"
"github.com/navidrome/navidrome/log"
"github.com/robfig/cron/v3"
2020-07-02 22:34:21 +02:00
"github.com/spf13/viper"
2016-03-30 06:05:57 +02:00
)
2020-07-02 23:21:25 +02:00
type configOptions struct {
ConfigFile string
Address string
Port int
UnixSocketPerm string
MusicFolder string
DataFolder string
CacheFolder string
DbPath string
LogLevel string
ScanInterval time.Duration
ScanSchedule string
SessionTimeout time.Duration
BaseURL string
BasePath string
BaseHost string
BaseScheme string
TLSCert string
TLSKey string
UILoginBackgroundURL string
UIWelcomeMessage string
MaxSidebarPlaylists int
EnableTranscodingConfig bool
EnableDownloads bool
EnableExternalServices bool
EnableMediaFileCoverArt bool
TranscodingCacheSize string
ImageCacheSize string
AlbumPlayCountMode string
EnableArtworkPrecache bool
AutoImportPlaylists bool
PlaylistsPath string
AutoTranscodeDownload bool
DefaultDownsamplingFormat string
SearchFullString bool
RecentlyAddedByModTime bool
2023-12-12 02:37:11 +01:00
PreferSortTags bool
IgnoredArticles string
IndexGroups string
SubsonicArtistParticipations bool
FFmpegPath string
Jukebox mode (#2289) * Adding cache directory to ignore-list * Adding jukebox-related config options * Adding DevEnableJukebox config option pls. dummy server * Adding types and routers * Now without panic * First draft on parsing the action * Some cleanups * Adding playback server * Verify audio device configuration * Adding debug-build target to have full symbol support * Adding beep sound library pls some example code. Not working yet * Play a fixed mp3 on any interface access for testing purposes * Put action code into separate file, adding stringer, more debug output, prepare structs, validation * Put action parameter parser code where it belongs * Have a single Action transporting all information * User fmt.Errorf for error-generation * Adding wide playback interface * Use action map for parsing, stringer instead switch stmt. * Use but only one switch case and direct dispatch, refactoring * Add error handling and pushing to client * send decent errormessage, no internal server error * Adding playback devices slice and load it from config * Combine config-verification and structure init * Return user-specific device * Separate playback server from device * Use dataStore to retrieve mediafile by id * WIP: Playlist and start/stop handling. Doing start/stop the hard way as of now * WIP: set, start and stop work on one single song. More to come * Dont need to wait for the end * Merge jukebox_action.go into jukebox.go * Remove getParameterAsInt64(). Use existing requiredParamInt() instead * Dont need to call newFailure() explicitly * Remove int64, use int instead. * Add and set action now accept multiple ids * Kickout copy of childFromMediaFile(). It is not needed here. * Refactoring devices and playbackServer * Turn (internal) playback.DeviceStatus into subsonic JukeboxStatus when rendering output. Indexes int64 -> int * Now we have a position and playing status * Switching gain to float32, xs:float is defined as 32 bit. Fixing nasty copy/pointer bug * Now with volume control * Start working the queue * Remove user from device interface * Rename function GetDevice -> GetDeviceForUser to make intention clearer * Have a nice stringer for the queue * User Prepared boolean for now to allow pause/unpause * Skipping works, but without offsets * Make ChildFromMediaFile public to be used in jukebox get() implementation * Return position in seconds and implement offset-skip in seconds * Default offset to 0 * Adding a simple setGain implementation * Prepare for transcoding AAC * WIP: transcode to WAV to use beeps wav decoder. Not done yet. * WIP: out of sheer desparation: convert to MP3 (which works) rather than WAV to troubleshoot issue. * Use FLAC as intermediate format to play Apple AAC * A bit of cleanup * Catching the end-of-stream event for further reactions * Have a trackSwitching goroutine waiting on channel when track ends * Move decoder code into own file. Restructure code a bit * Now with going on to play the next song in the playlist * Adding shuffle feature * Implementing remove action * Cleanup code * Remove templates for ffmpeg mp3 generation. Not needed anymore. * Adding some documentation * Check whether offset into track is in range. Fixing potential remove track bug. Documentation * Make golangci-lint happy: handling return values * Adding test suite and example dummy for playback package * Adding some basic queue tests * Only use Jukebox.Enabled config option * Adding stream closing handling * Pass context.Context to all PlaybackDevice methods * Remove unneeded function * Correct spelling * Reduce visibility of ChildFromMediaFile * Decomplicate action-parsing * Adding simple tempfile-based AAC->FLAC transcoding. No parallel reading and writing yet. * Try to optimize pipe-writing, tempfile-handling and reading. Not done yet. * Do a synchronous copy of the tempfile. Racecondition detected * More debugging statements and fixing the play/pause bug. More work needed * Start the trackSwitcher() with each device once. Return JSON position even if its 0. More debug-output * Moving all track-handling code into own module * Fix typo. Do not pass ctx around when not applicable * WIP: More refactoring, debugging output * Fix nil pointer * Repairing MP3 playback by pinning indirect dependencies: hajimehoshi/go-mp3 and hajimehoshi/oto * Do not forget to cleanup after a skip action * Make resync with master easy * Adding missing mocks * Adding missing error-handling found by linter * Updating github.com/hajimehoshi/oto * Removing duplicate function * Move BEEP-related code into own package * Juggle beep-related code around as preparation for interface access * More refactoring for interface separation * Gather CloseDevice() behind Track interface. * Adding skeleton, draft audio-interface using mpv.io * Adding majority of interface commands using messages to mpv socket. * Adding end-of-stream handling * MPV: start/stop are working * postition is given in float in mpv * Unify Close() and CloseDevice(). Using temp filename for controlling socket * Wait until control-socket shows up. Cleanup socket in Close() * Use canceable command. Rename to Executor * Skipping tracks works now * Now with actually setting the position * Fix regain * Add missing error-handling found by linter * Adding retry mode on time-pos property getter * Remove unneeded code on queue * Putting build-tag beep onto beep files * Remove deprecated call to rand.Seed() "As of Go 1.20 there is no reason to call Seed with a random value. Programs that call Seed with a known value to get a specific sequence of results should use New(NewSource(seed)) to obtain a local random generator." * Using int32 to conform to Subsonic API spec * Fix merge error * Minor style changes * Get username from context --------- Co-authored-by: Deluan <deluan@navidrome.org>
2023-09-10 17:25:22 +02:00
MPVPath string
MPVCmdTemplate string
CoverArtPriority string
CoverJpegQuality int
ArtistArtPriority string
EnableGravatar bool
EnableFavourites bool
EnableStarRating bool
EnableUserEditing bool
EnableSharing bool
DefaultDownloadableShare bool
DefaultTheme string
DefaultLanguage string
DefaultUIVolume int
EnableReplayGain bool
EnableCoverAnimation bool
GATrackingID string
EnableLogRedacting bool
AuthRequestLimit int
AuthWindowLength time.Duration
PasswordEncryptionKey string
ReverseProxyUserHeader string
ReverseProxyWhitelist string
HTTPSecurityHeaders secureOptions
Prometheus prometheusOptions
Scanner scannerOptions
Jukebox mode (#2289) * Adding cache directory to ignore-list * Adding jukebox-related config options * Adding DevEnableJukebox config option pls. dummy server * Adding types and routers * Now without panic * First draft on parsing the action * Some cleanups * Adding playback server * Verify audio device configuration * Adding debug-build target to have full symbol support * Adding beep sound library pls some example code. Not working yet * Play a fixed mp3 on any interface access for testing purposes * Put action code into separate file, adding stringer, more debug output, prepare structs, validation * Put action parameter parser code where it belongs * Have a single Action transporting all information * User fmt.Errorf for error-generation * Adding wide playback interface * Use action map for parsing, stringer instead switch stmt. * Use but only one switch case and direct dispatch, refactoring * Add error handling and pushing to client * send decent errormessage, no internal server error * Adding playback devices slice and load it from config * Combine config-verification and structure init * Return user-specific device * Separate playback server from device * Use dataStore to retrieve mediafile by id * WIP: Playlist and start/stop handling. Doing start/stop the hard way as of now * WIP: set, start and stop work on one single song. More to come * Dont need to wait for the end * Merge jukebox_action.go into jukebox.go * Remove getParameterAsInt64(). Use existing requiredParamInt() instead * Dont need to call newFailure() explicitly * Remove int64, use int instead. * Add and set action now accept multiple ids * Kickout copy of childFromMediaFile(). It is not needed here. * Refactoring devices and playbackServer * Turn (internal) playback.DeviceStatus into subsonic JukeboxStatus when rendering output. Indexes int64 -> int * Now we have a position and playing status * Switching gain to float32, xs:float is defined as 32 bit. Fixing nasty copy/pointer bug * Now with volume control * Start working the queue * Remove user from device interface * Rename function GetDevice -> GetDeviceForUser to make intention clearer * Have a nice stringer for the queue * User Prepared boolean for now to allow pause/unpause * Skipping works, but without offsets * Make ChildFromMediaFile public to be used in jukebox get() implementation * Return position in seconds and implement offset-skip in seconds * Default offset to 0 * Adding a simple setGain implementation * Prepare for transcoding AAC * WIP: transcode to WAV to use beeps wav decoder. Not done yet. * WIP: out of sheer desparation: convert to MP3 (which works) rather than WAV to troubleshoot issue. * Use FLAC as intermediate format to play Apple AAC * A bit of cleanup * Catching the end-of-stream event for further reactions * Have a trackSwitching goroutine waiting on channel when track ends * Move decoder code into own file. Restructure code a bit * Now with going on to play the next song in the playlist * Adding shuffle feature * Implementing remove action * Cleanup code * Remove templates for ffmpeg mp3 generation. Not needed anymore. * Adding some documentation * Check whether offset into track is in range. Fixing potential remove track bug. Documentation * Make golangci-lint happy: handling return values * Adding test suite and example dummy for playback package * Adding some basic queue tests * Only use Jukebox.Enabled config option * Adding stream closing handling * Pass context.Context to all PlaybackDevice methods * Remove unneeded function * Correct spelling * Reduce visibility of ChildFromMediaFile * Decomplicate action-parsing * Adding simple tempfile-based AAC->FLAC transcoding. No parallel reading and writing yet. * Try to optimize pipe-writing, tempfile-handling and reading. Not done yet. * Do a synchronous copy of the tempfile. Racecondition detected * More debugging statements and fixing the play/pause bug. More work needed * Start the trackSwitcher() with each device once. Return JSON position even if its 0. More debug-output * Moving all track-handling code into own module * Fix typo. Do not pass ctx around when not applicable * WIP: More refactoring, debugging output * Fix nil pointer * Repairing MP3 playback by pinning indirect dependencies: hajimehoshi/go-mp3 and hajimehoshi/oto * Do not forget to cleanup after a skip action * Make resync with master easy * Adding missing mocks * Adding missing error-handling found by linter * Updating github.com/hajimehoshi/oto * Removing duplicate function * Move BEEP-related code into own package * Juggle beep-related code around as preparation for interface access * More refactoring for interface separation * Gather CloseDevice() behind Track interface. * Adding skeleton, draft audio-interface using mpv.io * Adding majority of interface commands using messages to mpv socket. * Adding end-of-stream handling * MPV: start/stop are working * postition is given in float in mpv * Unify Close() and CloseDevice(). Using temp filename for controlling socket * Wait until control-socket shows up. Cleanup socket in Close() * Use canceable command. Rename to Executor * Skipping tracks works now * Now with actually setting the position * Fix regain * Add missing error-handling found by linter * Adding retry mode on time-pos property getter * Remove unneeded code on queue * Putting build-tag beep onto beep files * Remove deprecated call to rand.Seed() "As of Go 1.20 there is no reason to call Seed with a random value. Programs that call Seed with a known value to get a specific sequence of results should use New(NewSource(seed)) to obtain a local random generator." * Using int32 to conform to Subsonic API spec * Fix merge error * Minor style changes * Get username from context --------- Co-authored-by: Deluan <deluan@navidrome.org>
2023-09-10 17:25:22 +02:00
Jukebox jukeboxOptions
2021-02-07 22:46:15 +01:00
Agents string
LastFM lastfmOptions
Spotify spotifyOptions
ListenBrainz listenBrainzOptions
// DevFlags. These are used to enable/disable debugging and incomplete features
DevLogSourceLine bool
DevLogLevels map[string]string
DevEnableProfiler bool
DevAutoCreateAdminPassword string
DevAutoLoginUsername string
DevActivityPanel bool
DevSidebarPlaylists bool
DevEnableBufferedScrobble bool
DevShowArtistPage bool
DevOffsetOptimize int
DevArtworkMaxRequests int
DevArtworkThrottleBacklogLimit int
DevArtworkThrottleBacklogTimeout time.Duration
DevArtistInfoTimeToLive time.Duration
DevAlbumInfoTimeToLive time.Duration
2016-03-30 06:05:57 +02:00
}
type scannerOptions struct {
Support for Original Date, Release Date & splitting/grouping of album editions (#2162) * Update AlbumGridView.js * Update AlbumDetails.js * Update AlbumDetails.js * Create DoubleRangeField.js * Update and rename DoubleRangeField.js to RangeFieldDouble.js * Update RangeFieldDouble.js * Update AlbumGridView.js * Update AlbumDetails.js * Update RangeFieldDouble.js * Update index.js * Update RangeFieldDouble.js * Update RangeFieldDouble.js * Update RangeFieldDouble.js * Update RangeFieldDouble.js * Update RangeFieldDouble.js * Update AlbumDetails.js * Update RangeFieldDouble.js * Update AlbumDetails.js * Update RangeFieldDouble.js * Update AlbumDetails.js * Update RangeFieldDouble.js * Update RangeFieldDouble.js * Update AlbumDetails.js * Update AlbumDetails.js * Update RangeFieldDouble.js * Update RangeFieldDouble.js * Update AlbumDetails.js * Update RangeFieldDouble.js * Update AlbumDetails.js * Update en.json * Update en.json * Update AlbumDetails.js * Update RangeFieldDouble.js * Update AlbumGridView.js * Update AlbumDetails.js * Update AlbumSongs.js * Update ContextMenus.js * Update SongDatagrid.js * Update AlbumSongs.js * Update SongDatagrid.js * Update SongDatagrid.js * Update SongDatagrid.js * Update AlbumSongs.js * Update SongList.js * Update playlist_track_repository.go * Update 20230113000000_release_year.go * Update PlayButton.js * Update mediafile_repository.go * Update album.go * Update playlist_track_repository.go * Update playlist_track_repository.go * Update SongDatagrid.js * Update 20230113000000_release_year.go * Update SongDatagrid.js * Update AlbumSongs.js * Update SongDatagrid.js * Update SongDatagrid.js * Update SongDatagrid.js * Update SongDatagrid.js * Update AlbumDetails.js * Update AlbumSongs.js * Update AlbumSongs.js * Update RangeFieldDouble.js * Update SongDatagrid.js * Update 20230113000000_release_year.go * Update 20230113000000_release_year.go * Update 20230113000000_release_year.go * Update 20230113000000_release_year.go * Update AlbumSongs.js * Update AlbumSongs.js * Update mapping.go * Update RangeFieldDouble.js * Update AlbumGridView.js * Update AlbumSongs.js * Update en.json * Update SongDatagrid.js * Update SongDatagrid.js * Update metadata.go * Update mapping.go * Update AlbumDetails.js * Update AlbumGridView.js * Update RangeFieldDouble.js * Update mapping.go * Update metadata.go * Update mapping.go * Update AlbumDetails.js * Update 20230113000000_release_year.go * Update AlbumDetails.js * Update en.json * Update configuration.go * Update mapping.go * Update configuration.go * Update mediafile.go * Update metadata.go * Update RangeFieldDouble.js * Update 20230113000000_release_year.go * Update configuration.go * Update mapping.go * Update mediafile.go * Update mapping.go * Update RangeFieldDouble.js * Update RangeFieldDouble.js * Update RangeFieldDouble.js * Update RangeFieldDouble.js * Update RangeFieldDouble.js * Update 20230113000000_release_year.go * Update AlbumDetails.js * Update RangeFieldDouble.js * Update mapping.go * Update metadata.go * Update album.go * Update mediafile.go * Update mediafile.go * Update album.go * Update fields.go * Update mediafile_repository.go * Update playlist_track_repository.go * Update AlbumSongs.js * Update SongDatagrid.js * Update PlayButton.js * Update SongList.js * Update ContextMenus.js * Update SongDatagrid.js * Update metadata.go * Update ArtistShow.js * Update mapping.go * Update configuration.go * Update mapping.go * Update metadata.go * Update metadata.go * Update mapping.go * Update metadata.go * Update metadata.go * Update mapping.go * Update 20230113000000_release_year.go * Update 20230113000000_release_year.go * Update mapping.go * Update metadata.go * Update metadata.go * Update album.go * Update mediafile.go * Update AlbumDetails.js * Update AlbumSongs.js * Update album.go * Update mediafile.go * Update metadata.go * Update mediafile.go * Update 20230113000000_release_year.go * Update 20230113000000_release_year.go * Update album.go * Update mediafile.go * Update RangeFieldDouble.js * Update AlbumDetails.js * Update AlbumGridView.js * Update en.json * Update AlbumGridView.js * Update RangeFieldDouble.js * Update and rename 20230113000000_release_year.go to 20230113000000_release_date.go * Update album.go * Update mediafile.go * Update fields.go * Update playlist_track_repository.go * Update mediafile_repository.go * Update mapping.go * Update metadata.go * Update mapping.go * Update SongDatagrid.js * Update RangeFieldDouble.js * Update index.js * Update ContextMenus.js * Update PlayButton.js * Create FormatDate.js * Update SongList.js * Update AlbumDetails.js * Update AlbumSongs.js * Update AlbumSongs.js * Update en.json * Update AlbumDetails.js * Update album.go fixed conflict I think? * Update mediafile.go fixed conflict * Format with goimports * Update SongDatagrid.js only show Cat # in desktop view * Update metadata_internal_test.go * Update metadata_test.go * Delete test.mp3 * Add files via upload mp3 test file with Date, Original Date and Release Date * Update metadata_test.go * Update metadata_test.go * Update metadata_test.go * Update metadata_test.go * Update taglib_test.go * Delete test.mp3 * Add files via upload file with replaygain & dates * Update AlbumGridView.js * Update AlbumDetails.js * Update AlbumSongs.js * Update ContextMenus.js * Update FormatDate.js * Update PlayButton.js * Update RangeFieldDouble.js * Update SongDatagrid.js * Update AlbumSongs.js * Update SongDatagrid.js * Update AlbumSongs.js * Fix formatting * Update mapping.go * Update AlbumSongs.js * Update SongDatagrid.js * Update SongDatagrid.js prettier * Create RangeDoubleField.js rename of RangeFieldDouble.js * Update AlbumGridView.js RangeFieldDouble -> RangeDoubleField * Update mediafile.go AllOrNothing() -> allOrNothing() * Update metadata_internal_test.go getYear -> getDate * Update AlbumDetails.js wrote suggested changes * Update en.json Editions -> Releases & fixed the field name * Update configuration.go Rename Editions -> Releases * Update 20230113000000_release_date.go Editions -> Releases * Update album.go Editions -> Releases * Update mediafile.go Editions -> Releases * Update AlbumDetails.js Editions -> Releases * Update AlbumSongs.js Editions -> Releases * Update RangeDoubleField.js Editions -> Releases * Update SongDatagrid.js Editions -> Releases * Update index.js FormatFullDate and RangeDoubleField * Rename FormatDate.js to FormatFullDate.js * Delete RangeFieldDouble.js * Update mediafile.go AllOrNothing -> allOrNothing * Update mapping.go Editions -> Releases * Update AlbumDetails.js prettier * Update SongDatagrid.js showReleaseRow -> showReleaseDivider * Update AlbumSongs.js showReleaseRow -> showReleaseDivider for clarity * Update and rename 20230113000000_release_date.go to 20230515184510_add_release_date.go - rename the migration file - fixed the import to goose/v3 - additional db fields for original date & year * Update 20230515184510_add_release_date.go * Update fields.go * Update album.go * Update mediafile.go * Update mapping.go * Update AlbumDetails.js * Update en.json * Update AlbumDetails.js * Update AlbumDetails.js now hopefully prettier * Update mapping.go --------- Co-authored-by: Deluan <deluan@navidrome.org>
2023-05-19 21:27:47 +02:00
Extractor string
GenreSeparators string
GroupAlbumReleases bool
}
type lastfmOptions struct {
Enabled bool
ApiKey string
Secret string
Language string
}
type spotifyOptions struct {
ID string
Secret string
}
type listenBrainzOptions struct {
Enabled bool
BaseURL string
}
type secureOptions struct {
CustomFrameOptionsValue string
}
type prometheusOptions struct {
Enabled bool
MetricsPath string
}
Jukebox mode (#2289) * Adding cache directory to ignore-list * Adding jukebox-related config options * Adding DevEnableJukebox config option pls. dummy server * Adding types and routers * Now without panic * First draft on parsing the action * Some cleanups * Adding playback server * Verify audio device configuration * Adding debug-build target to have full symbol support * Adding beep sound library pls some example code. Not working yet * Play a fixed mp3 on any interface access for testing purposes * Put action code into separate file, adding stringer, more debug output, prepare structs, validation * Put action parameter parser code where it belongs * Have a single Action transporting all information * User fmt.Errorf for error-generation * Adding wide playback interface * Use action map for parsing, stringer instead switch stmt. * Use but only one switch case and direct dispatch, refactoring * Add error handling and pushing to client * send decent errormessage, no internal server error * Adding playback devices slice and load it from config * Combine config-verification and structure init * Return user-specific device * Separate playback server from device * Use dataStore to retrieve mediafile by id * WIP: Playlist and start/stop handling. Doing start/stop the hard way as of now * WIP: set, start and stop work on one single song. More to come * Dont need to wait for the end * Merge jukebox_action.go into jukebox.go * Remove getParameterAsInt64(). Use existing requiredParamInt() instead * Dont need to call newFailure() explicitly * Remove int64, use int instead. * Add and set action now accept multiple ids * Kickout copy of childFromMediaFile(). It is not needed here. * Refactoring devices and playbackServer * Turn (internal) playback.DeviceStatus into subsonic JukeboxStatus when rendering output. Indexes int64 -> int * Now we have a position and playing status * Switching gain to float32, xs:float is defined as 32 bit. Fixing nasty copy/pointer bug * Now with volume control * Start working the queue * Remove user from device interface * Rename function GetDevice -> GetDeviceForUser to make intention clearer * Have a nice stringer for the queue * User Prepared boolean for now to allow pause/unpause * Skipping works, but without offsets * Make ChildFromMediaFile public to be used in jukebox get() implementation * Return position in seconds and implement offset-skip in seconds * Default offset to 0 * Adding a simple setGain implementation * Prepare for transcoding AAC * WIP: transcode to WAV to use beeps wav decoder. Not done yet. * WIP: out of sheer desparation: convert to MP3 (which works) rather than WAV to troubleshoot issue. * Use FLAC as intermediate format to play Apple AAC * A bit of cleanup * Catching the end-of-stream event for further reactions * Have a trackSwitching goroutine waiting on channel when track ends * Move decoder code into own file. Restructure code a bit * Now with going on to play the next song in the playlist * Adding shuffle feature * Implementing remove action * Cleanup code * Remove templates for ffmpeg mp3 generation. Not needed anymore. * Adding some documentation * Check whether offset into track is in range. Fixing potential remove track bug. Documentation * Make golangci-lint happy: handling return values * Adding test suite and example dummy for playback package * Adding some basic queue tests * Only use Jukebox.Enabled config option * Adding stream closing handling * Pass context.Context to all PlaybackDevice methods * Remove unneeded function * Correct spelling * Reduce visibility of ChildFromMediaFile * Decomplicate action-parsing * Adding simple tempfile-based AAC->FLAC transcoding. No parallel reading and writing yet. * Try to optimize pipe-writing, tempfile-handling and reading. Not done yet. * Do a synchronous copy of the tempfile. Racecondition detected * More debugging statements and fixing the play/pause bug. More work needed * Start the trackSwitcher() with each device once. Return JSON position even if its 0. More debug-output * Moving all track-handling code into own module * Fix typo. Do not pass ctx around when not applicable * WIP: More refactoring, debugging output * Fix nil pointer * Repairing MP3 playback by pinning indirect dependencies: hajimehoshi/go-mp3 and hajimehoshi/oto * Do not forget to cleanup after a skip action * Make resync with master easy * Adding missing mocks * Adding missing error-handling found by linter * Updating github.com/hajimehoshi/oto * Removing duplicate function * Move BEEP-related code into own package * Juggle beep-related code around as preparation for interface access * More refactoring for interface separation * Gather CloseDevice() behind Track interface. * Adding skeleton, draft audio-interface using mpv.io * Adding majority of interface commands using messages to mpv socket. * Adding end-of-stream handling * MPV: start/stop are working * postition is given in float in mpv * Unify Close() and CloseDevice(). Using temp filename for controlling socket * Wait until control-socket shows up. Cleanup socket in Close() * Use canceable command. Rename to Executor * Skipping tracks works now * Now with actually setting the position * Fix regain * Add missing error-handling found by linter * Adding retry mode on time-pos property getter * Remove unneeded code on queue * Putting build-tag beep onto beep files * Remove deprecated call to rand.Seed() "As of Go 1.20 there is no reason to call Seed with a random value. Programs that call Seed with a known value to get a specific sequence of results should use New(NewSource(seed)) to obtain a local random generator." * Using int32 to conform to Subsonic API spec * Fix merge error * Minor style changes * Get username from context --------- Co-authored-by: Deluan <deluan@navidrome.org>
2023-09-10 17:25:22 +02:00
type AudioDeviceDefinition []string
type jukeboxOptions struct {
Enabled bool
Devices []AudioDeviceDefinition
Default string
AdminOnly bool
Jukebox mode (#2289) * Adding cache directory to ignore-list * Adding jukebox-related config options * Adding DevEnableJukebox config option pls. dummy server * Adding types and routers * Now without panic * First draft on parsing the action * Some cleanups * Adding playback server * Verify audio device configuration * Adding debug-build target to have full symbol support * Adding beep sound library pls some example code. Not working yet * Play a fixed mp3 on any interface access for testing purposes * Put action code into separate file, adding stringer, more debug output, prepare structs, validation * Put action parameter parser code where it belongs * Have a single Action transporting all information * User fmt.Errorf for error-generation * Adding wide playback interface * Use action map for parsing, stringer instead switch stmt. * Use but only one switch case and direct dispatch, refactoring * Add error handling and pushing to client * send decent errormessage, no internal server error * Adding playback devices slice and load it from config * Combine config-verification and structure init * Return user-specific device * Separate playback server from device * Use dataStore to retrieve mediafile by id * WIP: Playlist and start/stop handling. Doing start/stop the hard way as of now * WIP: set, start and stop work on one single song. More to come * Dont need to wait for the end * Merge jukebox_action.go into jukebox.go * Remove getParameterAsInt64(). Use existing requiredParamInt() instead * Dont need to call newFailure() explicitly * Remove int64, use int instead. * Add and set action now accept multiple ids * Kickout copy of childFromMediaFile(). It is not needed here. * Refactoring devices and playbackServer * Turn (internal) playback.DeviceStatus into subsonic JukeboxStatus when rendering output. Indexes int64 -> int * Now we have a position and playing status * Switching gain to float32, xs:float is defined as 32 bit. Fixing nasty copy/pointer bug * Now with volume control * Start working the queue * Remove user from device interface * Rename function GetDevice -> GetDeviceForUser to make intention clearer * Have a nice stringer for the queue * User Prepared boolean for now to allow pause/unpause * Skipping works, but without offsets * Make ChildFromMediaFile public to be used in jukebox get() implementation * Return position in seconds and implement offset-skip in seconds * Default offset to 0 * Adding a simple setGain implementation * Prepare for transcoding AAC * WIP: transcode to WAV to use beeps wav decoder. Not done yet. * WIP: out of sheer desparation: convert to MP3 (which works) rather than WAV to troubleshoot issue. * Use FLAC as intermediate format to play Apple AAC * A bit of cleanup * Catching the end-of-stream event for further reactions * Have a trackSwitching goroutine waiting on channel when track ends * Move decoder code into own file. Restructure code a bit * Now with going on to play the next song in the playlist * Adding shuffle feature * Implementing remove action * Cleanup code * Remove templates for ffmpeg mp3 generation. Not needed anymore. * Adding some documentation * Check whether offset into track is in range. Fixing potential remove track bug. Documentation * Make golangci-lint happy: handling return values * Adding test suite and example dummy for playback package * Adding some basic queue tests * Only use Jukebox.Enabled config option * Adding stream closing handling * Pass context.Context to all PlaybackDevice methods * Remove unneeded function * Correct spelling * Reduce visibility of ChildFromMediaFile * Decomplicate action-parsing * Adding simple tempfile-based AAC->FLAC transcoding. No parallel reading and writing yet. * Try to optimize pipe-writing, tempfile-handling and reading. Not done yet. * Do a synchronous copy of the tempfile. Racecondition detected * More debugging statements and fixing the play/pause bug. More work needed * Start the trackSwitcher() with each device once. Return JSON position even if its 0. More debug-output * Moving all track-handling code into own module * Fix typo. Do not pass ctx around when not applicable * WIP: More refactoring, debugging output * Fix nil pointer * Repairing MP3 playback by pinning indirect dependencies: hajimehoshi/go-mp3 and hajimehoshi/oto * Do not forget to cleanup after a skip action * Make resync with master easy * Adding missing mocks * Adding missing error-handling found by linter * Updating github.com/hajimehoshi/oto * Removing duplicate function * Move BEEP-related code into own package * Juggle beep-related code around as preparation for interface access * More refactoring for interface separation * Gather CloseDevice() behind Track interface. * Adding skeleton, draft audio-interface using mpv.io * Adding majority of interface commands using messages to mpv socket. * Adding end-of-stream handling * MPV: start/stop are working * postition is given in float in mpv * Unify Close() and CloseDevice(). Using temp filename for controlling socket * Wait until control-socket shows up. Cleanup socket in Close() * Use canceable command. Rename to Executor * Skipping tracks works now * Now with actually setting the position * Fix regain * Add missing error-handling found by linter * Adding retry mode on time-pos property getter * Remove unneeded code on queue * Putting build-tag beep onto beep files * Remove deprecated call to rand.Seed() "As of Go 1.20 there is no reason to call Seed with a random value. Programs that call Seed with a known value to get a specific sequence of results should use New(NewSource(seed)) to obtain a local random generator." * Using int32 to conform to Subsonic API spec * Fix merge error * Minor style changes * Get username from context --------- Co-authored-by: Deluan <deluan@navidrome.org>
2023-09-10 17:25:22 +02:00
}
2021-02-07 22:46:15 +01:00
var (
Server = &configOptions{}
hooks []func()
)
2020-01-08 16:25:23 +01:00
2020-07-02 22:34:21 +02:00
func LoadFromFile(confFile string) {
viper.SetConfigFile(confFile)
err := viper.ReadInConfig()
if err != nil {
_, _ = fmt.Fprintln(os.Stderr, "FATAL: Error reading config file:", err)
os.Exit(1)
}
2020-07-02 22:34:21 +02:00
Load()
}
2020-07-02 22:34:21 +02:00
func Load() {
err := viper.Unmarshal(&Server)
if err != nil {
_, _ = fmt.Fprintln(os.Stderr, "FATAL: Error parsing config:", err)
2020-07-02 22:34:21 +02:00
os.Exit(1)
}
err = os.MkdirAll(Server.DataFolder, os.ModePerm)
if err != nil {
_, _ = fmt.Fprintln(os.Stderr, "FATAL: Error creating data path:", "path", Server.DataFolder, err)
os.Exit(1)
}
if Server.CacheFolder == "" {
Server.CacheFolder = filepath.Join(Server.DataFolder, "cache")
}
err = os.MkdirAll(Server.CacheFolder, os.ModePerm)
if err != nil {
_, _ = fmt.Fprintln(os.Stderr, "FATAL: Error creating cache path:", "path", Server.CacheFolder, err)
os.Exit(1)
}
2020-07-02 22:34:21 +02:00
Server.ConfigFile = viper.GetViper().ConfigFileUsed()
if Server.DbPath == "" {
Server.DbPath = filepath.Join(Server.DataFolder, consts.DefaultDbPath)
}
2020-07-02 22:34:21 +02:00
log.SetLevelString(Server.LogLevel)
log.SetLogLevels(Server.DevLogLevels)
log.SetLogSourceLine(Server.DevLogSourceLine)
log.SetRedacting(Server.EnableLogRedacting)
if err := validateScanSchedule(); err != nil {
os.Exit(1)
}
if Server.BaseURL != "" {
u, err := url.Parse(Server.BaseURL)
if err != nil {
_, _ = fmt.Fprintf(os.Stderr, "FATAL: Invalid BaseURL %s: %s\n", Server.BaseURL, err.Error())
os.Exit(1)
}
Server.BasePath = u.Path
u.Path = ""
u.RawQuery = ""
Server.BaseHost = u.Host
Server.BaseScheme = u.Scheme
}
// Print current configuration if log level is Debug
if log.IsGreaterOrEqualTo(log.LevelDebug) {
prettyConf := pretty.Sprintf("Loaded configuration from '%s': %# v", Server.ConfigFile, Server)
if Server.EnableLogRedacting {
prettyConf = log.Redact(prettyConf)
}
_, _ = fmt.Fprintln(os.Stderr, prettyConf)
}
2021-02-07 22:46:15 +01:00
if !Server.EnableExternalServices {
disableExternalServices()
}
2021-02-07 22:46:15 +01:00
// Call init hooks
for _, hook := range hooks {
hook()
}
}
func disableExternalServices() {
log.Info("All external integrations are DISABLED!")
Server.LastFM.Enabled = false
Server.Spotify.ID = ""
Server.ListenBrainz.Enabled = false
Server.Agents = ""
if Server.UILoginBackgroundURL == consts.DefaultUILoginBackgroundURL {
Server.UILoginBackgroundURL = consts.DefaultUILoginBackgroundURLOffline
}
}
func validateScanSchedule() error {
if Server.ScanInterval != -1 {
log.Warn("ScanInterval is DEPRECATED. Please use ScanSchedule. See docs at https://navidrome.org/docs/usage/configuration-options/")
if Server.ScanSchedule != "@every 1m" {
log.Error("You cannot specify both ScanInterval and ScanSchedule, ignoring ScanInterval")
} else {
if Server.ScanInterval == 0 {
Server.ScanSchedule = ""
} else {
Server.ScanSchedule = fmt.Sprintf("@every %s", Server.ScanInterval)
}
log.Warn("Setting ScanSchedule", "schedule", Server.ScanSchedule)
}
}
if Server.ScanSchedule == "0" || Server.ScanSchedule == "" {
Server.ScanSchedule = ""
2021-05-07 02:49:26 +02:00
return nil
}
if _, err := time.ParseDuration(Server.ScanSchedule); err == nil {
Server.ScanSchedule = "@every " + Server.ScanSchedule
}
c := cron.New()
_, err := c.AddFunc(Server.ScanSchedule, func() {})
if err != nil {
log.Error("Invalid ScanSchedule. Please read format spec at https://pkg.go.dev/github.com/robfig/cron#hdr-CRON_Expression_Format", "schedule", Server.ScanSchedule, err)
}
2021-05-07 02:49:26 +02:00
return err
}
2021-02-07 22:46:15 +01:00
// AddHook is used to register initialization code that should run as soon as the config is loaded
func AddHook(hook func()) {
hooks = append(hooks, hook)
2016-03-30 06:05:57 +02:00
}
2020-07-02 23:21:25 +02:00
func init() {
2020-07-28 14:49:07 +02:00
viper.SetDefault("musicfolder", filepath.Join(".", "music"))
viper.SetDefault("cachefolder", "")
2020-07-28 14:49:07 +02:00
viper.SetDefault("datafolder", ".")
2020-07-02 22:34:21 +02:00
viper.SetDefault("loglevel", "info")
viper.SetDefault("address", "0.0.0.0")
2020-07-02 22:34:21 +02:00
viper.SetDefault("port", 4533)
viper.SetDefault("unixsocketperm", "0660")
2020-07-02 22:41:54 +02:00
viper.SetDefault("sessiontimeout", consts.DefaultSessionTimeout)
viper.SetDefault("scaninterval", -1)
viper.SetDefault("scanschedule", "@every 1m")
2020-07-02 22:34:21 +02:00
viper.SetDefault("baseurl", "")
viper.SetDefault("tlscert", "")
viper.SetDefault("tlskey", "")
2021-03-24 15:21:31 +01:00
viper.SetDefault("uiloginbackgroundurl", consts.DefaultUILoginBackgroundURL)
viper.SetDefault("uiwelcomemessage", "")
viper.SetDefault("maxsidebarplaylists", consts.DefaultMaxSidebarPlaylists)
2020-07-02 22:34:21 +02:00
viper.SetDefault("enabletranscodingconfig", false)
viper.SetDefault("transcodingcachesize", "100MB")
viper.SetDefault("imagecachesize", "100MB")
viper.SetDefault("albumplaycountmode", consts.AlbumPlayCountModeAbsolute)
viper.SetDefault("enableartworkprecache", true)
2020-08-03 05:17:13 +02:00
viper.SetDefault("autoimportplaylists", true)
viper.SetDefault("playlistspath", consts.DefaultPlaylistsPath)
viper.SetDefault("enabledownloads", true)
viper.SetDefault("enableexternalservices", true)
viper.SetDefault("enablemediafilecoverart", true)
viper.SetDefault("autotranscodedownload", false)
viper.SetDefault("defaultdownsamplingformat", consts.DefaultDownsamplingFormat)
viper.SetDefault("searchfullstring", false)
viper.SetDefault("recentlyaddedbymodtime", false)
2023-12-12 02:37:11 +01:00
viper.SetDefault("prefersorttags", false)
2020-07-02 22:34:21 +02:00
viper.SetDefault("ignoredarticles", "The El La Los Las Le Les Os As O A")
viper.SetDefault("indexgroups", "A B C D E F G H I J K L M N O P Q R S T U V W X-Z(XYZ) [Unknown]([)")
viper.SetDefault("subsonicartistparticipations", false)
viper.SetDefault("ffmpegpath", "")
viper.SetDefault("mpvcmdtemplate", "mpv --audio-device=%d --no-audio-display --pause %f --input-ipc-server=%s")
viper.SetDefault("coverartpriority", "cover.*, folder.*, front.*, embedded, external")
2020-07-02 22:34:21 +02:00
viper.SetDefault("coverjpegquality", 75)
viper.SetDefault("artistartpriority", "artist.*, album/artist.*, external")
viper.SetDefault("enablegravatar", false)
viper.SetDefault("enablefavourites", true)
viper.SetDefault("enablestarrating", true)
viper.SetDefault("enableuserediting", true)
2021-04-18 19:51:00 +02:00
viper.SetDefault("defaulttheme", "Dark")
viper.SetDefault("defaultlanguage", "")
viper.SetDefault("defaultuivolume", consts.DefaultUIVolume)
viper.SetDefault("enablereplaygain", true)
viper.SetDefault("enablecoveranimation", true)
viper.SetDefault("gatrackingid", "")
2021-05-02 22:49:20 +02:00
viper.SetDefault("enablelogredacting", true)
viper.SetDefault("authrequestlimit", 5)
viper.SetDefault("authwindowlength", 20*time.Second)
viper.SetDefault("passwordencryptionkey", "")
2020-07-02 22:34:21 +02:00
viper.SetDefault("reverseproxyuserheader", "Remote-User")
viper.SetDefault("reverseproxywhitelist", "")
viper.SetDefault("prometheus.enabled", false)
viper.SetDefault("prometheus.metricspath", "/metrics")
Jukebox mode (#2289) * Adding cache directory to ignore-list * Adding jukebox-related config options * Adding DevEnableJukebox config option pls. dummy server * Adding types and routers * Now without panic * First draft on parsing the action * Some cleanups * Adding playback server * Verify audio device configuration * Adding debug-build target to have full symbol support * Adding beep sound library pls some example code. Not working yet * Play a fixed mp3 on any interface access for testing purposes * Put action code into separate file, adding stringer, more debug output, prepare structs, validation * Put action parameter parser code where it belongs * Have a single Action transporting all information * User fmt.Errorf for error-generation * Adding wide playback interface * Use action map for parsing, stringer instead switch stmt. * Use but only one switch case and direct dispatch, refactoring * Add error handling and pushing to client * send decent errormessage, no internal server error * Adding playback devices slice and load it from config * Combine config-verification and structure init * Return user-specific device * Separate playback server from device * Use dataStore to retrieve mediafile by id * WIP: Playlist and start/stop handling. Doing start/stop the hard way as of now * WIP: set, start and stop work on one single song. More to come * Dont need to wait for the end * Merge jukebox_action.go into jukebox.go * Remove getParameterAsInt64(). Use existing requiredParamInt() instead * Dont need to call newFailure() explicitly * Remove int64, use int instead. * Add and set action now accept multiple ids * Kickout copy of childFromMediaFile(). It is not needed here. * Refactoring devices and playbackServer * Turn (internal) playback.DeviceStatus into subsonic JukeboxStatus when rendering output. Indexes int64 -> int * Now we have a position and playing status * Switching gain to float32, xs:float is defined as 32 bit. Fixing nasty copy/pointer bug * Now with volume control * Start working the queue * Remove user from device interface * Rename function GetDevice -> GetDeviceForUser to make intention clearer * Have a nice stringer for the queue * User Prepared boolean for now to allow pause/unpause * Skipping works, but without offsets * Make ChildFromMediaFile public to be used in jukebox get() implementation * Return position in seconds and implement offset-skip in seconds * Default offset to 0 * Adding a simple setGain implementation * Prepare for transcoding AAC * WIP: transcode to WAV to use beeps wav decoder. Not done yet. * WIP: out of sheer desparation: convert to MP3 (which works) rather than WAV to troubleshoot issue. * Use FLAC as intermediate format to play Apple AAC * A bit of cleanup * Catching the end-of-stream event for further reactions * Have a trackSwitching goroutine waiting on channel when track ends * Move decoder code into own file. Restructure code a bit * Now with going on to play the next song in the playlist * Adding shuffle feature * Implementing remove action * Cleanup code * Remove templates for ffmpeg mp3 generation. Not needed anymore. * Adding some documentation * Check whether offset into track is in range. Fixing potential remove track bug. Documentation * Make golangci-lint happy: handling return values * Adding test suite and example dummy for playback package * Adding some basic queue tests * Only use Jukebox.Enabled config option * Adding stream closing handling * Pass context.Context to all PlaybackDevice methods * Remove unneeded function * Correct spelling * Reduce visibility of ChildFromMediaFile * Decomplicate action-parsing * Adding simple tempfile-based AAC->FLAC transcoding. No parallel reading and writing yet. * Try to optimize pipe-writing, tempfile-handling and reading. Not done yet. * Do a synchronous copy of the tempfile. Racecondition detected * More debugging statements and fixing the play/pause bug. More work needed * Start the trackSwitcher() with each device once. Return JSON position even if its 0. More debug-output * Moving all track-handling code into own module * Fix typo. Do not pass ctx around when not applicable * WIP: More refactoring, debugging output * Fix nil pointer * Repairing MP3 playback by pinning indirect dependencies: hajimehoshi/go-mp3 and hajimehoshi/oto * Do not forget to cleanup after a skip action * Make resync with master easy * Adding missing mocks * Adding missing error-handling found by linter * Updating github.com/hajimehoshi/oto * Removing duplicate function * Move BEEP-related code into own package * Juggle beep-related code around as preparation for interface access * More refactoring for interface separation * Gather CloseDevice() behind Track interface. * Adding skeleton, draft audio-interface using mpv.io * Adding majority of interface commands using messages to mpv socket. * Adding end-of-stream handling * MPV: start/stop are working * postition is given in float in mpv * Unify Close() and CloseDevice(). Using temp filename for controlling socket * Wait until control-socket shows up. Cleanup socket in Close() * Use canceable command. Rename to Executor * Skipping tracks works now * Now with actually setting the position * Fix regain * Add missing error-handling found by linter * Adding retry mode on time-pos property getter * Remove unneeded code on queue * Putting build-tag beep onto beep files * Remove deprecated call to rand.Seed() "As of Go 1.20 there is no reason to call Seed with a random value. Programs that call Seed with a known value to get a specific sequence of results should use New(NewSource(seed)) to obtain a local random generator." * Using int32 to conform to Subsonic API spec * Fix merge error * Minor style changes * Get username from context --------- Co-authored-by: Deluan <deluan@navidrome.org>
2023-09-10 17:25:22 +02:00
viper.SetDefault("jukebox.enabled", false)
viper.SetDefault("jukebox.devices", []AudioDeviceDefinition{})
viper.SetDefault("jukebox.default", "")
viper.SetDefault("jukebox.adminonly", true)
Jukebox mode (#2289) * Adding cache directory to ignore-list * Adding jukebox-related config options * Adding DevEnableJukebox config option pls. dummy server * Adding types and routers * Now without panic * First draft on parsing the action * Some cleanups * Adding playback server * Verify audio device configuration * Adding debug-build target to have full symbol support * Adding beep sound library pls some example code. Not working yet * Play a fixed mp3 on any interface access for testing purposes * Put action code into separate file, adding stringer, more debug output, prepare structs, validation * Put action parameter parser code where it belongs * Have a single Action transporting all information * User fmt.Errorf for error-generation * Adding wide playback interface * Use action map for parsing, stringer instead switch stmt. * Use but only one switch case and direct dispatch, refactoring * Add error handling and pushing to client * send decent errormessage, no internal server error * Adding playback devices slice and load it from config * Combine config-verification and structure init * Return user-specific device * Separate playback server from device * Use dataStore to retrieve mediafile by id * WIP: Playlist and start/stop handling. Doing start/stop the hard way as of now * WIP: set, start and stop work on one single song. More to come * Dont need to wait for the end * Merge jukebox_action.go into jukebox.go * Remove getParameterAsInt64(). Use existing requiredParamInt() instead * Dont need to call newFailure() explicitly * Remove int64, use int instead. * Add and set action now accept multiple ids * Kickout copy of childFromMediaFile(). It is not needed here. * Refactoring devices and playbackServer * Turn (internal) playback.DeviceStatus into subsonic JukeboxStatus when rendering output. Indexes int64 -> int * Now we have a position and playing status * Switching gain to float32, xs:float is defined as 32 bit. Fixing nasty copy/pointer bug * Now with volume control * Start working the queue * Remove user from device interface * Rename function GetDevice -> GetDeviceForUser to make intention clearer * Have a nice stringer for the queue * User Prepared boolean for now to allow pause/unpause * Skipping works, but without offsets * Make ChildFromMediaFile public to be used in jukebox get() implementation * Return position in seconds and implement offset-skip in seconds * Default offset to 0 * Adding a simple setGain implementation * Prepare for transcoding AAC * WIP: transcode to WAV to use beeps wav decoder. Not done yet. * WIP: out of sheer desparation: convert to MP3 (which works) rather than WAV to troubleshoot issue. * Use FLAC as intermediate format to play Apple AAC * A bit of cleanup * Catching the end-of-stream event for further reactions * Have a trackSwitching goroutine waiting on channel when track ends * Move decoder code into own file. Restructure code a bit * Now with going on to play the next song in the playlist * Adding shuffle feature * Implementing remove action * Cleanup code * Remove templates for ffmpeg mp3 generation. Not needed anymore. * Adding some documentation * Check whether offset into track is in range. Fixing potential remove track bug. Documentation * Make golangci-lint happy: handling return values * Adding test suite and example dummy for playback package * Adding some basic queue tests * Only use Jukebox.Enabled config option * Adding stream closing handling * Pass context.Context to all PlaybackDevice methods * Remove unneeded function * Correct spelling * Reduce visibility of ChildFromMediaFile * Decomplicate action-parsing * Adding simple tempfile-based AAC->FLAC transcoding. No parallel reading and writing yet. * Try to optimize pipe-writing, tempfile-handling and reading. Not done yet. * Do a synchronous copy of the tempfile. Racecondition detected * More debugging statements and fixing the play/pause bug. More work needed * Start the trackSwitcher() with each device once. Return JSON position even if its 0. More debug-output * Moving all track-handling code into own module * Fix typo. Do not pass ctx around when not applicable * WIP: More refactoring, debugging output * Fix nil pointer * Repairing MP3 playback by pinning indirect dependencies: hajimehoshi/go-mp3 and hajimehoshi/oto * Do not forget to cleanup after a skip action * Make resync with master easy * Adding missing mocks * Adding missing error-handling found by linter * Updating github.com/hajimehoshi/oto * Removing duplicate function * Move BEEP-related code into own package * Juggle beep-related code around as preparation for interface access * More refactoring for interface separation * Gather CloseDevice() behind Track interface. * Adding skeleton, draft audio-interface using mpv.io * Adding majority of interface commands using messages to mpv socket. * Adding end-of-stream handling * MPV: start/stop are working * postition is given in float in mpv * Unify Close() and CloseDevice(). Using temp filename for controlling socket * Wait until control-socket shows up. Cleanup socket in Close() * Use canceable command. Rename to Executor * Skipping tracks works now * Now with actually setting the position * Fix regain * Add missing error-handling found by linter * Adding retry mode on time-pos property getter * Remove unneeded code on queue * Putting build-tag beep onto beep files * Remove deprecated call to rand.Seed() "As of Go 1.20 there is no reason to call Seed with a random value. Programs that call Seed with a known value to get a specific sequence of results should use New(NewSource(seed)) to obtain a local random generator." * Using int32 to conform to Subsonic API spec * Fix merge error * Minor style changes * Get username from context --------- Co-authored-by: Deluan <deluan@navidrome.org>
2023-09-10 17:25:22 +02:00
viper.SetDefault("scanner.extractor", consts.DefaultScannerExtractor)
2021-07-16 17:03:28 +02:00
viper.SetDefault("scanner.genreseparators", ";/,")
viper.SetDefault("scanner.groupalbumreleases", false)
2021-02-07 22:46:15 +01:00
viper.SetDefault("agents", "lastfm,spotify")
viper.SetDefault("lastfm.enabled", true)
viper.SetDefault("lastfm.language", "en")
2023-12-11 03:11:40 +01:00
viper.SetDefault("lastfm.apikey", "")
viper.SetDefault("lastfm.secret", "")
viper.SetDefault("spotify.id", "")
viper.SetDefault("spotify.secret", "")
viper.SetDefault("listenbrainz.enabled", true)
viper.SetDefault("listenbrainz.baseurl", "https://api.listenbrainz.org/1/")
viper.SetDefault("httpsecurityheaders.customframeoptionsvalue", "DENY")
2020-07-02 22:34:21 +02:00
// DevFlags. These are used to enable/disable debugging and incomplete features
viper.SetDefault("devlogsourceline", false)
viper.SetDefault("devenableprofiler", false)
2020-07-02 22:34:21 +02:00
viper.SetDefault("devautocreateadminpassword", "")
viper.SetDefault("devautologinusername", "")
viper.SetDefault("devactivitypanel", true)
viper.SetDefault("enablesharing", false)
viper.SetDefault("defaultdownloadableshare", false)
2021-07-19 22:10:37 +02:00
viper.SetDefault("devenablebufferedscrobble", true)
viper.SetDefault("devsidebarplaylists", true)
2021-10-17 17:07:59 +02:00
viper.SetDefault("devshowartistpage", true)
viper.SetDefault("devoffsetoptimize", 50000)
2024-02-17 03:48:25 +01:00
viper.SetDefault("devartworkmaxrequests", max(2, runtime.NumCPU()/3))
viper.SetDefault("devartworkthrottlebackloglimit", consts.RequestThrottleBacklogLimit)
viper.SetDefault("devartworkthrottlebacklogtimeout", consts.RequestThrottleBacklogTimeout)
viper.SetDefault("devartistinfotimetolive", consts.ArtistInfoTimeToLive)
viper.SetDefault("devalbuminfotimetolive", consts.AlbumInfoTimeToLive)
2016-03-30 06:05:57 +02:00
}
2020-07-02 23:21:25 +02:00
2020-07-03 15:39:28 +02:00
func InitConfig(cfgFile string) {
cfgFile = getConfigFile(cfgFile)
2020-07-02 23:21:25 +02:00
if cfgFile != "" {
// Use config file from the flag.
viper.SetConfigFile(cfgFile)
} else {
// Search config in local directory with name "navidrome" (without extension).
viper.AddConfigPath(".")
viper.SetConfigName("navidrome")
}
2020-07-03 00:17:31 +02:00
_ = viper.BindEnv("port")
2020-07-02 23:21:25 +02:00
viper.SetEnvPrefix("ND")
replacer := strings.NewReplacer(".", "_")
viper.SetEnvKeyReplacer(replacer)
2020-07-02 23:21:25 +02:00
viper.AutomaticEnv()
2020-07-03 16:19:44 +02:00
err := viper.ReadInConfig()
if viper.ConfigFileUsed() != "" && err != nil {
_, _ = fmt.Fprintln(os.Stderr, "FATAL: Navidrome could not open config file: ", err)
os.Exit(1)
2020-07-03 16:19:44 +02:00
}
2020-07-02 23:21:25 +02:00
}
func getConfigFile(cfgFile string) string {
if cfgFile != "" {
return cfgFile
}
return os.Getenv("ND_CONFIGFILE")
}