pmrony commited on
Commit
e09fed9
·
verified ·
1 Parent(s): 0b905fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -4
app.py CHANGED
@@ -7,12 +7,26 @@ import re
7
  import urllib3
8
  from flask import Flask, jsonify, make_response, request, Response
9
  from supabase import create_client
10
- from pyrogram import Client, filters, enums, idle
11
  from pyrogram.errors import SessionPasswordNeeded, PhoneCodeInvalid, PhoneCodeExpired, UserDeactivated, SessionRevoked, AuthKeyUnregistered, FloodWait
12
  from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, WebAppInfo
13
 
14
  urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  # ================= CONFIGURATION =================
17
  BOT_TOKEN = os.environ.get("BOT_TOKEN")
18
  API_ID = int(os.environ.get("API_ID", 0))
@@ -620,7 +634,7 @@ async def handle_media_upload(client, message):
620
  original_file = await message.download(progress=download_progress)
621
  clean_upload_file = original_file
622
 
623
- # ১. ওয়াটারমার্ক (Watermark) করা - HD
624
  if media_type == "video" and not is_large_video:
625
  await status_msg.edit_text("⏳ Watermarking video... (HD + Superfast Processing)")
626
  watermarked_file = f"{original_file}_wm.mp4"
@@ -659,7 +673,7 @@ async def handle_media_upload(client, message):
659
  await status_msg.delete()
660
  return
661
 
662
- # ৩. টেলিগ্রামের জন্য ভিডিও ব্লার করা
663
  telegram_file = clean_upload_file
664
  if is_blur and not is_large_video:
665
  await status_msg.edit_text(f"⏳ Applying {blur_percent}% blur for Telegram broadcast...")
@@ -716,7 +730,7 @@ async def handle_media_upload(client, message):
716
  sent_to_admin = await client.send_animation(message.chat.id, telegram_file, caption=admin_cap, parse_mode=enums.ParseMode.HTML)
717
  tg_file_id = sent_to_admin.animation.file_id
718
  else:
719
- vid_duration = message.video.duration if message.video and message.video.duration else 0
720
  vid_width = message.video.width if message.video and message.video.width else 0
721
  vid_height = message.video.height if message.video and message.video.height else 0
722
 
 
7
  import urllib3
8
  from flask import Flask, jsonify, make_response, request, Response
9
  from supabase import create_client
10
+ from pyrogram import Client, filters, enums, idle, utils # utils ইম্পোর্ট করা হলো
11
  from pyrogram.errors import SessionPasswordNeeded, PhoneCodeInvalid, PhoneCodeExpired, UserDeactivated, SessionRevoked, AuthKeyUnregistered, FloodWait
12
  from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, WebAppInfo
13
 
14
  urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
15
 
16
+ # ==================== PYROGRAM NEW ID RANGE FIX (MONKEY PATCH) ====================
17
+ # টেলিগ্রামের নতুন আইডিগুলোর জন্য Pyrogram-এর Peer ID Invalid বাগ সমাধান করা হলো
18
+ def get_peer_type_new(peer_id: int) -> str:
19
+ peer_id_str = str(peer_id)
20
+ if not peer_id_str.startswith("-"):
21
+ return "user"
22
+ elif peer_id_str.startswith("-100"):
23
+ return "channel"
24
+ else:
25
+ return "chat"
26
+
27
+ utils.get_peer_type = get_peer_type_new
28
+ # ==================================================================================
29
+
30
  # ================= CONFIGURATION =================
31
  BOT_TOKEN = os.environ.get("BOT_TOKEN")
32
  API_ID = int(os.environ.get("API_ID", 0))
 
634
  original_file = await message.download(progress=download_progress)
635
  clean_upload_file = original_file
636
 
637
+ # ১. ওয়াটারমার্ক (Watermark) করা - Balanced (Superfast + CRF 23)
638
  if media_type == "video" and not is_large_video:
639
  await status_msg.edit_text("⏳ Watermarking video... (HD + Superfast Processing)")
640
  watermarked_file = f"{original_file}_wm.mp4"
 
673
  await status_msg.delete()
674
  return
675
 
676
+ # ৩. টেলিগ্রামে পাঠানোর জন্য ভিডিও ব্লার করা
677
  telegram_file = clean_upload_file
678
  if is_blur and not is_large_video:
679
  await status_msg.edit_text(f"⏳ Applying {blur_percent}% blur for Telegram broadcast...")
 
730
  sent_to_admin = await client.send_animation(message.chat.id, telegram_file, caption=admin_cap, parse_mode=enums.ParseMode.HTML)
731
  tg_file_id = sent_to_admin.animation.file_id
732
  else:
733
+ vid_duration = message.video.duration if message.video Image and message.video.duration else 0
734
  vid_width = message.video.width if message.video and message.video.width else 0
735
  vid_height = message.video.height if message.video and message.video.height else 0
736