musicdlp/backend/response.py

26 lines
508 B
Python

import json
import traceback
OK = '{"ok":true}'
def ok_playlist(items: list[str]) -> str:
return json.dumps({
"ok": True,
"data": items,
})
def ok_download(ret: int) -> str:
return json.dumps({
"ok": True,
"data": ret,
})
def error(ex: Exception) -> str:
traceback.print_tb(ex.__traceback__)
return json.dumps({
"ok": False,
"error": {
"type": ex.__class__.__qualname__,
"message": str(ex),
}
})