Merge pull request #75 from kamilkosek/main

main to dev
This commit is contained in:
Kamil Kosek
2025-02-11 13:38:30 +01:00
committed by GitHub
5 changed files with 40 additions and 19 deletions

View File

@@ -1,6 +1,8 @@
import os
import sys
import app
class Config:
LOG_LEVEL = os.getenv('LOG_LEVEL', 'INFO').upper()
SECRET_KEY = os.getenv('SECRET_KEY')
@@ -20,7 +22,7 @@ class Config:
DISPLAY_EXTENDED_AUDIO_DATA = os.getenv('DISPLAY_EXTENDED_AUDIO_DATA',"false").lower() == 'true'
CACHE_TYPE = 'redis'
CACHE_REDIS_PORT = 6379
CACHE_REDIS_HOST = 'redis'
CACHE_REDIS_HOST = os.getenv('CACHE_REDIS_HOST','redis')
CACHE_REDIS_DB = 0
CACHE_DEFAULT_TIMEOUT = 3600
REDIS_URL = os.getenv('REDIS_URL','redis://redis:6379/0')
@@ -39,16 +41,24 @@ class Config:
ENABLE_DEEZER = os.getenv('ENABLE_DEEZER','false').lower() == 'true'
# SpotDL specific configuration
SPOTDL_CONFIG = {
'cookie_file': '/jellyplist/cookies.txt',
# combine the path provided in MUSIC_STORAGE_BASE_PATH with the following path __jellyplist/{track-id} to get the value for output
'threads': 12
}
# combine the path provided in MUSIC_STORAGE_BASE_PATH with the SPOTDL_OUTPUT_FORMAT to get the value for output
if os.getenv('MUSIC_STORAGE_BASE_PATH'):
output_path = os.path.join(MUSIC_STORAGE_BASE_PATH,SPOTDL_OUTPUT_FORMAT)
# Ensure MUSIC_STORAGE_BASE_PATH ends with "__jellyplist"
if not MUSIC_STORAGE_BASE_PATH.endswith("__jellyplist"):
MUSIC_STORAGE_BASE_PATH += "__jellyplist"
# Ensure SPOTDL_OUTPUT_FORMAT does not start with "/"
normalized_spotdl_output_format = SPOTDL_OUTPUT_FORMAT.lstrip("/").replace(" ", "_")
# Join the paths
output_path = os.path.join(MUSIC_STORAGE_BASE_PATH, normalized_spotdl_output_format)
SPOTDL_CONFIG.update({'output': output_path})
if SPOTIFY_COOKIE_FILE:
SPOTDL_CONFIG.update({'cookie_file': SPOTIFY_COOKIE_FILE})
@classmethod
def validate_env_vars(cls):
@@ -72,4 +82,4 @@ class Config:
if missing_vars:
missing = ', '.join(missing_vars)
sys.stderr.write(f"Error: The following environment variables are not set: {missing}\n")
sys.exit(1)
sys.exit(1)