Fix: www/ movido a raíz, estructura final

This commit is contained in:
Ricardo Monla
2026-05-04 13:52:29 -03:00
parent 1e13888679
commit 17ff243bfb
337 changed files with 46456 additions and 19 deletions
+137
View File
@@ -0,0 +1,137 @@
#!/usr/bin/env node
/**
* Fija los videos en LIBRO_DE_ESTUDIO.html
* Reemplaza <video> tags con Vimeo iframe embebido + fallback a video local
* Mapeo manual para garantizar correspondencia correcta
*/
import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const LIBRO = path.join(__dirname, "descargas", "LIBRO_DE_ESTUDIO.html");
/**
* MAPA MANUAL: nombre del archivo videos_offline/*.mp4 → ID de Vimeo
* Los videos con "video_NUMERO.mp4" ya llevan el ID en el nombre.
* Los videos con nombre descriptivo se mapean manualmente según el orden
* en que aparecen en las secciones del curso.
*/
const MAPA = {
// ── Módulo 1: Planificación ──
"M1_Planificacion_PLANIFICACIÓN.mp4": "1170245111",
"M1_Preparacion_Atletica_PREPARACIÓN_ATLÉTICA.mp4": "1173231315",
// ── Módulo 2: Centrales y Opuestos ──
"M2_Centrales_y_Oponentes_PRIORIDAD_EN_EL_BLOQUEO.mp4": "919369433",
"M2_Centrales_y_Oponentes_ATAQUE_B.mp4": "919341704",
"M2_Centrales_y_Oponentes_HATU_RECEPCION_PERFECTA.mp4": "919347866",
"M2_Centrales_y_Oponentes_HATU_CON_PELOTA_SEPARADA.mp4": "919348493",
"M2_Centrales_y_Oponentes_HATU_MARCADA.mp4": "919351892",
"M2_Centrales_y_Oponentes_HATUMARCADA_BIEN_ATACADA.mp4": "919352848",
"M2_Centrales_y_Oponentes_HATU_BIEN_HECHA.mp4": "919353448",
"M2_Centrales_y_Oponentes_HANA_POSITIVA.mp4": "919354134",
"M2_Centrales_y_Oponentes_HANA_RECEPCION_A_2.mp4": "919356423",
"M2_Centrales_y_Oponentes_BETI_A_UN_PIE_ATRAS.mp4": "919357109",
"M2_Centrales_y_Oponentes_BETI_EN_JUEGO.mp4": "919358607",
"M2_Centrales_y_Oponentes_APOYO_0.mp4": "919363158",
"M2_Centrales_y_Oponentes_SKIPPED_STEP.mp4": "919364522",
// ── Módulo 2: Puntas y Liberos ──
"M2_Puntas_y_Liberos_PUNTAS_Y_LÍBEROS_AS.mp4": "1179888270",
"M2_Puntas_y_Liberos_SPLIT_STEP.mp4": "921876274",
"M2_Puntas_y_Liberos_EVALUACION_POSICIONAL.mp4": "921874753",
"M2_Puntas_y_Liberos_GLOBAL_TECNICO_DE_LA_PIPE.mp4": "921875020",
};
for (let i = 1; i <= 23; i++) {
const key = `M2_Centrales_y_Oponentes_video_9193${String(i).padStart(2, "0")}XXX`;
// Ya están cubiertos los que tienen video_ID en el nombre
}
function buildVideoMap() {
const libro = fs.readFileSync(LIBRO, "utf-8");
const videoRefs = [...libro.matchAll(/videos_offline\/([^"']+\.mp4)/g)].map(
(m) => m[1],
);
const finalMap = {};
let ok = 0,
fail = 0;
for (const ref of videoRefs) {
// Si tiene video_NUMERO en el filename, extraer el ID
const idMatch = ref.match(/video_(\d+)\.mp4/);
if (idMatch) {
finalMap[ref] = idMatch[1];
ok++;
} else if (MAPA[ref]) {
finalMap[ref] = MAPA[ref];
ok++;
} else {
console.log(` ⚠ SIN MAPA: ${ref}`);
fail++;
}
}
console.log(`\n📊 Total: ${ok} mapeados, ${fail} sin mapa\n`);
return { finalMap, videoRefs };
}
function fixLibro() {
const { finalMap, videoRefs } = buildVideoMap();
let html = fs.readFileSync(LIBRO, "utf-8");
const originalSize = html.length;
const videoRegex =
/<div class="video-container">\s*<video[^>]*>[\s\S]*?<\/video>\s*<\/div>/gs;
const matches = [];
let match;
while ((match = videoRegex.exec(html)) !== null) {
matches.push({
full: match[0],
index: match.index,
src: match[0].match(/videos_offline\/([^"']+)/)?.[1] || "",
});
}
console.log(`Procesando ${matches.length} videos...\n`);
let replaced = 0,
failed = 0;
for (const m of matches.reverse()) {
const vimeoId = finalMap[m.src];
if (!vimeoId) {
failed++;
continue;
}
const vimeoEmbed = `<div style="position:relative;padding-bottom:56.25%;height:0;overflow:hidden;margin-bottom:10px;border-radius:8px;background:#000;">
<iframe src="https://player.vimeo.com/video/${vimeoId}"
style="position:absolute;top:0;left:0;width:100%;height:100%;border:0;"
allow="autoplay;fullscreen;picture-in-picture" allowfullscreen loading="lazy">
</iframe>
</div>`;
const replacement = `<div class="video-container">
${vimeoEmbed}
${m.full}
</div>`;
html =
html.substring(0, m.index) +
replacement +
html.substring(m.index + m.full.length);
replaced++;
}
console.log(`${replaced} videos con reproductor Vimeo`);
if (failed > 0)
console.log(`${failed} videos sin mapear (mantenidos como locales)`);
fs.writeFileSync(LIBRO, html, "utf-8");
console.log(
`✅ LIBRO_DE_ESTUDIO.html actualizado (${originalSize}${html.length} bytes)`,
);
}
fixLibro();