Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -400,14 +400,18 @@ def _build_live_view_text(chat_id: int, mode: str = "status") -> str:
|
|
| 400 |
else:
|
| 401 |
status = compose_status_message(chat_id, include_config=False, include_logs=False)
|
| 402 |
logs = session.get('live_log_lines_user', [])
|
| 403 |
-
|
| 404 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 405 |
|
| 406 |
# Only show log tail while actively streaming
|
| 407 |
if state in ("streaming", "starting", "paused", "reconnecting"):
|
| 408 |
return (
|
| 409 |
-
f"{status}\n
|
| 410 |
-
f"๐ <b>
|
| 411 |
f"{pause_note}"
|
| 412 |
)
|
| 413 |
else:
|
|
@@ -893,7 +897,6 @@ def compose_status_message(chat_id: int, include_config: bool = False, include_l
|
|
| 893 |
]
|
| 894 |
|
| 895 |
lines += [
|
| 896 |
-
"",
|
| 897 |
*stats_lines,
|
| 898 |
f"๐ฌ <b>Input:</b> <code>{esc(cur_url)}</code> ({idx+1}/{len(playlist)})",
|
| 899 |
f"๐ <b>Loop:</b> <code>{session.get('current_loop_iteration', 0)+1}/{loop_total}</code>",
|
|
@@ -906,8 +909,11 @@ def compose_status_message(chat_id: int, include_config: bool = False, include_l
|
|
| 906 |
|
| 907 |
if include_logs and state in ("streaming", "paused", "starting", "reconnecting"):
|
| 908 |
user_logs = session.get('live_log_lines_user', [])
|
| 909 |
-
|
| 910 |
-
|
|
|
|
|
|
|
|
|
|
| 911 |
|
| 912 |
return "\n".join(lines)
|
| 913 |
|
|
|
|
| 400 |
else:
|
| 401 |
status = compose_status_message(chat_id, include_config=False, include_logs=False)
|
| 402 |
logs = session.get('live_log_lines_user', [])
|
| 403 |
+
def _compact_log(line: str) -> str:
|
| 404 |
+
stripped = re.sub(r'^\d{2}:\d{2}:\d{2} ', '', line)
|
| 405 |
+
return (stripped[:58] + "โฆ") if len(stripped) > 58 else stripped
|
| 406 |
+
compact_logs = [_compact_log(l) for l in logs[-5:]] if logs else ["No logs yet."]
|
| 407 |
+
log_tail = "\n".join(compact_logs)
|
| 408 |
+
pause_note = "\n<i>โธ Paused โ tap โถ๏ธ Resume</i>" if is_paused else ""
|
| 409 |
|
| 410 |
# Only show log tail while actively streaming
|
| 411 |
if state in ("streaming", "starting", "paused", "reconnecting"):
|
| 412 |
return (
|
| 413 |
+
f"{status}\n"
|
| 414 |
+
f"๐ <b>Logs:</b> <pre>{esc(log_tail)}</pre>"
|
| 415 |
f"{pause_note}"
|
| 416 |
)
|
| 417 |
else:
|
|
|
|
| 897 |
]
|
| 898 |
|
| 899 |
lines += [
|
|
|
|
| 900 |
*stats_lines,
|
| 901 |
f"๐ฌ <b>Input:</b> <code>{esc(cur_url)}</code> ({idx+1}/{len(playlist)})",
|
| 902 |
f"๐ <b>Loop:</b> <code>{session.get('current_loop_iteration', 0)+1}/{loop_total}</code>",
|
|
|
|
| 909 |
|
| 910 |
if include_logs and state in ("streaming", "paused", "starting", "reconnecting"):
|
| 911 |
user_logs = session.get('live_log_lines_user', [])
|
| 912 |
+
def _fmt_log(l):
|
| 913 |
+
s = re.sub(r'^\d{2}:\d{2}:\d{2} ', '', l)
|
| 914 |
+
return (s[:58] + "โฆ") if len(s) > 58 else s
|
| 915 |
+
last_logs = "\n".join([_fmt_log(l) for l in user_logs[-5:]]) if user_logs else "No logs yet."
|
| 916 |
+
lines += ["", f"๐ <b>Logs:</b> <pre>{esc(last_logs)}</pre>"]
|
| 917 |
|
| 918 |
return "\n".join(lines)
|
| 919 |
|