Spaces:
Runtime error
Runtime error
Update bot/youtube/uploader.py
Browse files- bot/youtube/uploader.py +6 -8
bot/youtube/uploader.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
# FILE: bot/youtube/uploader.py
|
| 2 |
-
#
|
| 3 |
-
|
| 4 |
from __future__ import annotations
|
| 5 |
|
| 6 |
import os
|
|
@@ -32,7 +31,6 @@ async def upload_video(
|
|
| 32 |
{"ok": True, "video_id": "...", "url": "...", "response": {...}}
|
| 33 |
{"ok": False, "err": "...", "detail": "..."}
|
| 34 |
"""
|
| 35 |
-
|
| 36 |
if not access_token:
|
| 37 |
return {"ok": False, "err": "missing_access_token"}
|
| 38 |
if not file_path or not os.path.exists(file_path):
|
|
@@ -54,9 +52,9 @@ async def upload_video(
|
|
| 54 |
if not (isinstance(start, dict) and start.get("ok") and start.get("session_url")):
|
| 55 |
err = start.get("err", "start_failed") if isinstance(start, dict) else "start_failed"
|
| 56 |
detail = start.get("detail") if isinstance(start, dict) else None
|
| 57 |
-
out = {"ok": False, "err": err}
|
| 58 |
if detail:
|
| 59 |
-
out["detail"] = str(detail)[:
|
| 60 |
return out
|
| 61 |
|
| 62 |
session_url = str(start["session_url"])
|
|
@@ -72,10 +70,10 @@ async def upload_video(
|
|
| 72 |
if not (isinstance(up, dict) and up.get("ok")):
|
| 73 |
err = up.get("err", "upload_failed") if isinstance(up, dict) else "upload_failed"
|
| 74 |
detail = up.get("detail") if isinstance(up, dict) else None
|
| 75 |
-
|
| 76 |
if detail:
|
| 77 |
-
|
| 78 |
-
return
|
| 79 |
|
| 80 |
resp = up.get("response") if isinstance(up, dict) else None
|
| 81 |
if not isinstance(resp, dict):
|
|
|
|
| 1 |
# FILE: bot/youtube/uploader.py
|
| 2 |
+
# PATH: bot/youtube/uploader.py
|
|
|
|
| 3 |
from __future__ import annotations
|
| 4 |
|
| 5 |
import os
|
|
|
|
| 31 |
{"ok": True, "video_id": "...", "url": "...", "response": {...}}
|
| 32 |
{"ok": False, "err": "...", "detail": "..."}
|
| 33 |
"""
|
|
|
|
| 34 |
if not access_token:
|
| 35 |
return {"ok": False, "err": "missing_access_token"}
|
| 36 |
if not file_path or not os.path.exists(file_path):
|
|
|
|
| 52 |
if not (isinstance(start, dict) and start.get("ok") and start.get("session_url")):
|
| 53 |
err = start.get("err", "start_failed") if isinstance(start, dict) else "start_failed"
|
| 54 |
detail = start.get("detail") if isinstance(start, dict) else None
|
| 55 |
+
out: Dict[str, Any] = {"ok": False, "err": err}
|
| 56 |
if detail:
|
| 57 |
+
out["detail"] = str(detail)[:700]
|
| 58 |
return out
|
| 59 |
|
| 60 |
session_url = str(start["session_url"])
|
|
|
|
| 70 |
if not (isinstance(up, dict) and up.get("ok")):
|
| 71 |
err = up.get("err", "upload_failed") if isinstance(up, dict) else "upload_failed"
|
| 72 |
detail = up.get("detail") if isinstance(up, dict) else None
|
| 73 |
+
out2: Dict[str, Any] = {"ok": False, "err": err}
|
| 74 |
if detail:
|
| 75 |
+
out2["detail"] = str(detail)[:900]
|
| 76 |
+
return out2
|
| 77 |
|
| 78 |
resp = up.get("response") if isinstance(up, dict) else None
|
| 79 |
if not isinstance(resp, dict):
|