29 lines
791 B
JavaScript
29 lines
791 B
JavaScript
|
const fs = require('fs');
|
||
|
const path = require('path');
|
||
|
const VIDEO_DIR = "videos";
|
||
|
const DESCRIPTION_FILE = "description.json";
|
||
|
|
||
|
let info = [];
|
||
|
|
||
|
for (let dir of fs.readdirSync(VIDEO_DIR)) {
|
||
|
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('index.json', JSON.stringify(info));
|
||
|
|