| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- import os
- import helper.console as console
- class Settings:
- # Directory to permanently save the file (ENV: MD_SAVEDIR)
- SaveDir = None
- # Directory to temporary download the file (ENV: MD_TMP)
- tmpDir = '/tmp'
- # Minimal debug level (ENV: MD_LOGGING)
- Debuglvl = 0
- # Minimal bitrate to auto download the file (ENV: MD_QUALITY)
- MinQuality = 300
- #Format for downloaded file ID3 comment
- CommentFormat = None
- @staticmethod
- def import_config(config):
- namespace = 'music-downloader'
- if namespace in config:
- if 'saveDir' in config[namespace]:
- Settings.SaveDir = config[namespace]['saveDir']
- if 'tmpDir' in config[namespace]:
- Settings.tmpDir = config[namespace]['tmpDir']
- if 'debuglvl' in config[namespace]:
- Settings.Debuglvl = config[namespace]['debuglvl']
- if 'minQuality' in config[namespace]:
- Settings.MinQuality = config[namespace]['minQuality']
- if 'commentFormat' in config[namespace]:
- Settings.CommentFormat = config[namespace]['commentFormat']
- if os.getenv('MD_SAVEDIR') is not None:
- console.output('Overrule MD_SAVEDIR', console.DBG_INFO)
- Settings.SaveDir = os.getenv('MD_SAVEDIR')
- if os.getenv('MD_TMP') is not None:
- console.output('Overrule MD_TMP', console.DBG_INFO)
- Settings.SaveDir = os.getenv('MD_TMP')
- if os.getenv('MD_LOGGING') is not None:
- console.output('Overrule MD_LOGGING', console.DBG_INFO)
- Settings.SaveDir = os.getenv('MD_LOGGING')
- if os.getenv('MD_QUALITY') is not None:
- console.output('Overrule MD_QUALITY', console.DBG_INFO)
- Settings.SaveDir = os.getenv('MD_QUALITY')
- Settings.SaveDir = os.path.expanduser(Settings.SaveDir)
- Settings.tmpDir = os.path.expanduser(Settings.tmpDir)
|