File size: 7,894 Bytes
039b1c4 e8ab232 039b1c4 e8ab232 039b1c4 e8ab232 039b1c4 e8ab232 039b1c4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | <!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>YouTube to TV (MP4/M3U)</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600&display=swap');
body { font-family: 'Outfit', sans-serif; }
.live-pulse {
animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: .5; }
}
</style>
</head>
<body class="bg-[#0f172a] text-slate-200 min-h-screen flex items-center justify-center p-4">
<div class="max-w-xl w-full bg-slate-800/50 backdrop-blur-xl border border-white/10 p-8 rounded-3xl shadow-2xl">
<h1 class="text-4xl font-bold text-transparent bg-clip-text bg-gradient-to-r from-blue-400 to-emerald-400 text-center mb-8">
YouTube to TV Converter
</h1>
<div class="space-y-6">
<div class="relative">
<input
type="text"
id="youtube-url"
placeholder="Pega el enlace de YouTube o Directo aqu铆..."
class="w-full bg-slate-900/50 border border-slate-700/50 text-white placeholder-slate-500 rounded-2xl px-6 py-4 focus:ring-2 focus:ring-blue-500/50 focus:border-blue-500/50 outline-none transition-all"
>
</div>
<button
onclick="convertLink()"
id="convert-btn"
class="w-full bg-gradient-to-r from-blue-500 to-emerald-600 hover:from-blue-600 hover:to-emerald-700 text-white font-semibold rounded-2xl px-8 py-4 transition-all transform hover:scale-[1.02] active:scale-[0.98] shadow-lg shadow-blue-500/20"
>
Procesar para TV
</button>
<!-- Loading Spinner -->
<div id="loading" class="hidden flex flex-col items-center space-y-4">
<div class="w-12 h-12 border-4 border-blue-500/30 border-t-blue-500 rounded-full animate-spin"></div>
<p id="loading-text" class="text-slate-400 text-center">Analizando video... Esto puede tardar si es una descarga pesada.</p>
</div>
<!-- Error Message -->
<div id="error-msg" class="hidden p-4 rounded-xl bg-red-500/10 border border-red-500/50 text-red-400 text-sm"></div>
<!-- Download Result -->
<div id="result" class="hidden p-6 rounded-2xl bg-slate-900/50 border border-white/5 space-y-4">
<div class="flex items-center justify-center space-x-2 mb-4">
<p id="result-text" class="text-emerald-400 font-medium text-center"></p>
<span id="live-badge" class="hidden px-2 py-0.5 bg-red-500 text-white text-[10px] font-bold rounded live-pulse">EN VIVO</span>
</div>
<div class="grid grid-cols-1 gap-3">
<a id="download-link" href="#" class="flex items-center justify-center bg-blue-500 hover:bg-blue-600 text-white font-bold py-3 px-6 rounded-xl transition-all shadow-md shadow-blue-500/20">
<span>Descargar Video (.MP4)</span>
</a>
<a id="m3u-link" href="#" class="flex items-center justify-center bg-emerald-500 hover:bg-emerald-600 text-white font-bold py-3 px-6 rounded-xl transition-all shadow-md shadow-emerald-500/20">
<span>Descargar Archivo IPTV (.M3U)</span>
</a>
</div>
<div class="text-slate-500 text-[10px] text-center italic mt-2 space-y-1">
<p id="info-note">El archivo .M3U es ideal para sistemas de IPTV y televisores inteligentes.</p>
</div>
</div>
</div>
<footer class="mt-12 text-center text-slate-500 text-xs space-y-2">
<p>Hecho con 鉂わ笍 para tu Sistema de TV</p>
<p><a href="/debug" class="underline hover:text-blue-400">Ver Logs de Diagn贸stico (Debug)</a></p>
</footer>
</div>
<script>
async function convertLink() {
const urlInput = document.getElementById('youtube-url');
const convertBtn = document.getElementById('convert-btn');
const loading = document.getElementById('loading');
const errorMsg = document.getElementById('error-msg');
const result = document.getElementById('result');
const resultText = document.getElementById('result-text');
const downloadLink = document.getElementById('download-link');
const m3uLink = document.getElementById('m3u-link');
const liveBadge = document.getElementById('live-badge');
const infoNote = document.getElementById('info-note');
const url = urlInput.value.trim();
if (!url) {
showError('Por favor, ingresa una URL de YouTube.');
return;
}
// UI State
errorMsg.classList.add('hidden');
result.classList.add('hidden');
liveBadge.classList.add('hidden');
loading.classList.remove('hidden');
convertBtn.disabled = true;
convertBtn.classList.add('opacity-50', 'cursor-not-allowed');
try {
const response = await fetch('/convert', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ url: url })
});
let data;
try {
data = await response.json();
} catch (e) {
const text = await response.text();
console.error('Server returned non-JSON:', text);
throw new Error(`Error ${response.status}: El servidor no respondi贸 con JSON. Revisa los logs de Hugging Face.`);
}
if (!response.ok) {
throw new Error(data.error || 'Ocurri贸 un error inesperado');
}
// Success
loading.classList.add('hidden');
result.classList.remove('hidden');
resultText.textContent = `"${data.title}"`;
if (data.is_live) {
liveBadge.classList.remove('hidden');
downloadLink.classList.add('hidden');
infoNote.textContent = 'En los directos, usa el archivo .M3U para conectarte al streaming en vivo.';
} else if (data.has_download) {
downloadLink.classList.remove('hidden');
downloadLink.href = data.download_url;
infoNote.textContent = 'El archivo .M3U permite ver el video en streaming sin ocupar espacio.';
} else {
downloadLink.classList.add('hidden');
infoNote.textContent = 'La descarga MP4 ha fallado o el video es muy largo. Usa el archivo .M3U que s铆 funciona.';
}
m3uLink.href = data.m3u_url;
} catch (err) {
showError(err.message);
} finally {
loading.classList.add('hidden');
convertBtn.disabled = false;
convertBtn.classList.remove('opacity-50', 'cursor-not-allowed');
}
}
function showError(msg) {
const errorMsg = document.getElementById('error-msg');
errorMsg.textContent = msg;
errorMsg.classList.remove('hidden');
}
</script>
</body>
</html>
|