add data debug for api

This commit is contained in:
oskvr37
2025-01-27 14:30:38 +01:00
parent 19bc615155
commit 3306dbf7ec
+13
View File
@@ -1,9 +1,13 @@
import logging
import json
from pathlib import Path
from requests import Session
from tiddl import models
from .exceptions import AuthError, ApiError
DEBUG = False
API_URL = "https://api.tidal.com/v1"
# Tidal default limits
@@ -36,6 +40,15 @@ class TidalApi:
if req.status_code != 200:
raise ApiError(**data)
if DEBUG:
debug_data = {"endpoint": endpoint, "params": params, "data": data}
path = Path(f"debug_data/{endpoint}.json")
path.parent.mkdir(parents=True, exist_ok=True)
with path.open("w", encoding="utf-8") as f:
json.dump(debug_data, f, indent=2)
return data
def getSession(self):