elm-twitch/indexify.js

29 lines
813 B
JavaScript
Raw Normal View History

2020-10-05 11:26:11 +02:00
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);
}
2020-10-05 11:56:14 +02:00
fs.writeFileSync(path.join(VIDEO_DIR, 'index.json'), JSON.stringify(info));
2020-10-05 11:26:11 +02:00