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:
18
main.py
18
main.py
@@ -63,28 +63,28 @@ def delete_playlist_file(playlist_dir, playlist_name):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Get playlists from a Navidrome server using the Subsonic API."""
|
"""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:
|
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
|
return
|
||||||
if not os.path.isdir(mopidy_playlist_dir):
|
if not os.path.isdir(mopidy_playlist_dir):
|
||||||
logging.error(f"Mopidy playlist directory not found: {mopidy_playlist_dir}")
|
logging.error(f"Mopidy playlist directory not found: {mopidy_playlist_dir}")
|
||||||
return
|
return
|
||||||
|
|
||||||
navidrome_url = os.environ.get('NAVIDROME_URL')
|
navidrome_url = settings.NAVIDROME_URL
|
||||||
username = os.environ.get('NAVIDROME_USER')
|
username = settings.NAVIDROME_USER
|
||||||
|
|
||||||
if not all([navidrome_url, username]):
|
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
|
return
|
||||||
|
|
||||||
salt = os.environ.get('SUBSONIC_SALT')
|
salt = settings.SUBSONIC_SALT
|
||||||
token = os.environ.get('SUBSONIC_TOKEN')
|
token = settings.SUBSONIC_TOKEN
|
||||||
|
|
||||||
if not all([salt, token]):
|
if not all([salt, token]):
|
||||||
password = os.environ.get('NAVIDROME_PASSWORD')
|
password = settings.NAVIDROME_PASSWORD
|
||||||
if not 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
|
return
|
||||||
|
|
||||||
# Subsonic API requires a salt and a token (md5(password + salt))
|
# Subsonic API requires a salt and a token (md5(password + salt))
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
MOPIDY_PLAYLIST_DIR = ""
|
||||||
|
NAVIDROME_URL = ""
|
||||||
|
NAVIDROME_USER = ""
|
||||||
|
NAVIDROME_PASSWORD = ""
|
||||||
|
SUBSONIC_SALT = ""
|
||||||
|
SUBSONIC_TOKEN = ""
|
||||||
|
|||||||
Reference in New Issue
Block a user