Improve config by using dotenv

This commit is contained in:
François Charette 2020-12-05 20:21:56 +01:00
parent 432b7f250c
commit 515022b60f
4 changed files with 25 additions and 10 deletions

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
'Qobuz Downloads' Qobuz Downloads
*__pycache* *__pycache*
.env

View File

@ -27,11 +27,21 @@ pip3 install -r requirements.txt --user
pip3 install windows-curses pip3 install windows-curses
pip3 install -r requirements.txt pip3 install -r requirements.txt
``` ```
#### Add your credentials to `config.py` #### Add your credentials to a `.env` file
```python ```none
email = "your@email.com" QOBUZ_EMAIL=your@email.com
password = "your_password" QOBUZ_PW=your_password
``` ```
NB: The .env file should be in the root folder, where main.py and config.py are located.
In addition to your credentials, you can also use the `.env` file to
change other default values by means of the following environment variables:
- `QOBUZ_FOLDER` (location of the download folder)
- `QOBUZ_LIMIT` (results limit)
- `QOBUZ_QUALITY` (default quality for url input mode)
#### Run qobuz-dl #### Run qobuz-dl
##### Linux / MAC OS ##### Linux / MAC OS
``` ```

View File

@ -1,13 +1,16 @@
import os
from dotenv import load_dotenv
load_dotenv()
# Qobuz credentials (Don't remove the quotes!) # Qobuz credentials (Don't remove the quotes!)
email = "your@email.com" email = os.getenv('QOBUZ_EMAIL')
password = "your_password" password = os.getenv('QOBUZ_PW')
# Default folder where the releases are downloaded # Default folder where the releases are downloaded
default_folder = "Qobuz Downloads" default_folder = os.getenv('QOBUZ_FOLDER', "Qobuz Downloads")
# Default per type results limit # Default per type results limit
default_limit = 10 default_limit = os.getenv('QOBUZ_LIMIT', 10)
# Default quality for url input mode. This will be ignored in interactive mode # Default quality for url input mode. This will be ignored in interactive mode
# (5, 6, 7, 27) [320, LOSSLESS, 24B <96KHZ, 24B >96KHZ] # (5, 6, 7, 27) [320, LOSSLESS, 24B <96KHZ, 24B >96KHZ]
default_quality = 6 default_quality = os.getenv('QOBUZ_QUALITY', 6)

View File

@ -3,3 +3,4 @@ requests==2.24.0
mutagen==1.45.1 mutagen==1.45.1
tqdm==4.48.2 tqdm==4.48.2
pick==0.6.7 pick==0.6.7
python-dotenv==0.15.0