adjust for cookie_file might not be set

This commit is contained in:
Ofirfr
2025-01-13 22:02:51 +02:00
parent 6f051cb167
commit 3ceae962b1

View File

@@ -113,8 +113,8 @@ def download_missing_tracks(self):
app.logger.info("Starting track download job...") app.logger.info("Starting track download job...")
with app.app_context(): with app.app_context():
spotdl_config = app.config['SPOTDL_CONFIG'] spotdl_config: dict = app.config['SPOTDL_CONFIG']
cookie_file = spotdl_config['cookie_file'] cookie_file = spotdl_config.get('cookie_file', None)
output_dir = spotdl_config['output'] output_dir = spotdl_config['output']
client_id = app.config['SPOTIFY_CLIENT_ID'] client_id = app.config['SPOTIFY_CLIENT_ID']
client_secret = app.config['SPOTIFY_CLIENT_SECRET'] client_secret = app.config['SPOTIFY_CLIENT_SECRET']
@@ -239,7 +239,7 @@ def download_missing_tracks(self):
"--client-id", client_id, "--client-id", client_id,
"--client-secret", client_secret "--client-secret", client_secret
] ]
if os.path.exists(cookie_file): if cookie_file and os.path.exists(cookie_file):
app.logger.debug(f"Found {cookie_file}, using it for spotDL") app.logger.debug(f"Found {cookie_file}, using it for spotDL")
command.append("--cookie-file") command.append("--cookie-file")
command.append(cookie_file) command.append(cookie_file)
@@ -248,7 +248,7 @@ def download_missing_tracks(self):
command.append("--proxy") command.append("--proxy")
command.append(app.config['SPOTDL_PROXY']) command.append(app.config['SPOTDL_PROXY'])
app.logger.debug(f"Executing the spotDL command: {' '.join(command)}") app.logger.info(f"Executing the spotDL command: {' '.join(command)}")
result = subprocess.run(command, capture_output=True, text=True, timeout=90) result = subprocess.run(command, capture_output=True, text=True, timeout=90)
if result.returncode == 0: if result.returncode == 0:
track.downloaded = True track.downloaded = True