Spaces:
Paused
Paused
| import os | |
| import random | |
| import yt_dlp | |
| import json | |
| from flask import Flask, render_template_string, request, Response, stream_with_context | |
| app = Flask(__name__) | |
| # --- LUXURY PREMIUM UI --- | |
| HTML_TEMPLATE = """ | |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>LUXE DL | VIP Edition</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <link href="https://fonts.googleapis.com/css2?family=Cinzel:wght@700&family=Poppins:wght@300;400;600&display=swap" rel="stylesheet"> | |
| <style> | |
| :root { --gold: #D4AF37; --dark: #050505; } | |
| body { background-color: var(--dark); color: white; font-family: 'Poppins', sans-serif; } | |
| .luxury-font { font-family: 'Cinzel', serif; } | |
| .gold-gradient { background: linear-gradient(135deg, #D4AF37 0%, #F9E29C 50%, #B8860B 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; } | |
| .glass-card { background: rgba(255, 255, 255, 0.02); backdrop-filter: blur(15px); border: 1px solid rgba(212, 175, 55, 0.15); box-shadow: 0 20px 50px rgba(0,0,0,0.5); } | |
| .btn-gold { background: linear-gradient(135deg, #D4AF37 0%, #B8860B 100%); color: black; font-weight: 800; transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); } | |
| .btn-gold:hover { transform: scale(1.02); box-shadow: 0 0 30px rgba(212, 175, 55, 0.5); } | |
| .log-container { background: #000; border: 1px solid #222; font-family: 'Courier New', monospace; font-size: 10px; max-height: 100px; overflow-y: auto; color: #D4AF37; } | |
| .loader { border: 2px solid rgba(212, 175, 55, 0.1); border-top: 2px solid var(--gold); border-radius: 50%; width: 35px; height: 35px; animation: spin 0.8s linear infinite; } | |
| @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } | |
| input::placeholder { color: #444; text-transform: uppercase; letter-spacing: 1px; font-size: 10px; } | |
| </style> | |
| </head> | |
| <body class="min-h-screen flex flex-col items-center justify-center p-6"> | |
| <div class="w-full max-w-lg text-center"> | |
| <h1 class="luxury-font text-6xl font-bold mb-1 gold-gradient">LUXE DL</h1> | |
| <p class="text-gray-600 text-[9px] tracking-[0.5em] uppercase mb-10 font-bold">VIP Multi-Platform Downloader</p> | |
| <div class="glass-card p-8 rounded-3xl relative overflow-hidden"> | |
| <div class="absolute top-0 left-0 w-full h-1 bg-gradient-to-r from-transparent via-gold to-transparent opacity-50"></div> | |
| <input type="text" id="url" placeholder="Paste your premium link here" | |
| class="w-full p-5 rounded-2xl bg-black/40 border border-white/5 mb-5 text-center outline-none focus:border-gold/50 transition-all text-sm"> | |
| <button onclick="start()" id="btn" class="w-full py-5 rounded-2xl btn-gold luxury-font tracking-[0.2em] text-sm">INITIALIZE BYPASS</button> | |
| <div id="loading" class="hidden flex flex-col items-center mt-8"> | |
| <div class="loader mb-3"></div> | |
| <p id="status" class="text-gold text-[10px] tracking-widest uppercase animate-pulse">Scanning Source...</p> | |
| </div> | |
| <div id="logBox" class="hidden mt-6 text-left"> | |
| <div id="logs" class="log-container p-4 rounded-xl"></div> | |
| </div> | |
| <div id="result" class="hidden mt-8 text-left border-t border-white/5 pt-8"> | |
| <div class="flex gap-5 items-start"> | |
| <div class="relative"> | |
| <img id="thumb" class="w-28 h-28 rounded-xl object-cover border border-white/10 shadow-2xl" src=""> | |
| <div class="absolute -bottom-2 -right-2 bg-gold text-black text-[8px] px-2 py-1 font-bold rounded shadow-lg">HD</div> | |
| </div> | |
| <div class="flex-1 min-w-0"> | |
| <h3 id="title" class="text-sm font-bold truncate text-white mb-1"></h3> | |
| <p id="plat" class="text-gold text-[9px] uppercase tracking-widest mb-4 font-bold"></p> | |
| <div id="links" class="space-y-2"></div> | |
| </div> | |
| </div> | |
| </div> | |
| <div id="err" class="hidden mt-6 p-4 bg-red-950/30 border border-red-500/20 rounded-2xl text-red-400 text-[11px] text-center font-medium"></div> | |
| </div> | |
| <p class="mt-10 text-gray-700 text-[8px] uppercase tracking-[0.3em]">Encrypted & Secure Extraction</p> | |
| </div> | |
| <script> | |
| function log(m, c='text-gold') { | |
| const l = document.getElementById('logs'); | |
| const d = document.createElement('div'); | |
| d.className = c + ' mb-1'; | |
| d.innerText = `[SYS] ${m}`; | |
| l.appendChild(d); l.scrollTop = l.scrollHeight; | |
| } | |
| async function start() { | |
| const u = document.getElementById('url').value; | |
| if(!u) return; | |
| const btn = document.getElementById('btn'); | |
| const res = document.getElementById('result'); | |
| const err = document.getElementById('err'); | |
| const load = document.getElementById('loading'); | |
| const lb = document.getElementById('logBox'); | |
| const logs = document.getElementById('logs'); | |
| btn.disabled = true; res.classList.add('hidden'); err.classList.add('hidden'); | |
| load.classList.remove('hidden'); lb.classList.remove('hidden'); logs.innerHTML = ''; | |
| try { | |
| const response = await fetch('/api/extract', { | |
| method: 'POST', | |
| headers: {'Content-Type': 'application/json'}, | |
| body: JSON.stringify({url: u}) | |
| }); | |
| const reader = response.body.getReader(); | |
| const decoder = new TextDecoder(); | |
| let buffer = ''; | |
| while (true) { | |
| const {done, value} = await reader.read(); | |
| if (done) break; | |
| buffer += decoder.decode(value, {stream: true}); | |
| const parts = buffer.split('\\n\\n'); | |
| buffer = parts.pop(); | |
| for (const part of parts) { | |
| if (part.startsWith('data: ')) { | |
| try { | |
| const data = JSON.parse(part.replace('data: ', '')); | |
| if(data.type === 'log') { | |
| log(data.msg); document.getElementById('status').innerText = data.msg; | |
| } else if(data.type === 'res') { | |
| document.getElementById('title').innerText = data.title; | |
| document.getElementById('plat').innerText = data.ext; | |
| document.getElementById('thumb').src = data.thumb; | |
| const lDiv = document.getElementById('links'); | |
| lDiv.innerHTML = ''; | |
| data.fmts.forEach(f => { | |
| const a = document.createElement('a'); | |
| a.href = f.url; a.target = '_blank'; | |
| a.className = 'block w-full py-3 px-4 bg-white/5 hover:bg-white/10 border border-white/5 rounded-xl text-[10px] font-bold flex justify-between items-center transition-all'; | |
| a.innerHTML = `<span>${f.q.toUpperCase()} ${f.e.toUpperCase()}</span> <span class="text-gold">DOWNLOAD →</span>`; | |
| lDiv.appendChild(a); | |
| }); | |
| res.classList.remove('hidden'); log('CORE EXTRACTION COMPLETE', 'text-blue-400'); | |
| } else if(data.type === 'err') { | |
| err.innerText = data.msg; err.classList.remove('hidden'); log('FATAL: ' + data.msg, 'text-red-500'); | |
| } | |
| } catch(e) {} | |
| } | |
| } | |
| } | |
| } catch (e) { | |
| err.innerText = "NETWORK ERROR: UNABLE TO REACH VIP SERVER"; err.classList.remove('hidden'); | |
| } finally { | |
| btn.disabled = false; load.classList.add('hidden'); | |
| } | |
| } | |
| </script> | |
| </body> | |
| </html> | |
| """ | |
| def home(): return render_template_string(HTML_TEMPLATE) | |
| def run(): | |
| def gen(): | |
| u = request.json.get('url') | |
| yield f"data: {json.dumps({'type':'log','msg':'Initializing VIP Tunnel...'})}\\n\\n" | |
| # --- VIP BYPASS OPTIONS --- | |
| opts = { | |
| 'quiet': True, | |
| 'no_warnings': True, | |
| 'format': 'best', | |
| 'nocheckcertificate': True, | |
| 'ignoreerrors': True, | |
| 'no_color': True, | |
| # TikTok & YouTube Bypass Headers | |
| 'http_headers': { | |
| 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Mobile/15E148 Safari/604.1', | |
| 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', | |
| 'Accept-Language': 'en-US,en;q=0.9', | |
| 'Referer': 'https://www.google.com/', | |
| } | |
| } | |
| try: | |
| yield f"data: {json.dumps({'type':'log','msg':'Injecting Anti-Bot Headers...'})}\\n\\n" | |
| with yt_dlp.YoutubeDL(opts) as ydl: | |
| info = ydl.extract_info(u, download=False) | |
| if not info: | |
| raise Exception("Target platform blocked the extraction. Server IP blacklisted.") | |
| yield f"data: {json.dumps({'type':'log','msg':'Parsing High-Quality Streams...'})}\\n\\n" | |
| fmts = [] | |
| seen = set() | |
| # Platform specific parsing | |
| raw_fmts = info.get('formats', []) | |
| if not raw_fmts: | |
| fmts.append({'q': 'Original Quality', 'e': info.get('ext','mp4'), 'url': info.get('url')}) | |
| else: | |
| for f in raw_fmts: | |
| if f.get('url'): | |
| # Filter for video+audio or just video for Instagram/TikTok | |
| is_video = f.get('vcodec') != 'none' or info.get('extractor') in ['instagram', 'tiktok'] | |
| if is_video: | |
| q = str(f.get('format_note') or f.get('resolution') or '720p') | |
| if q not in seen: | |
| fmts.append({'q': q, 'e': f.get('ext','mp4'), 'url': f.get('url')}) | |
| seen.add(q) | |
| yield f"data: {json.dumps({'type':'res','title':info.get('title','VIP Video'),'thumb':info.get('thumbnail',''),'ext':info.get('extractor_key',''),'fmts':fmts[:6]})}\\n\\n" | |
| except Exception as e: | |
| err_msg = str(e) | |
| if "status code 0" in err_msg or "Video not available" in err_msg: | |
| err_msg = "TikTok/YouTube blocked Hugging Face. Try a different link or refresh." | |
| yield f"data: {json.dumps({'type':'err','msg':err_msg})}\\n\\n" | |
| return Response(stream_with_context(gen()), mimetype='text-event-stream') | |
| if __name__ == '__main__': | |
| app.run(host='0.0.0.0', port=7860) | |