hologramicon commited on
Commit
5b9138f
·
verified ·
1 Parent(s): 28cf732

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +46 -36
index.html CHANGED
@@ -5,78 +5,88 @@
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Unir Videos</title>
7
  <style>
8
- body { font-family: sans-serif; max-width: 800px; margin: auto; padding: 20px; }
9
- textarea { width: 100%; min-height: 150px; margin-bottom: 10px; }
10
- button { padding: 10px 20px; font-size: 16px; }
11
- #status-container { margin-top: 20px; border: 1px solid #ccc; padding: 10px; background: #f9f9f9; }
12
- #log { white-space: pre-wrap; font-family: monospace; max-height: 300px; overflow-y: auto; }
13
- progress { width: 100%; }
 
 
 
14
  </style>
15
  </head>
16
  <body>
17
  <h1>Unir Videos desde URLs</h1>
18
- <p>Pega una URL por línea. Se descargarán y unirán en un solo video WebM.</p>
19
- <textarea id="urls" placeholder="https://www.youtube.com/watch?v=...\nhttps://vimeo.com/..."></textarea>
20
- <button onclick="startProcess()">Iniciar Proceso</button>
 
21
 
22
- <div id="status-container" style="display:none;">
23
  <h2>Estado del Proceso</h2>
24
- <p>Task ID: <b id="taskId"></b></p>
25
- <p>Estado: <b id="status"></b></p>
26
- <progress id="progress" value="0" max="100"></progress>
27
- <h3>Log:</h3>
28
  <pre id="log"></pre>
29
- <div id="download-link-container"></div>
30
  </div>
31
 
32
  <script>
33
- let taskId = null;
 
 
 
 
 
 
 
34
  let intervalId = null;
35
 
36
  async function startProcess() {
37
- const urlsText = document.getElementById('urls').value;
38
- const urls = urlsText.split('\n').filter(url => url.trim() !== '');
39
-
40
  if (urls.length === 0) {
41
  alert('Por favor, ingresa al menos una URL.');
42
  return;
43
  }
44
 
45
- document.getElementById('status-container').style.display = 'block';
46
- document.getElementById('status').innerText = 'Enviando...';
47
- document.getElementById('download-link-container').innerHTML = '';
 
 
48
 
49
  const response = await fetch('/api/process', {
50
  method: 'POST',
51
  headers: { 'Content-Type': 'application/json' },
52
- body: JSON.stringify({ urls: urls })
53
  });
54
 
55
  const data = await response.json();
56
- taskId = data.taskId;
57
- document.getElementById('taskId').innerText = taskId;
58
-
59
- intervalId = setInterval(checkStatus, 2000); // Revisar estado cada 2 segundos
60
  }
61
 
62
- async function checkStatus() {
63
- if (!taskId) return;
64
-
65
  const response = await fetch(`/api/status/${taskId}`);
66
  const data = await response.json();
67
 
68
- document.getElementById('status').innerText = data.status;
69
- document.getElementById('progress').value = data.progress;
70
- document.getElementById('log').innerText = data.log;
71
 
72
  if (data.status === 'completed' || data.status === 'failed') {
73
  clearInterval(intervalId);
74
- if(data.fileUrl) {
 
 
 
75
  const link = document.createElement('a');
76
  link.href = data.fileUrl;
77
- link.textContent = 'Descargar Video Final';
78
  link.setAttribute('download', '');
79
- document.getElementById('download-link-container').appendChild(link);
 
 
80
  }
81
  }
82
  }
 
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Unir Videos</title>
7
  <style>
8
+ body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; max-width: 800px; margin: 2rem auto; padding: 0 1rem; background-color: #f8f9fa; color: #333; }
9
+ h1 { color: #007bff; }
10
+ textarea { width: 100%; min-height: 120px; margin-bottom: 1rem; padding: 10px; border-radius: 8px; border: 1px solid #ccc; font-size: 16px; }
11
+ button { display: block; width: 100%; padding: 12px 20px; font-size: 18px; font-weight: bold; color: white; background-color: #007bff; border: none; border-radius: 8px; cursor: pointer; transition: background-color 0.2s; }
12
+ button:disabled { background-color: #6c757d; cursor: not-allowed; }
13
+ #status-container { margin-top: 1.5rem; border: 1px solid #e9ecef; border-radius: 8px; padding: 1.5rem; background: #fff; display: none; }
14
+ #log { white-space: pre-wrap; font-family: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", monospace; background-color: #e9ecef; padding: 1rem; border-radius: 4px; max-height: 300px; overflow-y: auto; }
15
+ progress { width: 100%; height: 12px; margin: 0.5rem 0; }
16
+ #download-link a { font-weight: bold; color: #28a745; text-decoration: none; }
17
  </style>
18
  </head>
19
  <body>
20
  <h1>Unir Videos desde URLs</h1>
21
+ <p>Pega una URL por línea. Se descargarán y unirán en un solo video en formato WebM.</p>
22
+
23
+ <textarea id="urls" placeholder="https://www.youtube.com/watch?v=..."></textarea>
24
+ <button id="process-btn" onclick="startProcess()">✨ Iniciar Proceso</button>
25
 
26
+ <div id="status-container">
27
  <h2>Estado del Proceso</h2>
28
+ <p>Progreso: <b id="status-text">En cola...</b></p>
29
+ <progress id="progress-bar" value="0" max="100"></progress>
30
+ <h3>Registro (Log):</h3>
 
31
  <pre id="log"></pre>
32
+ <div id="download-link"></div>
33
  </div>
34
 
35
  <script>
36
+ const processBtn = document.getElementById('process-btn');
37
+ const urlsTextarea = document.getElementById('urls');
38
+ const statusContainer = document.getElementById('status-container');
39
+ const statusText = document.getElementById('status-text');
40
+ const progressBar = document.getElementById('progress-bar');
41
+ const logPre = document.getElementById('log');
42
+ const downloadLinkDiv = document.getElementById('download-link');
43
+
44
  let intervalId = null;
45
 
46
  async function startProcess() {
47
+ const urls = urlsTextarea.value.split('\n').filter(url => url.trim() !== '');
 
 
48
  if (urls.length === 0) {
49
  alert('Por favor, ingresa al menos una URL.');
50
  return;
51
  }
52
 
53
+ // Deshabilitar botón y mostrar estado
54
+ processBtn.disabled = true;
55
+ processBtn.textContent = 'Procesando... ⏳';
56
+ statusContainer.style.display = 'block';
57
+ downloadLinkDiv.innerHTML = '';
58
 
59
  const response = await fetch('/api/process', {
60
  method: 'POST',
61
  headers: { 'Content-Type': 'application/json' },
62
+ body: JSON.stringify({ urls })
63
  });
64
 
65
  const data = await response.json();
66
+ intervalId = setInterval(() => checkStatus(data.taskId), 2000);
 
 
 
67
  }
68
 
69
+ async function checkStatus(taskId) {
 
 
70
  const response = await fetch(`/api/status/${taskId}`);
71
  const data = await response.json();
72
 
73
+ statusText.textContent = data.status;
74
+ progressBar.value = data.progress;
75
+ logPre.textContent = data.log;
76
 
77
  if (data.status === 'completed' || data.status === 'failed') {
78
  clearInterval(intervalId);
79
+ processBtn.disabled = false;
80
+ processBtn.textContent = '✨ Iniciar Proceso';
81
+
82
+ if (data.status === 'completed' && data.fileUrl) {
83
  const link = document.createElement('a');
84
  link.href = data.fileUrl;
85
+ link.textContent = 'Descargar Video Final';
86
  link.setAttribute('download', '');
87
+ downloadLinkDiv.appendChild(link);
88
+ } else {
89
+ downloadLinkDiv.innerHTML = '<p style="color:red;">❌ El proceso ha fallado.</p>';
90
  }
91
  }
92
  }