musicdlp/backend/response.py
DarkCat09 93c5ea3b18
Code cleanup
(there was an attempt to redirect yt-dlp stdout)
2024-05-03 20:10:42 +04:00

27 lines
520 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_downloaded(ret: int) -> str:
return json.dumps({
"type": "downloaded",
"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),
}
})