This commit is contained in:
2025-12-03 09:30:32 +00:00
parent d5169fbec7
commit 85b1562a75
4 changed files with 23 additions and 4 deletions

View File

@@ -16,7 +16,7 @@ app.include_router(download.router)
app.include_router(system.router)
@app.get("/", response_class=HTMLResponse)
async def index(request: Request):
def index(request: Request):
wrapper = TidalWrapper()
if not wrapper.is_authenticated():
return templates.TemplateResponse("login.html", {"request": request})

View File

@@ -83,7 +83,7 @@ class DownloadManager:
return task
def get_queue(self):
return list(self.active_downloads.values()) + self.history
return list(self.active_downloads.values()) + self.history[-10:]
def _worker(self):
while True:

View File

@@ -27,7 +27,26 @@ class TidalWrapper:
self.auth_status = {"status": "idle", "message": "", "link": "", "code": ""}
def is_authenticated(self) -> bool:
max_retries = 5
retry_delay = 5
for attempt in range(max_retries):
try:
return self.session.check_login()
except Exception as e:
error_str = str(e)
# Check for connection-related errors
if "Connection" in error_str or "RemoteDisconnected" in error_str or "Network" in error_str:
logger.warning(f"Connection error checking authentication (Attempt {attempt + 1}/{max_retries}): {e}")
if attempt < max_retries - 1:
logger.info(f"Waiting {retry_delay} seconds for network/gluetun to recover...")
time.sleep(retry_delay)
continue
# If it's not a connection error, or we've run out of retries
logger.error(f"Error checking authentication status: {e}")
return False
return False
def start_device_login(self) -> Dict[str, str]:
"""

View File

@@ -33,7 +33,7 @@ services:
volumes:
- ./downloads:/app/downloads
- ./config:/app/config
- ./music:/app/music
- /mnt/big/media/music:/app/music
# Mount source for development
- ./app:/app/app
command: uvicorn app.main:app --host 0.0.0.0 --port 8080 --reload