Add SPOTIFY_COOKIE_FILE env var and handle correctly when its missing

This commit is contained in:
Kamil
2024-12-03 23:20:35 +00:00
parent b9ad5be7bc
commit 9a5adfaa5b
2 changed files with 10 additions and 1 deletions

View File

@@ -172,7 +172,15 @@ for name, func in filters.filters.items():
from .providers import SpotifyClient
spotify_client = SpotifyClient('/jellyplist/open.spotify.com_cookies.txt')
if app.config['SPOTIFY_COOKIE_FILE']:
if os.path.exists(app.config['SPOTIFY_COOKIE_FILE']):
spotify_client = SpotifyClient(app.config['SPOTIFY_COOKIE_FILE'])
else:
app.logger.error(f"Cookie file {app.config['SPOTIFY_COOKIE_FILE']} does not exist. Exiting.")
sys.exit(1)
else:
spotify_client = SpotifyClient()
spotify_client.authenticate()
from .registry import MusicProviderRegistry
MusicProviderRegistry.register_provider(spotify_client)

View File

@@ -11,6 +11,7 @@ class Config:
JELLYFIN_REQUEST_TIMEOUT = int(os.getenv('JELLYFIN_REQUEST_TIMEOUT','10'))
SPOTIFY_CLIENT_ID = os.getenv('SPOTIFY_CLIENT_ID')
SPOTIFY_CLIENT_SECRET = os.getenv('SPOTIFY_CLIENT_SECRET')
SPOTIFY_COOKIE_FILE = os.getenv('SPOTIFY_COOKIE_FILE')
JELLYPLIST_DB_HOST = os.getenv('JELLYPLIST_DB_HOST')
JELLYPLIST_DB_PORT = int(os.getenv('JELLYPLIST_DB_PORT','5432'))
JELLYPLIST_DB_USER = os.getenv('JELLYPLIST_DB_USER')