A clean and minimal youtube frontend, without all the ads and whistles
JavaScript
fix: disk space calculated on all videos..
Christian Fei790261ee53f7
diff --git a/lib/repository.js b/lib/repository.jsindex 8868f20..68b259f 100644--- a/lib/repository.js+++ b/lib/repository.js@@ -58,6 +58,9 @@ export default class Repository {saveSettings() {fs.writeFileSync(this.paths.settings, JSON.stringify(this.settings, null, 2))}+ getAllVideos() {+ return this.videos+ }getVideos (query = {}) {const isFiltering = Object.keys(query).length > 0 && query.filterlet videos = this.videosdiff --git a/lib/server.js b/lib/server.jsindex 9c96490..cd54317 100644--- a/lib/server.js+++ b/lib/server.js@@ -338,17 +338,20 @@ async function setVideoQualityHandler(req, res, repo) {function diskUsageHandler(req, res, repo) {const onlyIgnored = getQuery(req).onlyIgnored === 'true'- const videos = repo.getVideos()+ const videos = repo.getAllVideos()- const filterFn = onlyIgnored- ? video => video.downloaded && video.ignored- : video => video.downloaded+ const filterFn = onlyIgnored ? video => video.downloaded && video.ignored : video => video.downloadedconst diskSpaceUsed = videos.filter(filterFn).reduce((total, video) => {try {- return total + fs.statSync(`./data/videos/${video.id}.mp4`).size / Math.pow(10, 9)+ const files = fs.globSync(`./data/videos/${video.id}*`)+ return total + files.reduce((acc, file) => {+ const filesize = fs.statSync(file).size / Math.pow(10, 9)+ return acc + filesize+ }, 0)} catch (err) {+ console.error(err)return total}}, 0)