refactor: Move configuration from env vars to settings.py

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
2026-02-04 11:40:59 -07:00
parent b99ccd6f98
commit f7f3a04168
2 changed files with 15 additions and 9 deletions

18
main.py
View File

@@ -63,28 +63,28 @@ def delete_playlist_file(playlist_dir, playlist_name):
def main():
"""Get playlists from a Navidrome server using the Subsonic API."""
mopidy_playlist_dir = os.environ.get('MOPIDY_PLAYLIST_DIR')
mopidy_playlist_dir = settings.MOPIDY_PLAYLIST_DIR
if not mopidy_playlist_dir:
logging.error("MOPIDY_PLAYLIST_DIR environment variable must be set.")
logging.error("MOPIDY_PLAYLIST_DIR must be set in settings.py.")
return
if not os.path.isdir(mopidy_playlist_dir):
logging.error(f"Mopidy playlist directory not found: {mopidy_playlist_dir}")
return
navidrome_url = os.environ.get('NAVIDROME_URL')
username = os.environ.get('NAVIDROME_USER')
navidrome_url = settings.NAVIDROME_URL
username = settings.NAVIDROME_USER
if not all([navidrome_url, username]):
logging.error("NAVIDROME_URL and NAVIDROME_USER environment variables must be set.")
logging.error("NAVIDROME_URL and NAVIDROME_USER must be set in settings.py.")
return
salt = os.environ.get('SUBSONIC_SALT')
token = os.environ.get('SUBSONIC_TOKEN')
salt = settings.SUBSONIC_SALT
token = settings.SUBSONIC_TOKEN
if not all([salt, token]):
password = os.environ.get('NAVIDROME_PASSWORD')
password = settings.NAVIDROME_PASSWORD
if not password:
logging.error("Either (SUBSONIC_SALT and SUBSONIC_TOKEN) or NAVIDROME_PASSWORD must be set.")
logging.error("Either (SUBSONIC_SALT and SUBSONIC_TOKEN) or NAVIDROME_PASSWORD must be set in settings.py.")
return
# Subsonic API requires a salt and a token (md5(password + salt))

View File

@@ -0,0 +1,6 @@
MOPIDY_PLAYLIST_DIR = ""
NAVIDROME_URL = ""
NAVIDROME_USER = ""
NAVIDROME_PASSWORD = ""
SUBSONIC_SALT = ""
SUBSONIC_TOKEN = ""