1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-12-23 01:16:18 +00:00

Config sample update

This commit is contained in:
spl0k 2017-11-29 20:09:48 +01:00
parent 5d23b38bf3
commit c515a25b69
3 changed files with 61 additions and 32 deletions

View File

@ -82,23 +82,30 @@ The sample configuration (`config.sample`) looks like this:
``` ```
[base] [base]
; A Storm database URI. See the 'schema' folder for schema creation scripts ; A Storm database URI. See the 'schema' folder for schema creation scripts
; Default: sqlite:///tmp/supysonic/supysonic.db
;database_uri = sqlite:////var/supysonic/supysonic.db ;database_uri = sqlite:////var/supysonic/supysonic.db
; database_uri = mysql://username:password@hostname/database_name ;database_uri = mysql://supysonic:supysonic@localhost/supysonic
; database_uri = postgres://username:password@hostname/database_name ;database_uri = postgres://supysonic:supysonic@localhost/supysonic
; Optional, restrict scanner to these extensions ; Optional, restrict scanner to these extensions. Default: none
;scanner_extensions = mp3 ogg ;scanner_extensions = mp3 ogg
[webapp] [webapp]
; Optional cache directory ; Optional cache directory. Default: /tmp/supysonic
cache_dir = /var/supysonic/cache cache_dir = /var/supysonic/cache
; Optional rotating log file ; Optional rotating log file. Default: none
log_file = /var/supysonic/supysonic.log log_file = /var/supysonic/supysonic.log
; Log level. Possible values: DEBUG, INFO, WARNING, ERROR, CRITICAL ; Log level. Possible values: DEBUG, INFO, WARNING, ERROR, CRITICAL. Default: WARNING
log_level = WARNING log_level = WARNING
; Enable the Subsonic REST API. You'll most likely want to keep this on, here for testing purposes. Default: on
;mount_api = on
; Enable the administrative web interface. Default: on
;mount_webui = on
[daemon] [daemon]
; Optional rotating log file for the scanner daemon ; Optional rotating log file for the scanner daemon
log_file = /var/supysonic/supysonic-daemon.log log_file = /var/supysonic/supysonic-daemon.log
@ -106,11 +113,12 @@ log_level = INFO
[lastfm] [lastfm]
; API and secret key to enable scrobbling. http://www.last.fm/api/accounts ; API and secret key to enable scrobbling. http://www.last.fm/api/accounts
; Defaults: none
;api_key = ;api_key =
;secret = ;secret =
[transcoding] [transcoding]
; Programs used to convert from one format/bitrate to another. ; Programs used to convert from one format/bitrate to another. Defaults: none
transcoder_mp3_mp3 = lame --quiet --mp3input -b %outrate %srcpath - transcoder_mp3_mp3 = lame --quiet --mp3input -b %outrate %srcpath -
transcoder = ffmpeg -i %srcpath -ab %outratek -v 0 -f %outfmt - transcoder = ffmpeg -i %srcpath -ab %outratek -v 0 -f %outfmt -
decoder_mp3 = mpg123 --quiet -w - %srcpath decoder_mp3 = mpg123 --quiet -w - %srcpath
@ -120,9 +128,11 @@ encoder_mp3 = lame --quiet -b %outrate - -
encoder_ogg = oggenc2 -q -M %outrate - encoder_ogg = oggenc2 -q -M %outrate -
[mimetypes] [mimetypes]
; extension to mimetype mappings in case your system has some trouble guessing ; Extension to mimetype mappings in case your system has some trouble guessing
; Default: none
;mp3 = audio/mpeg ;mp3 = audio/mpeg
;ogg = audio/vorbis ;ogg = audio/vorbis
``` ```
Note that using SQLite for large libraries might not be the brightest idea Note that using SQLite for large libraries might not be the brightest idea

View File

@ -1,25 +1,29 @@
[base] [base]
; A Storm database URI. See the 'schema' folder for schema creation scripts ; A Storm database URI. See the 'schema' folder for schema creation scripts
; Default: sqlite:///tmp/supysonic/supysonic.db
;database_uri = sqlite:////var/supysonic/supysonic.db ;database_uri = sqlite:////var/supysonic/supysonic.db
;database_uri = mysql://supysonic:supysonic@localhost/supysonic ;database_uri = mysql://supysonic:supysonic@localhost/supysonic
;database_uri = postgres://supysonic:supysonic@localhost/supysonic ;database_uri = postgres://supysonic:supysonic@localhost/supysonic
; Optional, restrict scanner to these extensions ; Optional, restrict scanner to these extensions. Default: none
;scanner_extensions = mp3 ogg ;scanner_extensions = mp3 ogg
; Optional for develop, key for sign the session cookies
; secret_key = verydifficultkeyword
[webapp] [webapp]
; Optional cache directory ; Optional cache directory. Default: /tmp/supysonic
cache_dir = /var/supysonic/cache cache_dir = /var/supysonic/cache
; Optional rotating log file ; Optional rotating log file. Default: none
log_file = /var/supysonic/supysonic.log log_file = /var/supysonic/supysonic.log
; Log level. Possible values: DEBUG, INFO, WARNING, ERROR, CRITICAL ; Log level. Possible values: DEBUG, INFO, WARNING, ERROR, CRITICAL. Default: WARNING
log_level = WARNING log_level = WARNING
; Enable the Subsonic REST API. You'll most likely want to keep this on, here for testing purposes. Default: on
;mount_api = on
; Enable the administrative web interface. Default: on
;mount_webui = on
[daemon] [daemon]
; Optional rotating log file for the scanner daemon ; Optional rotating log file for the scanner daemon
log_file = /var/supysonic/supysonic-daemon.log log_file = /var/supysonic/supysonic-daemon.log
@ -27,11 +31,12 @@ log_level = INFO
[lastfm] [lastfm]
; API and secret key to enable scrobbling. http://www.last.fm/api/accounts ; API and secret key to enable scrobbling. http://www.last.fm/api/accounts
; Defaults: none
;api_key = ;api_key =
;secret = ;secret =
[transcoding] [transcoding]
; Programs used to convert from one format/bitrate to another. ; Programs used to convert from one format/bitrate to another. Defaults: none
transcoder_mp3_mp3 = lame --quiet --mp3input -b %outrate %srcpath - transcoder_mp3_mp3 = lame --quiet --mp3input -b %outrate %srcpath -
transcoder = ffmpeg -i %srcpath -ab %outratek -v 0 -f %outfmt - transcoder = ffmpeg -i %srcpath -ab %outratek -v 0 -f %outfmt -
decoder_mp3 = mpg123 --quiet -w - %srcpath decoder_mp3 = mpg123 --quiet -w - %srcpath
@ -41,7 +46,8 @@ encoder_mp3 = lame --quiet -b %outrate - -
encoder_ogg = oggenc2 -q -M %outrate - encoder_ogg = oggenc2 -q -M %outrate -
[mimetypes] [mimetypes]
; extension to mimetype mappings in case your system has some trouble guessing ; Extension to mimetype mappings in case your system has some trouble guessing
; Default: none
;mp3 = audio/mpeg ;mp3 = audio/mpeg
;ogg = audio/vorbis ;ogg = audio/vorbis

View File

@ -55,13 +55,26 @@ class IniConfig(DefaultConfig):
parser.read(paths) parser.read(paths)
for section in parser.sections(): for section in parser.sections():
options = { k: v for k, v in parser.items(section) } options = { k: self.__try_parse(v) for k, v in parser.items(section) }
section = section.upper() section = section.upper()
if hasattr(self, section): if hasattr(self, section):
getattr(self, section).update(options) getattr(self, section).update(options)
else: else:
setattr(self, section, options) setattr(self, section, options)
@staticmethod
def __try_parse(value):
try:
return int(value)
except ValueError:
lv = value.lower()
if lv in ('yes', 'true', 'on'):
return True
elif lv in ('no', 'false', 'off'):
return False
return value
@classmethod @classmethod
def from_common_locations(cls): def from_common_locations(cls):
return IniConfig(cls.common_paths) return IniConfig(cls.common_paths)