Agnivesh10M commited on
Commit
c8efef9
·
verified ·
1 Parent(s): 5991be2

Update TechVJ/start.py

Browse files
Files changed (1) hide show
  1. TechVJ/start.py +74 -22
TechVJ/start.py CHANGED
@@ -10,6 +10,15 @@ from pyrogram.errors import FloodWait, RPCError
10
  from config import API_ID, API_HASH, ADMINS, CHANNEL_ID, WAITING_TIME
11
  from db import db
12
 
 
 
 
 
 
 
 
 
 
13
  HELP_TXT = """📚 **User Guide & Manual**
14
  ━━━━━━━━━━━━━━━━━━━━
15
 
@@ -80,7 +89,7 @@ def time_formatter(seconds: int) -> str:
80
  async def progress_bar(current, total, ud_type, message, start, fname=""):
81
  now = time.time()
82
  diff = now - start
83
- if round(diff % 12.00) == 0 or current == total:
84
  percentage = current * 100 / total if total > 0 else 0
85
  speed = current / diff if diff > 0 else 0
86
  elapsed_time = round(diff)
@@ -185,7 +194,6 @@ async def resume_command(client: Client, message: Message):
185
  if last_id >= task["end_id"]:
186
  return await message.reply_text("✅ पिछला टास्क पहले ही पूरा हो चुका था।")
187
 
188
- # जहाँ रुका था, उसके अगले ID से शुरू करना
189
  task["start_id"] = last_id + 1
190
  await message.reply_text(f"🔄 **टास्क रिज्यूम किया जा रहा है...** (ID `{task['start_id']}` से `{task['end_id']}` तक)")
191
  await start_clone_task(client, user_id)
@@ -368,7 +376,8 @@ async def start_clone_task(client: Client, user_id: int):
368
  api_hash=user_api_hash,
369
  api_id=user_api_id,
370
  in_memory=True,
371
- workers=100
 
372
  )
373
  try:
374
  await acc.start()
@@ -400,7 +409,7 @@ async def start_clone_task(client: Client, user_id: int):
400
  if ok:
401
  success += 1
402
  total_bytes += sz
403
- batch_temp.LAST_SAVED_ID[user_id] = msgid # प्रोग्रेस सेव
404
  else:
405
  not_found += 1
406
  break
@@ -445,7 +454,6 @@ async def start_clone_task(client: Client, user_id: int):
445
  )
446
  await status_msg.edit_text(summary_card)
447
 
448
- # फ़ोटो और मीडिया का सही नाम और एक्सटेंशन पहचानना
449
  def get_file_name_from_msg(msg: Message) -> str:
450
  if msg.document and msg.document.file_name:
451
  return msg.document.file_name
@@ -490,7 +498,6 @@ async def process_media(client: Client, acc: Client, user_id: int, source_chat,
490
  else:
491
  final_caption = task["extra_caption"]
492
 
493
- # केवल टेक्स्ट मैसेज
494
  if msg.text:
495
  text_to_send = msg.text.markdown
496
  if task.get("custom_caption"):
@@ -512,16 +519,26 @@ async def process_media(client: Client, acc: Client, user_id: int, source_chat,
512
  down_start = time.time()
513
  await status_msg.edit_text(f"📥 **Downloading ID:** `{msgid}`\n📁 **File:** `{file_name}`...")
514
 
515
- # फ़ोटो के लिए प्रोग्रेस बार की ज़रूरत नहीं होती
516
  if msg.photo:
517
  file_path = await acc.download_media(msg, file_name=down_path)
518
  else:
519
- file_path = await acc.download_media(
520
- msg,
521
- file_name=down_path,
522
- progress=progress_bar,
523
- progress_args=("📥 Downloading ID: " + str(msgid), status_msg, down_start, file_name)
524
- )
 
 
 
 
 
 
 
 
 
 
525
 
526
  if not file_path or not os.path.exists(file_path):
527
  return False, 0
@@ -538,22 +555,60 @@ async def process_media(client: Client, acc: Client, user_id: int, source_chat,
538
  created_temp_thumb = generate_auto_thumb(file_path, auto_thumb_path)
539
  thumb_to_use = created_temp_thumb
540
 
 
541
  try:
542
  if msg.photo:
543
  await client.send_photo(
544
  target_chat, file_path, caption=final_caption, parse_mode=enums.ParseMode.MARKDOWN
545
  )
546
- elif msg.document:
547
- await client.send_document(
548
- target_chat, file_path, thumb=thumb_to_use, caption=final_caption, parse_mode=enums.ParseMode.MARKDOWN,
549
- progress=progress_bar, progress_args=(f"📤 Uploading ID: {msgid}", status_msg, up_start, file_name)
 
 
550
  )
551
- elif msg.video:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
552
  await client.send_video(
553
  target_chat, file_path, thumb=thumb_to_use, caption=final_caption, parse_mode=enums.ParseMode.MARKDOWN,
554
  duration=msg.video.duration or 0, width=msg.video.width or 0, height=msg.video.height or 0,
555
  progress=progress_bar, progress_args=(f"📤 Uploading ID: {msgid}", status_msg, up_start, file_name)
556
  )
 
 
 
 
 
557
  elif msg.audio:
558
  await client.send_audio(
559
  target_chat, file_path, thumb=thumb_to_use, caption=final_caption, parse_mode=enums.ParseMode.MARKDOWN,
@@ -561,13 +616,10 @@ async def process_media(client: Client, acc: Client, user_id: int, source_chat,
561
  )
562
  else:
563
  await client.send_document(target_chat, file_path, thumb=thumb_to_use, caption=final_caption, parse_mode=enums.ParseMode.MARKDOWN)
564
- except Exception as e:
565
- print(f"Upload error: {e}")
566
- return False, 0
567
  finally:
568
  if os.path.exists(file_path):
569
  os.remove(file_path)
570
  if created_temp_thumb and os.path.exists(created_temp_thumb):
571
  os.remove(created_temp_thumb)
572
 
573
- return True, size
 
10
  from config import API_ID, API_HASH, ADMINS, CHANNEL_ID, WAITING_TIME
11
  from db import db
12
 
13
+ # ⚡ SUPER FAST ENGINE IMPORTS
14
+ try:
15
+ from TechVJ.TechVJ.fast_download import fast_download_file, fast_upload_file
16
+ except ImportError:
17
+ try:
18
+ from TechVJ.fast_download import fast_download_file, fast_upload_file
19
+ except ImportError:
20
+ from fast_download import fast_download_file, fast_upload_file
21
+
22
  HELP_TXT = """📚 **User Guide & Manual**
23
  ━━━━━━━━━━━━━━━━━━━━
24
 
 
89
  async def progress_bar(current, total, ud_type, message, start, fname=""):
90
  now = time.time()
91
  diff = now - start
92
+ if round(diff % 4.0) == 0 or current == total:
93
  percentage = current * 100 / total if total > 0 else 0
94
  speed = current / diff if diff > 0 else 0
95
  elapsed_time = round(diff)
 
194
  if last_id >= task["end_id"]:
195
  return await message.reply_text("✅ पिछला टास्क पहले ही पूरा हो चुका था।")
196
 
 
197
  task["start_id"] = last_id + 1
198
  await message.reply_text(f"🔄 **टास्क रिज्यूम किया जा रहा है...** (ID `{task['start_id']}` से `{task['end_id']}` तक)")
199
  await start_clone_task(client, user_id)
 
376
  api_hash=user_api_hash,
377
  api_id=user_api_id,
378
  in_memory=True,
379
+ workers=150,
380
+ max_concurrent_transmissions=16
381
  )
382
  try:
383
  await acc.start()
 
409
  if ok:
410
  success += 1
411
  total_bytes += sz
412
+ batch_temp.LAST_SAVED_ID[user_id] = msgid
413
  else:
414
  not_found += 1
415
  break
 
454
  )
455
  await status_msg.edit_text(summary_card)
456
 
 
457
  def get_file_name_from_msg(msg: Message) -> str:
458
  if msg.document and msg.document.file_name:
459
  return msg.document.file_name
 
498
  else:
499
  final_caption = task["extra_caption"]
500
 
 
501
  if msg.text:
502
  text_to_send = msg.text.markdown
503
  if task.get("custom_caption"):
 
519
  down_start = time.time()
520
  await status_msg.edit_text(f"📥 **Downloading ID:** `{msgid}`\n📁 **File:** `{file_name}`...")
521
 
522
+ # ⚡ FAST PARALLEL DOWNLOAD
523
  if msg.photo:
524
  file_path = await acc.download_media(msg, file_name=down_path)
525
  else:
526
+ try:
527
+ file_path = await fast_download_file(
528
+ acc,
529
+ msg,
530
+ out_path=down_path,
531
+ progress_func=progress_bar,
532
+ progress_args=("📥 Downloading ID: " + str(msgid), status_msg, down_start, file_name)
533
+ )
534
+ except Exception as e:
535
+ print(f"Fast download failed, fallback to normal: {e}")
536
+ file_path = await acc.download_media(
537
+ msg,
538
+ file_name=down_path,
539
+ progress=progress_bar,
540
+ progress_args=("📥 Downloading ID: " + str(msgid), status_msg, down_start, file_name)
541
+ )
542
 
543
  if not file_path or not os.path.exists(file_path):
544
  return False, 0
 
555
  created_temp_thumb = generate_auto_thumb(file_path, auto_thumb_path)
556
  thumb_to_use = created_temp_thumb
557
 
558
+ # ⚡ FAST PARALLEL UPLOAD
559
  try:
560
  if msg.photo:
561
  await client.send_photo(
562
  target_chat, file_path, caption=final_caption, parse_mode=enums.ParseMode.MARKDOWN
563
  )
564
+ else:
565
+ uploaded_file = await fast_upload_file(
566
+ client,
567
+ file_path,
568
+ progress_func=progress_bar,
569
+ progress_args=(f"📤 Uploading ID: {msgid}", status_msg, up_start, file_name)
570
  )
571
+
572
+ if msg.video:
573
+ await client.send_video(
574
+ target_chat,
575
+ video=uploaded_file,
576
+ thumb=thumb_to_use,
577
+ caption=final_caption,
578
+ parse_mode=enums.ParseMode.MARKDOWN,
579
+ duration=msg.video.duration or 0,
580
+ width=msg.video.width or 0,
581
+ height=msg.video.height or 0
582
+ )
583
+ elif msg.audio:
584
+ await client.send_audio(
585
+ target_chat,
586
+ audio=uploaded_file,
587
+ thumb=thumb_to_use,
588
+ caption=final_caption,
589
+ parse_mode=enums.ParseMode.MARKDOWN
590
+ )
591
+ else:
592
+ await client.send_document(
593
+ target_chat,
594
+ document=uploaded_file,
595
+ thumb=thumb_to_use,
596
+ caption=final_caption,
597
+ parse_mode=enums.ParseMode.MARKDOWN
598
+ )
599
+ except Exception as e:
600
+ print(f"Fast upload failed, fallback to normal: {e}")
601
+ if msg.video:
602
  await client.send_video(
603
  target_chat, file_path, thumb=thumb_to_use, caption=final_caption, parse_mode=enums.ParseMode.MARKDOWN,
604
  duration=msg.video.duration or 0, width=msg.video.width or 0, height=msg.video.height or 0,
605
  progress=progress_bar, progress_args=(f"📤 Uploading ID: {msgid}", status_msg, up_start, file_name)
606
  )
607
+ elif msg.document:
608
+ await client.send_document(
609
+ target_chat, file_path, thumb=thumb_to_use, caption=final_caption, parse_mode=enums.ParseMode.MARKDOWN,
610
+ progress=progress_bar, progress_args=(f"📤 Uploading ID: {msgid}", status_msg, up_start, file_name)
611
+ )
612
  elif msg.audio:
613
  await client.send_audio(
614
  target_chat, file_path, thumb=thumb_to_use, caption=final_caption, parse_mode=enums.ParseMode.MARKDOWN,
 
616
  )
617
  else:
618
  await client.send_document(target_chat, file_path, thumb=thumb_to_use, caption=final_caption, parse_mode=enums.ParseMode.MARKDOWN)
 
 
 
619
  finally:
620
  if os.path.exists(file_path):
621
  os.remove(file_path)
622
  if created_temp_thumb and os.path.exists(created_temp_thumb):
623
  os.remove(created_temp_thumb)
624
 
625
+ return True, size