Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -555,8 +555,6 @@ async def start_cloning(client, message):
|
|
| 555 |
status_msg = await message.reply("⏳ Initializing cloning task...", parse_mode=enums.ParseMode.HTML)
|
| 556 |
asyncio.create_task(clone_videos_background(client, source_id, dest_id, status_msg))
|
| 557 |
|
| 558 |
-
# =================================================================
|
| 559 |
-
|
| 560 |
# ================= NEW: SET UPLOAD SERVER MODE =================
|
| 561 |
@bot.on_message(filters.command("upload") & filters.private & filters.user(ADMIN_IDS))
|
| 562 |
async def set_upload_mode(client, message):
|
|
@@ -714,7 +712,6 @@ async def handle_media_upload(client, message):
|
|
| 714 |
clean_upload_file = original_file
|
| 715 |
|
| 716 |
# ১. ওয়াটারমার্ক (Watermark) করা - Balanced (Superfast + CRF 23)
|
| 717 |
-
# জাইএফ (Animation) ফাইলের কোনো অডিও ট্র্যাক থাকে না, তাই এফএফএমপেগ ফেইল হওয়া ঠেকাতে অডিও বাইপাস করা হলো
|
| 718 |
if media_type == "video" and not is_large_video:
|
| 719 |
await status_msg.edit_text("⏳ Watermarking video... (HD + Superfast Processing)")
|
| 720 |
watermarked_file = f"{original_file}_wm.mp4"
|
|
@@ -733,13 +730,14 @@ async def handle_media_upload(client, message):
|
|
| 733 |
process = await asyncio.create_subprocess_exec(*cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
|
| 734 |
await process.communicate()
|
| 735 |
|
| 736 |
-
# বাগ সংশোধন: ফাইলের সাইজ ০-এর চেয়ে বেশি হলে তবেই আউটপুট ব্যবহার করা হবে, অন্যথায় অরি
|
| 737 |
if process.returncode == 0 and os.path.exists(watermarked_file) and os.path.getsize(watermarked_file) > 0:
|
| 738 |
clean_upload_file = watermarked_file
|
| 739 |
|
| 740 |
-
# ২.
|
|
|
|
| 741 |
storage_msg_id = None
|
| 742 |
-
if media_type
|
| 743 |
if upload_mode == "telegram":
|
| 744 |
await status_msg.edit_text("⏳ Uploading Clean HD video to your storage channel...")
|
| 745 |
|
|
@@ -801,7 +799,7 @@ async def handle_media_upload(client, message):
|
|
| 801 |
await status_msg.delete()
|
| 802 |
return
|
| 803 |
|
| 804 |
-
# ৩.
|
| 805 |
telegram_file = clean_upload_file
|
| 806 |
if is_blur and not is_large_video:
|
| 807 |
await status_msg.edit_text(f"⏳ Applying {blur_percent}% blur for Telegram broadcast...")
|
|
@@ -828,6 +826,8 @@ async def handle_media_upload(client, message):
|
|
| 828 |
|
| 829 |
process_blur = await asyncio.create_subprocess_exec(*cmd_blur, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
|
| 830 |
await process_blur.communicate()
|
|
|
|
|
|
|
| 831 |
if process_blur.returncode == 0 and os.path.exists(blurred_file) and os.path.getsize(blurred_file) > 0:
|
| 832 |
telegram_file = blurred_file
|
| 833 |
|
|
@@ -856,6 +856,7 @@ async def handle_media_upload(client, message):
|
|
| 856 |
if media_type == "photo":
|
| 857 |
sent_to_admin = await client.send_photo(message.chat.id, telegram_file, caption=admin_cap, parse_mode=enums.ParseMode.HTML)
|
| 858 |
else:
|
|
|
|
| 859 |
media = get_media_obj(message)
|
| 860 |
vid_duration = media.duration if media and hasattr(media, 'duration') and media.duration else 0
|
| 861 |
vid_width = media.width if media and hasattr(media, 'width') and media.width else 0
|
|
|
|
| 555 |
status_msg = await message.reply("⏳ Initializing cloning task...", parse_mode=enums.ParseMode.HTML)
|
| 556 |
asyncio.create_task(clone_videos_background(client, source_id, dest_id, status_msg))
|
| 557 |
|
|
|
|
|
|
|
| 558 |
# ================= NEW: SET UPLOAD SERVER MODE =================
|
| 559 |
@bot.on_message(filters.command("upload") & filters.private & filters.user(ADMIN_IDS))
|
| 560 |
async def set_upload_mode(client, message):
|
|
|
|
| 712 |
clean_upload_file = original_file
|
| 713 |
|
| 714 |
# ১. ওয়াটারমার্ক (Watermark) করা - Balanced (Superfast + CRF 23)
|
|
|
|
| 715 |
if media_type == "video" and not is_large_video:
|
| 716 |
await status_msg.edit_text("⏳ Watermarking video... (HD + Superfast Processing)")
|
| 717 |
watermarked_file = f"{original_file}_wm.mp4"
|
|
|
|
| 730 |
process = await asyncio.create_subprocess_exec(*cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
|
| 731 |
await process.communicate()
|
| 732 |
|
| 733 |
+
# বাগ সংশোধন: ফাইলের সাইজ ০-এর চেয়ে বেশি হলে তবেই আউটপুট ব্যবহার করা হবে, অন্যথায় অরিじんাল ফাইল ব্যবহৃত হবে
|
| 734 |
if process.returncode == 0 and os.path.exists(watermarked_file) and os.path.getsize(watermarked_file) > 0:
|
| 735 |
clean_upload_file = watermarked_file
|
| 736 |
|
| 737 |
+
# ২. আপনার নিজের টেলিগ্রাম স্টোরেজ চ্যানেলে ফাইল আপলোড (ভিডিও বা ফটো)
|
| 738 |
+
# এখানে থাম্বনেইল, সঠিক ডিউরেশন এবং সাইজ জেনারেট করে পোস্ট করা হবে যাতে সাদা ০:০০ শো না করে
|
| 739 |
storage_msg_id = None
|
| 740 |
+
if media_type in ["video", "photo"]:
|
| 741 |
if upload_mode == "telegram":
|
| 742 |
await status_msg.edit_text("⏳ Uploading Clean HD video to your storage channel...")
|
| 743 |
|
|
|
|
| 799 |
await status_msg.delete()
|
| 800 |
return
|
| 801 |
|
| 802 |
+
# ৩. পাঠানোর জন্য ভিডিও ব্লার করা
|
| 803 |
telegram_file = clean_upload_file
|
| 804 |
if is_blur and not is_large_video:
|
| 805 |
await status_msg.edit_text(f"⏳ Applying {blur_percent}% blur for Telegram broadcast...")
|
|
|
|
| 826 |
|
| 827 |
process_blur = await asyncio.create_subprocess_exec(*cmd_blur, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
|
| 828 |
await process_blur.communicate()
|
| 829 |
+
|
| 830 |
+
# বাগ সংশোধন: ফাইলের সাইজ ০-এর চেয়ে বেশি হলে তবেই আউটপুট ব্যবহার করা হবে, অন্যথায় অরিজিনাল ফাইল ব্যবহৃত হবে
|
| 831 |
if process_blur.returncode == 0 and os.path.exists(blurred_file) and os.path.getsize(blurred_file) > 0:
|
| 832 |
telegram_file = blurred_file
|
| 833 |
|
|
|
|
| 856 |
if media_type == "photo":
|
| 857 |
sent_to_admin = await client.send_photo(message.chat.id, telegram_file, caption=admin_cap, parse_mode=enums.ParseMode.HTML)
|
| 858 |
else:
|
| 859 |
+
# Safe dimensions extraction for Videos and Animations
|
| 860 |
media = get_media_obj(message)
|
| 861 |
vid_duration = media.duration if media and hasattr(media, 'duration') and media.duration else 0
|
| 862 |
vid_width = media.width if media and hasattr(media, 'width') and media.width else 0
|