Agnivesh10M commited on
Commit
d8ec2c4
·
verified ·
1 Parent(s): f9f84cd

Update TechVJ/start.py

Browse files
Files changed (1) hide show
  1. TechVJ/start.py +54 -68
TechVJ/start.py CHANGED
@@ -18,12 +18,12 @@ from config import API_ID, API_HASH, ADMINS, CHANNEL_ID, WAITING_TIME, FORCE_SUB
18
  from db import db
19
 
20
  try:
21
- from TechVJ.TechVJ.fast_download import fast_download_file, fast_upload_file
22
  except ImportError:
23
  try:
24
- from TechVJ.fast_download import fast_download_file, fast_upload_file
25
  except ImportError:
26
- from fast_download import fast_download_file, fast_upload_file
27
 
28
  class batch_temp(object):
29
  IS_BATCH = {}
@@ -742,79 +742,65 @@ async def process_media(
742
  try:
743
  if msg.photo:
744
  await sender_client.send_photo(
745
- target_chat, file_path, caption=final_caption, parse_mode=enums.ParseMode.MARKDOWN, **topic_kwargs
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
746
  )
747
  else:
748
- uploaded_file = await fast_upload_file(
749
- sender_client,
750
- file_path,
751
- progress_func=progress_bar,
752
- progress_args=("📤 Uploading", status_msg, up_start, file_name, current_idx, total_msgs)
 
 
 
 
753
  )
754
-
755
- if batch_temp.IS_BATCH.get(user_id):
756
- return False, 0, None
757
-
758
- if msg.video:
759
- await sender_client.send_video(
760
- target_chat,
761
- video=uploaded_file,
762
- thumb=thumb_to_use,
763
- caption=final_caption,
764
- parse_mode=enums.ParseMode.MARKDOWN,
765
- duration=msg.video.duration or 0,
766
- width=msg.video.width or 0,
767
- height=msg.video.height or 0,
768
- **topic_kwargs
769
- )
770
- elif msg.audio:
771
- await sender_client.send_audio(
772
- target_chat,
773
- audio=uploaded_file,
774
- thumb=thumb_to_use,
775
- caption=final_caption,
776
- parse_mode=enums.ParseMode.MARKDOWN,
777
- **topic_kwargs
778
- )
779
- else:
780
- await sender_client.send_document(
781
- target_chat,
782
- document=uploaded_file,
783
- thumb=thumb_to_use,
784
- caption=final_caption,
785
- parse_mode=enums.ParseMode.MARKDOWN,
786
- **topic_kwargs
787
- )
788
  except (ChatAdminRequired, RightForbidden):
789
  return False, 0, "❌ **एडमिन एरर:** टारगेट ग्रुप में फ़ाइल पोस्ट करने की अनुमति नहीं है।"
790
  except Exception as e:
791
- print(f"Standard upload fallback: {e}")
792
- if not batch_temp.IS_BATCH.get(user_id):
793
- if msg.video:
794
- await sender_client.send_video(
795
- target_chat, file_path, thumb=thumb_to_use, caption=final_caption, parse_mode=enums.ParseMode.MARKDOWN,
796
- duration=msg.video.duration or 0, width=msg.video.width or 0, height=msg.video.height or 0,
797
- progress=progress_bar, progress_args=("📤 Uploading", status_msg, up_start, file_name, current_idx, total_msgs),
798
- **topic_kwargs
799
- )
800
- elif msg.document:
801
- await sender_client.send_document(
802
- target_chat, file_path, thumb=thumb_to_use, caption=final_caption, parse_mode=enums.ParseMode.MARKDOWN,
803
- progress=progress_bar, progress_args=("📤 Uploading", status_msg, up_start, file_name, current_idx, total_msgs),
804
- **topic_kwargs
805
- )
806
- elif msg.audio:
807
- await sender_client.send_audio(
808
- target_chat, file_path, thumb=thumb_to_use, caption=final_caption, parse_mode=enums.ParseMode.MARKDOWN,
809
- progress=progress_bar, progress_args=("📤 Uploading", status_msg, up_start, file_name, current_idx, total_msgs),
810
- **topic_kwargs
811
- )
812
- else:
813
- await sender_client.send_document(target_chat, file_path, thumb=thumb_to_use, caption=final_caption, parse_mode=enums.ParseMode.MARKDOWN, **topic_kwargs)
814
  finally:
815
  if os.path.exists(file_path):
816
- os.remove(file_path)
 
 
 
817
  if created_temp_thumb and os.path.exists(created_temp_thumb):
818
- os.remove(created_temp_thumb)
 
 
 
819
 
820
  return True, size, None
 
18
  from db import db
19
 
20
  try:
21
+ from TechVJ.TechVJ.fast_download import fast_download_file
22
  except ImportError:
23
  try:
24
+ from TechVJ.fast_download import fast_download_file
25
  except ImportError:
26
+ from fast_download import fast_download_file
27
 
28
  class batch_temp(object):
29
  IS_BATCH = {}
 
742
  try:
743
  if msg.photo:
744
  await sender_client.send_photo(
745
+ target_chat,
746
+ file_path,
747
+ caption=final_caption,
748
+ parse_mode=enums.ParseMode.MARKDOWN,
749
+ **topic_kwargs
750
+ )
751
+ elif msg.video:
752
+ # सीधे एक ही बार में सिंगल-पास अपलोड (दोबारा अपलोड होने वाला बग फिक्स)
753
+ await sender_client.send_video(
754
+ target_chat,
755
+ video=file_path,
756
+ thumb=thumb_to_use,
757
+ caption=final_caption,
758
+ parse_mode=enums.ParseMode.MARKDOWN,
759
+ duration=getattr(msg.video, "duration", 0) or 0,
760
+ width=getattr(msg.video, "width", 0) or 0,
761
+ height=getattr(msg.video, "height", 0) or 0,
762
+ progress=progress_bar,
763
+ progress_args=("📤 Uploading", status_msg, up_start, file_name, current_idx, total_msgs),
764
+ **topic_kwargs
765
+ )
766
+ elif msg.audio:
767
+ await sender_client.send_audio(
768
+ target_chat,
769
+ audio=file_path,
770
+ thumb=thumb_to_use,
771
+ caption=final_caption,
772
+ parse_mode=enums.ParseMode.MARKDOWN,
773
+ duration=getattr(msg.audio, "duration", 0) or 0,
774
+ progress=progress_bar,
775
+ progress_args=("📤 Uploading", status_msg, up_start, file_name, current_idx, total_msgs),
776
+ **topic_kwargs
777
  )
778
  else:
779
+ await sender_client.send_document(
780
+ target_chat,
781
+ document=file_path,
782
+ thumb=thumb_to_use,
783
+ caption=final_caption,
784
+ parse_mode=enums.ParseMode.MARKDOWN,
785
+ progress=progress_bar,
786
+ progress_args=("📤 Uploading", status_msg, up_start, file_name, current_idx, total_msgs),
787
+ **topic_kwargs
788
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
789
  except (ChatAdminRequired, RightForbidden):
790
  return False, 0, "❌ **एडमिन एरर:** टारगेट ग्रुप में फ़ाइल पोस्ट करने की अनुमति नहीं है।"
791
  except Exception as e:
792
+ print(f"Upload error: {e}")
793
+ return False, 0, f"❌ अपलोडिंग एरर: `{e}`"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
794
  finally:
795
  if os.path.exists(file_path):
796
+ try:
797
+ os.remove(file_path)
798
+ except Exception:
799
+ pass
800
  if created_temp_thumb and os.path.exists(created_temp_thumb):
801
+ try:
802
+ os.remove(created_temp_thumb)
803
+ except Exception:
804
+ pass
805
 
806
  return True, size, None