59 lines
2.0 KiB
JavaScript
59 lines
2.0 KiB
JavaScript
import fs from 'fs';
|
|
|
|
const dbPath = 'descargar-curso/.mapa_videos.json';
|
|
const db = JSON.parse(fs.readFileSync(dbPath, 'utf-8'));
|
|
|
|
let total = 0;
|
|
let downloaded = 0;
|
|
let missing = [];
|
|
|
|
for (const mod of db.modulos) {
|
|
for (const sec of mod.secciones) {
|
|
for (const tema of sec.temas) {
|
|
|
|
// Text contents
|
|
if (tema.contenido_html) {
|
|
total++;
|
|
const htmlPath = `descargar-curso/descargas/secciones/${mod.carpeta}/${sec.carpeta}/${tema.contenido_html}`;
|
|
if (fs.existsSync(htmlPath)) {
|
|
downloaded++;
|
|
} else {
|
|
missing.push(`[Texto] ${tema.titulo}`);
|
|
}
|
|
}
|
|
|
|
// Videos
|
|
if (tema.videos && tema.videos.length > 0) {
|
|
tema.videos.forEach(v => {
|
|
total++;
|
|
const videoPath = `descargar-curso/descargas/secciones/${mod.carpeta}/${sec.carpeta}/${v.archivo_local}`;
|
|
if (fs.existsSync(videoPath)) {
|
|
downloaded++;
|
|
} else {
|
|
missing.push(`[Video] ${v.titulo}`);
|
|
}
|
|
});
|
|
}
|
|
|
|
// Resources
|
|
if (tema.recursos && tema.recursos.length > 0) {
|
|
tema.recursos.forEach(r => {
|
|
total++;
|
|
const recursoPath = `descargar-curso/descargas/secciones/${mod.carpeta}/${sec.carpeta}/${r.archivo_local}`;
|
|
if (fs.existsSync(recursoPath)) {
|
|
downloaded++;
|
|
} else {
|
|
missing.push(`[Recurso] ${r.titulo} (Esperado: ${r.archivo_local})`);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
console.log(`Total: ${total}`);
|
|
console.log(`Downloaded: ${downloaded}`);
|
|
console.log(`Missing: ${total - downloaded}`);
|
|
console.log("Missing Items:");
|
|
missing.forEach(m => console.log(" - " + m));
|