Srt / main.py
waigyi's picture
Update main.py
c8fd7d8 verified
import os, subprocess, asyncio, threading, time, random, re
from pyrogram import Client, filters, idle
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
from flask import Flask, render_template_string
# --- MINI WEB APP ENGINE ---
webapp = Flask(__name__)
WEB_TEMPLATE = """
<!DOCTYPE html>
<html>
<head>
<title>Ultimate Deep Bypass Dashboard</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #0f172a; color: #f8fafc; margin: 0; padding: 20px; }
.container { max-width: 800px; margin: auto; background: #1e293b; padding: 30px; border-radius: 12px; box-shadow: 0 4px 6px rgba(0,0,0,0.3); }
h1 { color: #38bdf8; text-align: center; margin-bottom: 30px; font-size: 28px; }
.card { background: #334155; padding: 20px; border-radius: 8px; margin-bottom: 20px; border-left: 5px solid #38bdf8; }
.card h3 { margin-top: 0; color: #e2e8f0; }
.status { display: inline-block; padding: 5px 15px; background: #22c55e; color: white; border-radius: 20px; font-size: 14px; font-weight: bold; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.badge { background: #475569; padding: 5px 10px; border-radius: 4px; font-size: 13px; color: #cbd5e1; }
footer { text-align: center; margin-top: 30px; color: #64748b; font-size: 12px; }
</style>
</head>
<body>
<div class="container">
<h1>🚀 WH Deep Bypass Bot v3.6 (Intro Integrated)</h1>
<div class="card">
<h3>🤖 Bot Status: <span class="status">ONLINE</span></h3>
<p>System Core Engine v3.6 is running flawlessly with Intro/Outro Merger.</p>
</div>
<div class="grid">
<div class="card" style="border-left-color: #eab308;">
<h3>🎵 Audio & Concat Booster</h3>
<p class="badge">Mode: High-Pitch Sharp Audio</p>
<p class="badge">Equalizer: Treble Boost Enabled</p>
<p class="badge">Merger: Auto Intro/Outro Scale</p>
</div>
<div class="card" style="border-left-color: #ec4899;">
<h3>🌫️ Blur, Logo & Subtitle Core</h3>
<p class="badge">Default Blur Strength: 30:20</p>
<p class="badge">Logo Overlay: Dynamic Filter Chain</p>
<p class="badge">Subtitle Font: Arial (Size 15)</p>
</div>
</div>
<footer>Powered by Ultimate Deep Bypass Engine © 2026</footer>
</div>
</body>
</html>
"""
@webapp.route('/')
def home():
return render_template_string(WEB_TEMPLATE)
def run_flask():
webapp.run(host='0.0.0.0', port=7860)
# --- CONFIGURATION ---
API_ID, API_HASH = 30074411, "eb00f53ab32888d0fa9e282e932011b9"
BOT_TOKEN = "8673978980:AAFW_A9MKnHsuXU9rl8fw860lyrnBih7irg"
BOT_PASSWORD = "131019"
INTRO_FILENAME = "my_intro.mp4" # ဆရာ့ ရှေ့နောက် Intro ဖိုင်အမည်
LOGO_FILENAME = "logo.png"
# --- SUBTITLE SETTINGS ---
SUB_FONT_SIZE = 15
SUB_FONT_NAME = "Arial"
SUB_COLOR = "&H00FFFF"
# --- DEFAULT BLUR STRENGTH ---
BLUR_STRENGTH = "30:20"
app = Client("animated_pro_bot", api_id=API_ID, api_hash=API_HASH, bot_token=BOT_TOKEN)
user_data = {}
async def update_progress(msg, current_step, total_steps, status_text):
frames = ["⏳", "⌛", "⚙️", "🔧"]
progress = int((current_step / total_steps) * 10)
bar = "🟩" * progress + "⬜" * (10 - progress)
running_man = "." * progress + "🏃💨" + "." * (10 - progress)
text = (
f"🌟 **အခြေအနေ: {status_text}...** {frames[current_step % 4]}\n\n"
f"🛠 **ပြုပြင်နေမှု:** {int((current_step/total_steps)*100)}%\n"
f"└ {bar} 🏁\n"
f"└─ {running_man}\n\n"
f"💡 *ခဏစောင့်ပေးပါ၊ Ultimate Deep Bypass v3.6 ကို အသုံးပြုနေပါသည်!*"
)
try: await msg.edit_text(text)
except: pass
def scale_srt_time(srt_path, scale_factor):
def time_to_ms(t_str):
h, m, s, ms = map(int, re.split('[:,]', t_str))
return h * 3600000 + m * 60000 + s * 1000 + ms
def ms_to_time(ms):
h, ms = divmod(ms, 3600000)
m, ms = divmod(ms, 60000)
s, ms = divmod(ms, 1000)
return f"{h:02}:{m:02}:{s:02},{ms:03}"
with open(srt_path, 'r', encoding='utf-8') as f:
content = f.read()
def replace_time(match):
start_ms = time_to_ms(match.group(1))
end_ms = time_to_ms(match.group(2))
return f"{ms_to_time(int(start_ms * scale_factor))} --> {ms_to_time(int(end_ms * scale_factor))}"
new_content = re.sub(r'(\d{2}:\d{2}:\d{2},\d{3}) --> (\d{2}:\d{2}:\d{2},\d{3})', replace_time, content)
with open(srt_path, 'w', encoding='utf-8') as f:
f.write(new_content)
@app.on_message(filters.command("start") & filters.private)
async def start(c, m):
uid = m.chat.id
user_data[uid] = {'auth': False, 'srt': None, 'video': None, 'ratio': 'original', 'blur_h': 0.25, 'blur_pos': 0.0, 'blur_side': 'bottom', 'use_logo': False}
await m.reply_text("🔐 Password ရိုက်ထည့်ပေးပါဗျ။")
@app.on_message(filters.text & filters.private & ~filters.me & ~filters.command("start"))
async def check_pw(c, m):
uid = m.chat.id
if user_data.get(uid, {}).get('auth'): return
if m.text == BOT_PASSWORD:
user_data.setdefault(uid, {})['auth'] = True
await m.reply_text("✅ Bot အဆင်သင့်ဖြစ်ပါပြီ! SRT အရင်ပို့ပြီးမှ Video ပို့ပါ။")
else:
await m.reply_text("❌ Password မှားယွင်းပါသည်။")
@app.on_message((filters.document | filters.video) & filters.private & ~filters.me)
async def handle_files(c, m):
uid = m.chat.id
if not user_data.get(uid, {}).get('auth'): return
if m.document and m.document.file_name.endswith('.srt'):
user_data[uid]['srt'] = await m.download(file_name=f"s_{uid}.srt")
await m.reply_text("📝 SRT လက်ခံရရှိပါပြီ။ ဗီဒီယို ပို့ပါ။")
elif m.video or (m.document and m.document.file_name.endswith('.mp4')):
user_data[uid]['video'] = await m.download(file_name=f"v_{uid}.mp4")
kb = InlineKeyboardMarkup([
[InlineKeyboardButton("🖼️ Logo ထည့်မည်", callback_data="logo_yes"),
InlineKeyboardButton("🚫 Logo မထည့်ပါ", callback_data="logo_no")]
])
await m.reply_text("🔖 ဗီဒီယိုမှာ ဆရာ့ Logo ထည့်သွင်းလိုပါသလား-", reply_markup=kb)
@app.on_callback_query()
async def callback_handler(c, cb):
uid = cb.message.chat.id
if cb.data.startswith("logo_"):
user_data[uid]['use_logo'] = (cb.data == "logo_yes")
kb = InlineKeyboardMarkup([
[InlineKeyboardButton("📱 9:16 (TikTok/Reels)", callback_data="ratio_916"), InlineKeyboardButton("📺 16:9 (YouTube)", callback_data="ratio_169")],
[InlineKeyboardButton("🟦 1:1 (Facebook/Square)", callback_data="ratio_11"), InlineKeyboardButton("🎥 မူရင်းဆိုဒ် (Original)", callback_data="ratio_original")]
])
await cb.message.edit_text("📐 ဗီဒီယို ဆိုဒ် (Aspect Ratio) ကို ရွေးချယ်ပါ-", reply_markup=kb)
elif cb.data.startswith("ratio_"):
user_data[uid]['ratio'] = cb.data.replace("ratio_", "")
kb = InlineKeyboardMarkup([
[InlineKeyboardButton("🤏 အသေး (၁၅%)", callback_data="bh_0.15"), InlineKeyboardButton("📏 အလတ် (၂၅%)", callback_data="bh_0.25")],
[InlineKeyboardButton("🧱 အကြီး (၃၅%)", callback_data="bh_0.35"), InlineKeyboardButton("🚫 Blur မလုပ်ပါ", callback_data="bh_0.0")]
])
await cb.message.edit_text(f"🌫️ Blur အမြင့် (Height) ကို ရွေးချယ်ပါ (ဆိုဒ်: {user_data[uid]['ratio']}):", reply_markup=kb)
elif cb.data.startswith("bh_"):
user_data[uid]['blur_h'] = float(cb.data.replace("bh_", ""))
if user_data[uid]['blur_h'] == 0.0:
user_data[uid]['blur_pos'] = 0.0
return await show_op_menu(cb, uid)
kb = InlineKeyboardMarkup([
[InlineKeyboardButton("⬇️ အောက်ခြေကပ် (Bottom Sticky)", callback_data="bp_0.0")],
[InlineKeyboardButton("⬆️ အောက်ခြေမှ နည်းနည်းခွာ (Bottom Floating)", callback_data="bp_0.05")],
[InlineKeyboardButton("🔝 အပေါ်ဆုံးကပ် (Top Sticky)", callback_data="bp_top_0.0")],
[InlineKeyboardButton("⏫ အပေါ်ဆုံးမှ နည်းနည်းခွာ (Top Floating)", callback_data="bp_top_0.05")]
])
await cb.message.edit_text(f"📍 Blur တည်နေရာ (Position) ကို ရွေးချယ်ပါ (အမြင့်: {int(user_data[uid]['blur_h']*100)}%):", reply_markup=kb)
elif cb.data.startswith("bp_"):
pos_data = cb.data.replace("bp_", "")
if pos_data.startswith("top_"):
user_data[uid]['blur_side'] = "top"
user_data[uid]['blur_pos'] = float(pos_data.replace("top_", ""))
else:
user_data[uid]['blur_side'] = "bottom"
user_data[uid]['blur_pos'] = float(pos_data)
await show_op_menu(cb, uid)
elif cb.data.startswith("op_"):
await process_video(c, cb)
async def show_op_menu(cb, uid):
h = user_data[uid].get('blur_h', 0.0)
kb = InlineKeyboardMarkup([
[InlineKeyboardButton("🚀 Deep Bypass + စာတန်းထိုး", callback_data="op_sub_only")],
[InlineKeyboardButton("⬇️ အောက်ခြေ Blur + စာတန်းထိုး", callback_data="op_bottom")],
[InlineKeyboardButton("⬆️ အပေါ်ပိုင်း Blur + စာတန်းထိုး", callback_data="op_top")],
[InlineKeyboardButton("🛡️ Guard Only (ဘယ်ညာမလှန်ပါ)", callback_data="op_none")]
])
await cb.message.edit_text(f"⚙️ ပြုပြင်မည့်ပုံစံ (Mode) ကို ရွေးချယ်ပါ (Blur: {int(h*100)}%, Logo: {'✅' if user_data[uid]['use_logo'] else '❌'}):", reply_markup=kb)
async def process_video(c, cb):
uid = cb.message.chat.id
d = user_data[uid]
v_in, s_in = d.get('video'), d.get('srt')
ratio = d.get('ratio', 'original')
blur_h = d.get('blur_h', 0.25)
blur_pos = d.get('blur_pos', 0.0)
v_temp = f"temp_{uid}.mp4"
v_out, ass_p, thumb = f"f_{uid}.mp4", f"s_{uid}.ass", f"t_{uid}.jpg"
msg = await cb.message.edit_text("🚀 Deep Engine စတင်နေပါပြီ...")
try:
speed_factor = 1.02
pts_factor = 1 / speed_factor
zoom_factor = 1.10
deep_vf = (
f"vignette=PI/10,hue=s=1.15,eq=contrast=1.08:gamma=1.02,noise=alls=5:all_seed=12345,"
f"scale='trunc({zoom_factor}*iw/2)*2':'trunc({zoom_factor}*ih/2)*2',"
f"crop='trunc(iw/{zoom_factor}/2)*2':'trunc(ih/{zoom_factor}/2)*2',"
f"setpts={pts_factor}*PTS"
)
if ratio == "916":
ratio_vf = "scale=720:1280:force_original_aspect_ratio=decrease,pad=720:1280:(720-iw)/2:(1280-ih)/2:color=black"
target_w, target_h = 720, 1280
elif ratio == "169":
ratio_vf = "scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(1280-iw)/2:(720-ih)/2:color=black"
target_w, target_h = 1280, 720
elif ratio == "11":
ratio_vf = "scale=1080:1080:force_original_aspect_ratio=decrease,pad=1080:1080:(1080-iw)/2:(1080-ih)/2:color=black"
target_w, target_h = 1080, 1080
else:
ratio_vf = ""
target_w, target_h = 720, 1280 # Default fallback dimension for safety match
base_vf = deep_vf
if ratio_vf:
base_vf = f"{base_vf},{ratio_vf}"
base_vf = f"{base_vf},scale='trunc(iw/2)*2':'trunc(ih/2)*2',format=yuv420p"
# --- AUDIO CORE ---
af_pro = f"atempo={speed_factor},equalizer=f=3000:width_type=h:width=200:g=12,aecho=0.8:0.7:40:0.3,loudnorm=I=-16:TP=-1.5:LRA=11,lowpass=f=16000,highpass=f=60"
await update_progress(msg, 1, 6, "Bypass Filters များ ထည့်သွင်းနေသည်")
input_args = ["-i", v_in]
has_logo = d['use_logo'] and os.path.exists(LOGO_FILENAME)
if has_logo:
input_args += ["-i", LOGO_FILENAME]
if cb.data == "op_none":
if has_logo:
final_vf = f"{base_vf}[vid];[1:v]scale=120:-1[logo];[vid][logo]overlay=W-w-20:20"
else:
final_vf = base_vf
else:
await update_progress(msg, 2, 6, "စာတန်းထိုး အချိန်နှင့် ပုံစံညှိနေသည်")
if not s_in: return await cb.message.reply_text("❌ SRT အရင်ပို့ပါ!")
scale_srt_time(s_in, pts_factor)
subprocess.run(["ffmpeg", "-y", "-i", s_in, ass_p], check=True)
with open(ass_p, 'r', encoding='utf-8') as f: lines = f.readlines()
style_line = f"Style: Default,{SUB_FONT_NAME},{SUB_FONT_SIZE},{SUB_COLOR},&H000000FF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,1,2,2,2,10,10,50,1"
new_lines = [style_line if l.startswith('Style: Default') else l for l in lines]
with open(ass_p, 'w', encoding='utf-8') as f: f.writelines(new_lines)
bs = BLUR_STRENGTH
# --- FILTER CHAIN (LOGO + BLUR + SUBTITLE) ---
if cb.data == "op_sub_only":
if has_logo:
final_vf = f"hflip,{base_vf}[vid];[1:v]scale=120:-1[logo];[vid][logo]overlay=W-w-20:20,ass='{ass_p}'"
else:
final_vf = f"hflip,{base_vf},ass='{ass_p}'"
elif cb.data == "op_bottom":
y_pos = f"ih*(1-{blur_h}-{blur_pos})"
if has_logo:
final_vf = f"hflip,{base_vf}[v1];[v1]split[m1][m2];[m2]crop=iw:ih*{blur_h}:0:{y_pos},boxblur={bs}[bl];[m1][bl]overlay=0:{y_pos}[v_blur];[v_blur][1:v]scale=120:-1[logo];[v_blur][logo]overlay=W-w-20:20,ass='{ass_p}'"
else:
final_vf = f"hflip,{base_vf}[v1];[v1]split[m1][m2];[m2]crop=iw:ih*{blur_h}:0:{y_pos},boxblur={bs}[bl];[m1][bl]overlay=0:{y_pos},ass='{ass_p}'"
elif cb.data == "op_top":
y_pos = f"ih*{blur_pos}"
if has_logo:
final_vf = f"hflip,{base_vf}[v1];[v1]split[m1][m2];[m2]crop=iw:ih*{blur_h}:0:{y_pos},boxblur={bs}[bl];[m1][bl]overlay=0:{y_pos}[v_blur];[v_blur][1:v]scale=120:-1[logo];[v_blur][logo]overlay=W-w-20:20,ass='{ass_p}'"
else:
final_vf = f"hflip,{base_vf}[v1];[v1]split[m1][m2];[m2]crop=iw:ih*{blur_h}:0:{y_pos},boxblur={bs}[bl];[m1][bl]overlay=0:{y_pos},ass='{ass_p}'"
await update_progress(msg, 3, 6, "Deep AI Bypass ဖြင့် ဗီဒီယို ထုတ်နေသည်")
cmd = ["ffmpeg", "-y"] + input_args + [
"-filter_complex", final_vf,
"-af", af_pro,
"-r", "24.95",
"-vcodec", "libx264",
"-crf", "22",
"-preset", "fast",
"-map_metadata", "-1",
"-metadata:s:v:0", "handler_name=DeepVideoHandler",
"-metadata:s:a:0", "handler_name=DeepSoundHandler",
v_temp
]
process = subprocess.run(cmd, capture_output=True, text=True)
if process.returncode != 0: raise Exception(f"FFmpeg Error: {process.stderr}")
# --- INTRO & OUTRO MERGER SYSTEM ---
if os.path.exists(INTRO_FILENAME):
await update_progress(msg, 4, 6, "ရှေ့နောက် Intro/Outro များ ချိတ်ဆက်နေသည်")
# Intro ရော Main Video ရော Frame Size, Sample Rate, Audio Layout ကိုက်ညီအောင် ညှိပြီး Concat လုပ်သည့် Complex Filter
concat_cmd = [
"ffmpeg", "-y",
"-i", INTRO_FILENAME,
"-i", v_temp,
"-i", INTRO_FILENAME,
"-filter_complex",
f"[0:v]scale={target_w}:{target_h}:force_original_aspect_ratio=decrease,pad={target_w}:{target_h}:({target_w}-iw)/2:({target_h}-ih)/2,setsar=1[v0];"
f"[1:v]scale={target_w}:{target_h}:force_original_aspect_ratio=decrease,pad={target_w}:{target_h}:({target_w}-iw)/2:({target_h}-ih)/2,setsar=1[v1];"
f"[2:v]scale={target_w}:{target_h}:force_original_aspect_ratio=decrease,pad={target_w}:{target_h}:({target_w}-iw)/2:({target_h}-ih)/2,setsar=1[v2];"
f"[0:a]aresample=44100,pan=stereo|c0=c0|c1=c1[a0];"
f"[1:a]aresample=44100,pan=stereo|c0=c0|c1=c1[a1];"
f"[2:a]aresample=44100,pan=stereo|c0=c0|c1=c1[a2];"
f"[v0][a0][v1][a1][v2][a2]concat=n=3:v=1:a=1[v][a]",
"-map", "[v]", "-map", "[a]",
"-vcodec", "libx264", "-crf", "22", "-preset", "fast", v_out
]
concat_process = subprocess.run(concat_cmd, capture_output=True, text=True)
if concat_process.returncode != 0: raise Exception(f"Concat Error: {concat_process.stderr}")
else:
os.rename(v_temp, v_out)
await update_progress(msg, 5, 6, "Metadata များ အမြစ်ပြတ် ဖျက်နေသည်")
subprocess.run(["ffmpeg", "-y", "-i", v_out, "-ss", "00:00:01", "-vframes", "1", thumb], check=True)
try: subprocess.run(["exiftool", "-all=", "-overwrite_original", v_out])
except: pass
await update_progress(msg, 6, 6, "Deep Bypass အောင်မြင်ပါသည်")
await cb.message.reply_video(
v_out,
thumb=thumb,
caption=f"✅ **Ultimate Deep Bypass v3.6 အောင်မြင်ပါသည်!**\n\n📐 *ဆိုဒ်:* {ratio}\n🛡️ *နည်းပညာ:* Intro/Outro Auto-Concat, Treble Audio Booster, Logo Overlay, Subtitle Sync (1.02x), Metadata Wipe."
)
await msg.delete()
except Exception as e:
await cb.message.reply_text(f"❌ အမှားအယွင်း: {str(e)}")
for f in [v_in, v_temp, v_out, ass_p, s_in, thumb]:
if f and os.path.exists(f): os.remove(f)
async def main():
await app.start()
print("Ultimate Deep Bypass Bot v3.6 (Intro Engine Added) is running...")
await idle()
if __name__ == "__main__":
threading.Thread(target=run_flask, daemon=True).start()
asyncio.get_event_loop().run_until_complete(main())