34 lines
900 B
JavaScript
34 lines
900 B
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
const VIDEO_DIR = "videos";
|
|
const DESCRIPTION_FILE = "description.json";
|
|
const INDEX_FILE = "index.json";
|
|
|
|
let info = [];
|
|
|
|
for (let dir of fs.readdirSync(VIDEO_DIR)) {
|
|
if (dir === INDEX_FILE) {
|
|
continue;
|
|
}
|
|
|
|
let description = JSON.parse(fs.readFileSync(path.join(VIDEO_DIR, dir, DESCRIPTION_FILE)));
|
|
description.url = dir + "/";
|
|
description.videos = [];
|
|
|
|
for (let subdir of fs.readdirSync(path.join(VIDEO_DIR, dir))) {
|
|
if (subdir === DESCRIPTION_FILE) {
|
|
continue;
|
|
}
|
|
|
|
let subdescription = JSON.parse(fs.readFileSync(path.join(VIDEO_DIR, dir, subdir, DESCRIPTION_FILE)));
|
|
subdescription.url = subdir + "/";
|
|
|
|
description.videos.push(subdescription);
|
|
}
|
|
|
|
info.push(description);
|
|
}
|
|
|
|
fs.writeFileSync(path.join(VIDEO_DIR, INDEX_FILE), JSON.stringify(info));
|
|
|