Fix indexify

This commit is contained in:
Thomas Forgione 2020-10-08 16:33:30 +02:00
parent 1ba2bbd8ce
commit c8664f2375
1 changed files with 6 additions and 1 deletions

View File

@ -2,10 +2,15 @@ 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 = [];
@ -24,5 +29,5 @@ for (let dir of fs.readdirSync(VIDEO_DIR)) {
info.push(description);
}
fs.writeFileSync(path.join(VIDEO_DIR, 'index.json'), JSON.stringify(info));
fs.writeFileSync(path.join(VIDEO_DIR, INDEX_FILE), JSON.stringify(info));