Karan Adhikari commited on
Commit
db2d685
Β·
unverified Β·
1 Parent(s): 532c525

Add file split support

Browse files
Files changed (1) hide show
  1. Backend/helper/scan_manager.py +101 -65
Backend/helper/scan_manager.py CHANGED
@@ -10,20 +10,18 @@ from Backend.logger import LOGGER
10
  from Backend.helper.encrypt import encode_string, decode_string
11
  from Backend.helper.metadata import metadata
12
  from Backend.helper.pyro import clean_filename, get_readable_file_size, remove_urls
 
13
 
 
 
 
 
 
 
14
 
15
- # ─────────────────────────────────────────────────────────────────────────────
16
- # Tunables β€” kept conservative so we never trip Telegram's flood limits.
17
- # ─────────────────────────────────────────────────────────────────────────────
18
- SCAN_BATCH_SIZE = 200 # get_messages accepts up to 200 ids per call
19
- SCAN_MAX_EMPTY_BATCHES = 10 # stop after this many consecutive empty batches
20
- SCAN_MAX_ID_CAP = 1_000_000 # hard ceiling to avoid runaway loops
21
- SCAN_BATCH_DELAY = 0.5 # seconds to sleep between batches
22
- SCAN_PERSIST_EVERY = 1 # persist state every N batches
23
-
24
- DBCHECK_CONCURRENCY = 5 # concurrent get_messages during integrity check
25
- DBCHECK_BATCH_DELAY = 0.3 # seconds between concurrent groups
26
- DBCHECK_PAGE_SIZE = 100 # mongo pagination size
27
 
28
  _STATE_COLLECTION = "scan_state"
29
  _SCAN_DOC_ID = "scan"
@@ -44,9 +42,6 @@ def _fmt_elapsed(seconds: float) -> str:
44
  return f"{s}s"
45
 
46
 
47
- # ═════════════════════════════════════════════════════════════════════════════
48
- # ScanManager β€” resumable channel indexer
49
- # ═════════════════════════════════════════════════════════════════════════════
50
  class ScanManager:
51
  def __init__(self) -> None:
52
  self._db = None
@@ -59,14 +54,15 @@ class ScanManager:
59
  @staticmethod
60
  def _blank_state() -> Dict[str, Any]:
61
  return {
62
- "status": "idle", # idle|running|paused|completed|cancelled|error
63
- "mode": "scan", # scan|rescan
64
- "selected_channels": [], # channels chosen for the active run
65
- "pending": [], # channels still to finish this run
66
  "current_channel": None,
67
  "current_channel_name": "",
68
- "current_id": 0, # last message id reached in current channel
69
- "cursors": {}, # {channel_id: next_message_id} β€” persistent
 
70
  "counters": {
71
  "total_found": 0,
72
  "processed": 0,
@@ -98,8 +94,6 @@ class ScanManager:
98
  self._db = db
99
 
100
  async def load(self, db) -> None:
101
- """Load persisted state on boot. A scan that was 'running' when the
102
- process died is flipped to 'paused' so the user can resume it."""
103
  self._db = db
104
  try:
105
  doc = await db.dbs["tracking"][_STATE_COLLECTION].find_one({"_id": _SCAN_DOC_ID})
@@ -111,7 +105,6 @@ class ScanManager:
111
  doc.pop("_id", None)
112
  merged = self._blank_state()
113
  merged.update(doc)
114
- # Normalise cursor keys to str (mongo keys are strings anyway)
115
  merged["cursors"] = {str(k): int(v) for k, v in (merged.get("cursors") or {}).items()}
116
  if merged["status"] == "running":
117
  merged["status"] = "paused"
@@ -135,13 +128,17 @@ class ScanManager:
135
  except Exception as e:
136
  LOGGER.error(f"[ScanManager] persist failed: {e}")
137
 
138
- # ── Public status (serialisable for the API) ─────────────────────────────
139
  def get_status(self) -> Dict[str, Any]:
140
  s = self.state
141
  elapsed = 0.0
142
  if s["started_at"]:
143
  end = s["finished_at"] or _now()
144
  elapsed = max(0.0, end - s["started_at"])
 
 
 
 
 
145
  return {
146
  "status": s["status"],
147
  "mode": s["mode"],
@@ -151,39 +148,39 @@ class ScanManager:
151
  "pending": list(s["pending"]),
152
  "current_channel": s["current_channel"],
153
  "current_channel_name": s["current_channel_name"],
154
- "current_id": s["current_id"],
 
 
 
155
  "counters": dict(s["counters"]),
156
  "elapsed": _fmt_elapsed(elapsed),
157
  "elapsed_seconds": int(elapsed),
158
  "error": s["error"],
159
  }
160
 
161
- # ── Duplicate detection ──────────────────────────────────────────────────
162
  async def _stream_id_exists(self, channel: int, msg_id: int) -> bool:
163
  db = self._db
164
  try:
165
  stream_hash = await encode_string({"chat_id": channel, "msg_id": msg_id})
166
  except Exception:
167
- return False
 
168
  for i in range(1, db.current_db_index + 1):
169
  storage = db.dbs.get(f"storage_{i}")
170
  if storage is None:
171
  continue
172
- if await storage["movie"].find_one({"telegram.id": stream_hash}):
 
 
 
 
 
173
  return True
174
- if await storage["tv"].find_one({"seasons.episodes.telegram.id": stream_hash}):
175
  return True
176
  return False
177
 
178
- # ── Control: start / resume / cancel ─────────────────────────────────────
179
  async def start(self, client, channels: List[str], mode: str = "scan") -> Dict[str, Any]:
180
- """Start (or resume) a scan.
181
-
182
- mode == "rescan" β†’ purge selected channels, reset their cursors, fresh scan.
183
- mode == "scan" β†’ resume any pending work, scanning each channel from its
184
- saved cursor (so previously-indexed messages are skipped
185
- and we continue exactly where we left off).
186
- """
187
  async with self._lock:
188
  if self.state["status"] == "running":
189
  return {"ok": False, "message": "A scan is already running."}
@@ -191,14 +188,12 @@ class ScanManager:
191
  channels = [str(c).strip() for c in (channels or []) if str(c).strip()]
192
 
193
  if mode == "scan" and not channels and self.state["pending"]:
194
- # Plain resume of an interrupted run
195
  channels = list(self.state["pending"])
196
 
197
  if not channels:
198
  return {"ok": False, "message": "No channels selected."}
199
 
200
  if mode == "rescan":
201
- # Purge + reset cursors for the selected channels
202
  for ch in channels:
203
  try:
204
  ch_int = int(str(ch).replace("-100", ""))
@@ -213,10 +208,8 @@ class ScanManager:
213
  self.state["pending"] = list(channels)
214
  self.state["counters"] = self._blank_counters()
215
  else:
216
- # Resume / fresh incremental scan
217
  resuming = self.state["status"] in ("paused", "cancelled") and self.state["pending"]
218
  if resuming:
219
- # Merge any newly-selected channels into the pending queue
220
  merged_pending = list(self.state["pending"])
221
  for ch in channels:
222
  if ch not in merged_pending:
@@ -248,7 +241,6 @@ class ScanManager:
248
  self._cancel = True
249
  return {"ok": True, "message": "Stop requested β€” the scan will pause after the current batch."}
250
 
251
- # ── Worker ────────────────────────────────────────────────────────────────
252
  async def _run(self, client) -> None:
253
  try:
254
  while self.state["pending"] and not self._cancel:
@@ -265,7 +257,6 @@ class ScanManager:
265
  if self._cancel:
266
  break
267
  if completed:
268
- # channel done for this run β€” drop it from pending
269
  if self.state["pending"] and self.state["pending"][0] == ch:
270
  self.state["pending"].pop(0)
271
  await self._persist()
@@ -288,7 +279,6 @@ class ScanManager:
288
  LOGGER.error(f"[ScanManager] {self.state['error']}")
289
  await self._persist()
290
  except asyncio.CancelledError:
291
- # Process is shutting down β€” leave status running so load() flips to paused
292
  await self._persist()
293
  raise
294
  except Exception as e:
@@ -299,9 +289,6 @@ class ScanManager:
299
  await self._persist()
300
 
301
  async def _scan_channel(self, client, chat_id: int, ch_key: str) -> bool:
302
- """Scan one channel from its saved cursor. Returns True if it ran to the
303
- natural end (so it can be removed from the pending queue), False if it
304
- was interrupted (cancel / shutdown)."""
305
  db = self._db
306
  s = self.state
307
 
@@ -315,17 +302,35 @@ class ScanManager:
315
  LOGGER.warning(f"[ScanManager] Could not resolve channel name for {chat_id}: {e}")
316
 
317
  s["current_channel"] = ch_key
 
 
 
 
 
318
  current = int(s["cursors"].get(str(ch_key), 1) or 1)
319
- LOGGER.info(f"[ScanManager] Scanning {s['current_channel_name']} ({chat_id}) from id {current}")
 
 
 
320
 
321
  empty_streak = 0
322
  batch_count = 0
323
 
324
- while empty_streak < SCAN_MAX_EMPTY_BATCHES and current < SCAN_MAX_ID_CAP:
325
- if self._cancel:
326
- return False
 
 
 
 
 
 
 
 
 
 
 
327
 
328
- batch_ids = list(range(current, min(current + SCAN_BATCH_SIZE, SCAN_MAX_ID_CAP)))
329
  try:
330
  messages = await client.get_messages(chat_id, batch_ids)
331
  except FloodWait as e:
@@ -336,7 +341,7 @@ class ScanManager:
336
  except Exception as ex:
337
  LOGGER.error(f"[ScanManager] Retry failed at {current}: {ex}")
338
  s["counters"]["errors"] += 1
339
- current += SCAN_BATCH_SIZE
340
  empty_streak += 1
341
  s["cursors"][str(ch_key)] = current
342
  s["current_id"] = current
@@ -344,7 +349,7 @@ class ScanManager:
344
  except Exception as e:
345
  LOGGER.error(f"[ScanManager] Batch fetch error at {current}: {e}")
346
  s["counters"]["errors"] += 1
347
- current += SCAN_BATCH_SIZE
348
  empty_streak += 1
349
  s["cursors"][str(ch_key)] = current
350
  s["current_id"] = current
@@ -369,7 +374,7 @@ class ScanManager:
369
  s["counters"]["processed"] += 1
370
 
371
  empty_streak = 0 if batch_had_content else empty_streak + 1
372
- current += SCAN_BATCH_SIZE
373
  s["cursors"][str(ch_key)] = current
374
  s["current_id"] = current
375
 
@@ -383,23 +388,55 @@ class ScanManager:
383
  LOGGER.info(f"[ScanManager] Finished {s['current_channel_name']} at id {current}")
384
  return True
385
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
386
  async def _process_message(self, message, chat_id: int) -> None:
387
  s = self.state
388
  db = self._db
389
 
390
  is_video = bool(message.video)
391
- is_video_doc = False
392
  if message.document and not is_video:
393
  mime = getattr(message.document, "mime_type", "") or ""
394
- is_video_doc = mime.startswith("video/")
 
 
 
 
 
395
 
396
- if not (is_video or is_video_doc):
397
  s["counters"]["skipped_nonvid"] += 1
398
  return
399
 
400
  file = message.video or message.document
401
  title = message.caption or file.file_name
402
  msg_id = message.id
 
403
  size = get_readable_file_size(file.file_size)
404
  channel_int = int(str(chat_id).replace("-100", ""))
405
 
@@ -421,6 +458,8 @@ class ScanManager:
421
  return
422
 
423
  title_clean = remove_urls(title)
 
 
424
  if not title_clean.endswith(('.mkv', '.mp4')):
425
  title_clean += '.mkv'
426
 
@@ -431,6 +470,7 @@ class ScanManager:
431
  msg_id=msg_id,
432
  size=size,
433
  name=title_clean,
 
434
  )
435
  if updated_id:
436
  s["counters"]["indexed"] += 1
@@ -495,9 +535,6 @@ class ScanManager:
495
  return purged
496
 
497
 
498
- # ═════════════════════════════════════════════════════════════════════════════
499
- # DbCheckManager β€” integrity checker + dead-link purge
500
- # ═════════════════════════════════════════════════════════════════════════════
501
  class DbCheckManager:
502
  def __init__(self) -> None:
503
  self._db = None
@@ -509,14 +546,14 @@ class DbCheckManager:
509
  @staticmethod
510
  def _blank_state() -> Dict[str, Any]:
511
  return {
512
- "status": "idle", # idle|running|completed|cancelled|error
513
  "checked": 0,
514
  "alive": 0,
515
  "dead": 0,
516
  "errors": 0,
517
  "purged": 0,
518
  "speed": 0,
519
- "dead_entries": [], # [{"id": hash, "title": str}]
520
  "started_at": 0.0,
521
  "finished_at": 0.0,
522
  "error": None,
@@ -569,7 +606,6 @@ class DbCheckManager:
569
  async def _check_message(self, client, stream_hash: str):
570
  try:
571
  decoded = await decode_string(stream_hash)
572
- # split files store a parts list β€” every part must be alive
573
  if isinstance(decoded, dict) and "parts" in decoded:
574
  parts = decoded.get("parts") or []
575
  if not parts:
 
10
  from Backend.helper.encrypt import encode_string, decode_string
11
  from Backend.helper.metadata import metadata
12
  from Backend.helper.pyro import clean_filename, get_readable_file_size, remove_urls
13
+ from Backend.helper.split_files import parse_split_info, strip_part_suffix
14
 
15
+ SCAN_BATCH_SIZE = 200
16
+ SCAN_MAX_EMPTY_BATCHES = 10
17
+ SCAN_MAX_ID_CAP = 1_000_000
18
+ SCAN_BATCH_DELAY = 0.5
19
+ SCAN_PERSIST_EVERY = 1
20
+ SCAN_PROBE_TEXT = "πŸ”„"
21
 
22
+ DBCHECK_CONCURRENCY = 5
23
+ DBCHECK_BATCH_DELAY = 0.3
24
+ DBCHECK_PAGE_SIZE = 100
 
 
 
 
 
 
 
 
 
25
 
26
  _STATE_COLLECTION = "scan_state"
27
  _SCAN_DOC_ID = "scan"
 
42
  return f"{s}s"
43
 
44
 
 
 
 
45
  class ScanManager:
46
  def __init__(self) -> None:
47
  self._db = None
 
54
  @staticmethod
55
  def _blank_state() -> Dict[str, Any]:
56
  return {
57
+ "status": "idle",
58
+ "mode": "scan",
59
+ "selected_channels": [],
60
+ "pending": [],
61
  "current_channel": None,
62
  "current_channel_name": "",
63
+ "current_id": 0,
64
+ "current_target_id": 0,
65
+ "cursors": {},
66
  "counters": {
67
  "total_found": 0,
68
  "processed": 0,
 
94
  self._db = db
95
 
96
  async def load(self, db) -> None:
 
 
97
  self._db = db
98
  try:
99
  doc = await db.dbs["tracking"][_STATE_COLLECTION].find_one({"_id": _SCAN_DOC_ID})
 
105
  doc.pop("_id", None)
106
  merged = self._blank_state()
107
  merged.update(doc)
 
108
  merged["cursors"] = {str(k): int(v) for k, v in (merged.get("cursors") or {}).items()}
109
  if merged["status"] == "running":
110
  merged["status"] = "paused"
 
128
  except Exception as e:
129
  LOGGER.error(f"[ScanManager] persist failed: {e}")
130
 
 
131
  def get_status(self) -> Dict[str, Any]:
132
  s = self.state
133
  elapsed = 0.0
134
  if s["started_at"]:
135
  end = s["finished_at"] or _now()
136
  elapsed = max(0.0, end - s["started_at"])
137
+
138
+ target = int(s.get("current_target_id", 0) or 0)
139
+ cur = int(s.get("current_id", 0) or 0)
140
+ progress = max(0, min(100, round(cur / target * 100))) if target > 0 else 0
141
+
142
  return {
143
  "status": s["status"],
144
  "mode": s["mode"],
 
148
  "pending": list(s["pending"]),
149
  "current_channel": s["current_channel"],
150
  "current_channel_name": s["current_channel_name"],
151
+ "current_id": cur,
152
+ "current_target_id": target,
153
+ "progress": progress,
154
+ "has_progress": target > 0,
155
  "counters": dict(s["counters"]),
156
  "elapsed": _fmt_elapsed(elapsed),
157
  "elapsed_seconds": int(elapsed),
158
  "error": s["error"],
159
  }
160
 
 
161
  async def _stream_id_exists(self, channel: int, msg_id: int) -> bool:
162
  db = self._db
163
  try:
164
  stream_hash = await encode_string({"chat_id": channel, "msg_id": msg_id})
165
  except Exception:
166
+ stream_hash = None
167
+ part_match = {"$elemMatch": {"chat_id": channel, "msg_id": msg_id}}
168
  for i in range(1, db.current_db_index + 1):
169
  storage = db.dbs.get(f"storage_{i}")
170
  if storage is None:
171
  continue
172
+ if stream_hash:
173
+ if await storage["movie"].find_one({"telegram.id": stream_hash}):
174
+ return True
175
+ if await storage["tv"].find_one({"seasons.episodes.telegram.id": stream_hash}):
176
+ return True
177
+ if await storage["movie"].find_one({"telegram.parts": part_match}):
178
  return True
179
+ if await storage["tv"].find_one({"seasons.episodes.telegram.parts": part_match}):
180
  return True
181
  return False
182
 
 
183
  async def start(self, client, channels: List[str], mode: str = "scan") -> Dict[str, Any]:
 
 
 
 
 
 
 
184
  async with self._lock:
185
  if self.state["status"] == "running":
186
  return {"ok": False, "message": "A scan is already running."}
 
188
  channels = [str(c).strip() for c in (channels or []) if str(c).strip()]
189
 
190
  if mode == "scan" and not channels and self.state["pending"]:
 
191
  channels = list(self.state["pending"])
192
 
193
  if not channels:
194
  return {"ok": False, "message": "No channels selected."}
195
 
196
  if mode == "rescan":
 
197
  for ch in channels:
198
  try:
199
  ch_int = int(str(ch).replace("-100", ""))
 
208
  self.state["pending"] = list(channels)
209
  self.state["counters"] = self._blank_counters()
210
  else:
 
211
  resuming = self.state["status"] in ("paused", "cancelled") and self.state["pending"]
212
  if resuming:
 
213
  merged_pending = list(self.state["pending"])
214
  for ch in channels:
215
  if ch not in merged_pending:
 
241
  self._cancel = True
242
  return {"ok": True, "message": "Stop requested β€” the scan will pause after the current batch."}
243
 
 
244
  async def _run(self, client) -> None:
245
  try:
246
  while self.state["pending"] and not self._cancel:
 
257
  if self._cancel:
258
  break
259
  if completed:
 
260
  if self.state["pending"] and self.state["pending"][0] == ch:
261
  self.state["pending"].pop(0)
262
  await self._persist()
 
279
  LOGGER.error(f"[ScanManager] {self.state['error']}")
280
  await self._persist()
281
  except asyncio.CancelledError:
 
282
  await self._persist()
283
  raise
284
  except Exception as e:
 
289
  await self._persist()
290
 
291
  async def _scan_channel(self, client, chat_id: int, ch_key: str) -> bool:
 
 
 
292
  db = self._db
293
  s = self.state
294
 
 
302
  LOGGER.warning(f"[ScanManager] Could not resolve channel name for {chat_id}: {e}")
303
 
304
  s["current_channel"] = ch_key
305
+
306
+ last_id = await self._probe_last_message_id(client, chat_id)
307
+ use_probe = last_id is not None and last_id >= 1
308
+ s["current_target_id"] = last_id if use_probe else 0
309
+
310
  current = int(s["cursors"].get(str(ch_key), 1) or 1)
311
+ LOGGER.info(
312
+ f"[ScanManager] Scanning {s['current_channel_name']} ({chat_id}) from id {current}"
313
+ + (f" up to {last_id} (probe)" if use_probe else " (heuristic mode β€” probe unavailable)")
314
+ )
315
 
316
  empty_streak = 0
317
  batch_count = 0
318
 
319
+ while not self._cancel and current < SCAN_MAX_ID_CAP:
320
+ # ── Stop condition ───────────────────────────────────────────────
321
+ if use_probe:
322
+ if current > last_id:
323
+ break
324
+ elif empty_streak >= SCAN_MAX_EMPTY_BATCHES:
325
+ break
326
+
327
+ upper = min(current + SCAN_BATCH_SIZE, SCAN_MAX_ID_CAP)
328
+ if use_probe:
329
+ upper = min(upper, last_id + 1)
330
+ batch_ids = list(range(current, upper))
331
+ if not batch_ids:
332
+ break
333
 
 
334
  try:
335
  messages = await client.get_messages(chat_id, batch_ids)
336
  except FloodWait as e:
 
341
  except Exception as ex:
342
  LOGGER.error(f"[ScanManager] Retry failed at {current}: {ex}")
343
  s["counters"]["errors"] += 1
344
+ current = upper
345
  empty_streak += 1
346
  s["cursors"][str(ch_key)] = current
347
  s["current_id"] = current
 
349
  except Exception as e:
350
  LOGGER.error(f"[ScanManager] Batch fetch error at {current}: {e}")
351
  s["counters"]["errors"] += 1
352
+ current = upper
353
  empty_streak += 1
354
  s["cursors"][str(ch_key)] = current
355
  s["current_id"] = current
 
374
  s["counters"]["processed"] += 1
375
 
376
  empty_streak = 0 if batch_had_content else empty_streak + 1
377
+ current = upper
378
  s["cursors"][str(ch_key)] = current
379
  s["current_id"] = current
380
 
 
388
  LOGGER.info(f"[ScanManager] Finished {s['current_channel_name']} at id {current}")
389
  return True
390
 
391
+ async def _probe_last_message_id(self, client, chat_id: int):
392
+ probe = None
393
+ try:
394
+ probe = await client.send_message(chat_id, SCAN_PROBE_TEXT)
395
+ except FloodWait as e:
396
+ LOGGER.info(f"[ScanManager] FloodWait {e.value}s during probe β€” sleeping…")
397
+ await asyncio.sleep(e.value)
398
+ try:
399
+ probe = await client.send_message(chat_id, SCAN_PROBE_TEXT)
400
+ except Exception as ex:
401
+ LOGGER.warning(f"[ScanManager] Probe send failed for {chat_id}: {ex}")
402
+ return None
403
+ except Exception as e:
404
+ LOGGER.warning(f"[ScanManager] Could not send probe to {chat_id}: {e}")
405
+ return None
406
+
407
+ last_id = getattr(probe, "id", None)
408
+ try:
409
+ await client.delete_messages(chat_id, probe.id)
410
+ except Exception as e:
411
+ LOGGER.warning(
412
+ f"[ScanManager] Could not delete probe message "
413
+ f"{getattr(probe, 'id', None)} in {chat_id}: {e}"
414
+ )
415
+ return last_id
416
+
417
  async def _process_message(self, message, chat_id: int) -> None:
418
  s = self.state
419
  db = self._db
420
 
421
  is_video = bool(message.video)
422
+ is_supported = is_video
423
  if message.document and not is_video:
424
  mime = getattr(message.document, "mime_type", "") or ""
425
+ if mime.startswith("video/"):
426
+ is_supported = True
427
+ else:
428
+ candidate = message.caption or message.document.file_name or ""
429
+ if parse_split_info(candidate):
430
+ is_supported = True
431
 
432
+ if not is_supported:
433
  s["counters"]["skipped_nonvid"] += 1
434
  return
435
 
436
  file = message.video or message.document
437
  title = message.caption or file.file_name
438
  msg_id = message.id
439
+ raw_size = file.file_size
440
  size = get_readable_file_size(file.file_size)
441
  channel_int = int(str(chat_id).replace("-100", ""))
442
 
 
458
  return
459
 
460
  title_clean = remove_urls(title)
461
+ if metadata_info.get('group_key'):
462
+ title_clean = strip_part_suffix(title_clean)
463
  if not title_clean.endswith(('.mkv', '.mp4')):
464
  title_clean += '.mkv'
465
 
 
470
  msg_id=msg_id,
471
  size=size,
472
  name=title_clean,
473
+ raw_size=raw_size,
474
  )
475
  if updated_id:
476
  s["counters"]["indexed"] += 1
 
535
  return purged
536
 
537
 
 
 
 
538
  class DbCheckManager:
539
  def __init__(self) -> None:
540
  self._db = None
 
546
  @staticmethod
547
  def _blank_state() -> Dict[str, Any]:
548
  return {
549
+ "status": "idle",
550
  "checked": 0,
551
  "alive": 0,
552
  "dead": 0,
553
  "errors": 0,
554
  "purged": 0,
555
  "speed": 0,
556
+ "dead_entries": [],
557
  "started_at": 0.0,
558
  "finished_at": 0.0,
559
  "error": None,
 
606
  async def _check_message(self, client, stream_hash: str):
607
  try:
608
  decoded = await decode_string(stream_hash)
 
609
  if isinstance(decoded, dict) and "parts" in decoded:
610
  parts = decoded.get("parts") or []
611
  if not parts: