feat: Allow authentication via SUBSONIC_SALT and SUBSONIC_TOKEN
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
20
main.py
20
main.py
@@ -13,15 +13,23 @@ def main():
|
||||
"""Get playlists from a Navidrome server using the Subsonic API."""
|
||||
navidrome_url = os.environ.get('NAVIDROME_URL')
|
||||
username = os.environ.get('NAVIDROME_USER')
|
||||
password = os.environ.get('NAVIDROME_PASSWORD')
|
||||
|
||||
if not all([navidrome_url, username, password]):
|
||||
logging.error("NAVIDROME_URL, NAVIDROME_USER, and NAVIDROME_PASSWORD environment variables must be set.")
|
||||
if not all([navidrome_url, username]):
|
||||
logging.error("NAVIDROME_URL and NAVIDROME_USER environment variables must be set.")
|
||||
return
|
||||
|
||||
# Subsonic API requires a salt and a token (md5(password + salt))
|
||||
salt = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(10))
|
||||
token = hashlib.md5((password + salt).encode('utf-8')).hexdigest()
|
||||
salt = os.environ.get('SUBSONIC_SALT')
|
||||
token = os.environ.get('SUBSONIC_TOKEN')
|
||||
|
||||
if not all([salt, token]):
|
||||
password = os.environ.get('NAVIDROME_PASSWORD')
|
||||
if not password:
|
||||
logging.error("Either (SUBSONIC_SALT and SUBSONIC_TOKEN) or NAVIDROME_PASSWORD must be set.")
|
||||
return
|
||||
|
||||
# Subsonic API requires a salt and a token (md5(password + salt))
|
||||
salt = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(10))
|
||||
token = hashlib.md5((password + salt).encode('utf-8')).hexdigest()
|
||||
|
||||
params = {
|
||||
'u': username,
|
||||
|
||||
Reference in New Issue
Block a user