no-name-here commited on
Commit
dcb9a47
Β·
verified Β·
1 Parent(s): 8ca9f2e

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +4 -2
main.py CHANGED
@@ -260,14 +260,16 @@ async def handle_media(chat_id: int, reply_to_id: int,
260
  # ── Progress callback for Pyrogram download ──────────────
261
  async def on_progress(current: int, total: int):
262
  now = time.time()
263
- if now - last_edit[0] < 2.5: # throttle edits to every 2.5s
264
  return
265
  last_edit[0] = now
266
  elapsed = now - dl_start
267
  speed = current / elapsed if elapsed > 0 else 0
 
 
268
  try:
269
  await status_msg.edit(
270
- build_progress_text("download", current, total,
271
  speed, elapsed, short_name)
272
  )
273
  except Exception:
 
260
  # ── Progress callback for Pyrogram download ──────────────
261
  async def on_progress(current: int, total: int):
262
  now = time.time()
263
+ if now - last_edit[0] < 2.5:
264
  return
265
  last_edit[0] = now
266
  elapsed = now - dl_start
267
  speed = current / elapsed if elapsed > 0 else 0
268
+ # Pyrogram often passes total=0 β€” use file_size from webhook as fallback
269
+ actual_total = total if total and total > 0 else file_size
270
  try:
271
  await status_msg.edit(
272
+ build_progress_text("download", current, actual_total,
273
  speed, elapsed, short_name)
274
  )
275
  except Exception: