30 lines
612 B
Python
30 lines
612 B
Python
import json
|
|
import traceback
|
|
|
|
def playlist(items: list[str]) -> str:
|
|
return json.dumps({
|
|
"type": "items",
|
|
"data": items,
|
|
})
|
|
|
|
def dl_progress(msg: str) -> str:
|
|
return json.dumps({
|
|
"type": "dl_progress",
|
|
"data": msg,
|
|
})
|
|
|
|
def dl_end(ret: int) -> str:
|
|
return json.dumps({
|
|
"type": "dl_end",
|
|
"data": ret,
|
|
})
|
|
|
|
def error(ex: Exception) -> str:
|
|
traceback.print_tb(ex.__traceback__)
|
|
return json.dumps({
|
|
"type": "error",
|
|
"data": {
|
|
"type": ex.__class__.__qualname__,
|
|
"message": str(ex),
|
|
}
|
|
})
|