diff --git a/helpers.py b/helpers.py index 2a993c0..a502198 100644 --- a/helpers.py +++ b/helpers.py @@ -624,10 +624,17 @@ def musicgpt_queue_stems(rid, audio_url, stems=None): } try: resp = requests.post(url, data=payload, headers={"Authorization": get_musicgpt_api_key()}, timeout=30) - data = resp.json() + try: + data = resp.json() + except Exception: + return None, None, None, f"HTTP {resp.status_code}: {resp.text[:300]}" if resp.status_code == 200 and data.get("success"): return data.get("task_id"), data.get("conversion_id"), data.get("credit_estimate"), None - return None, None, None, data.get("error") or f"HTTP {resp.status_code}" + # Capture as much detail as possible from the error response. + error_msg = data.get("error") or data.get("message") or f"HTTP {resp.status_code}" + if data.get("details"): + error_msg += f" — {data['details']}" + return None, None, None, error_msg except Exception as e: return None, None, None, str(e)