From 9665ef14b5c6db5271a42615652d344e5ea7a9d7 Mon Sep 17 00:00:00 2001 From: jrtechs Date: Sun, 10 Feb 2019 13:43:47 -0500 Subject: [PATCH] Fixed bug with finding out if a video is public or private and changed the way which icons are generated to be a more supported plugin which outputs GIFs. --- package.json | 4 ++-- routes/icon.js | 3 ++- videoManager.js | 33 ++++++++++++++++----------------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 008e5de..7580710 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "Home Brew Plex", + "name": "HomeBrewPlex", "version": "1.0.0", "description": "Light weight alternative for Plex", "main": "server.js", @@ -22,7 +22,7 @@ "download-file": "^0.1.5", "express": "^4.16.4", "express-session": "^1.15.6", - "filepreview": "^1.0.16", + "ffmpeg-generate-video-preview": "^1.0.3", "fs": "0.0.2", "path": "^0.12.7", "url": "^0.11.0", diff --git a/routes/icon.js b/routes/icon.js index 4053872..6547715 100644 --- a/routes/icon.js +++ b/routes/icon.js @@ -18,7 +18,7 @@ routes.get('/', (request, result) => const videoID = request.query.v; const splitArray = videoID.split('/'); - const name = splitArray[splitArray.length -1] + ".png"; + const name = splitArray[splitArray.length -1] + ".gif"; var file=""; @@ -36,6 +36,7 @@ routes.get('/', (request, result) => } else { + console.log("reading ./icon/public/" + name); file = fs.readFileSync("./icon/public/" + name); } diff --git a/videoManager.js b/videoManager.js index de1e37f..d8c46bb 100644 --- a/videoManager.js +++ b/videoManager.js @@ -2,7 +2,7 @@ const configManager = require('./configManager'); const recursive = require('./recursiveTraversal'); -const filepreview = require('filepreview'); +const generatePreview = require('ffmpeg-generate-video-preview') const fs = require('fs'); @@ -17,24 +17,22 @@ function createIndex(filename, videos, templateKey) console.log("Generating icon for " + filename); var splitArray = filename.split('/'); var name = splitArray[splitArray.length -1]; - const icon = './icon/' + templateKey + '/' + name + ".png"; + const icon = 'icon/' + templateKey + '/' + name + ".gif"; if (!fs.existsSync(icon)) { - var options = { - width: 200, - quality: 50, - previewTime: '00:05:00.000' - }; - - filepreview.generate(filename, icon, options, function (error) - { - if (error) + var options = { - resolve(); - } - console.log('File preview is located ' + icon); + input: filename, + output: icon, + width: 128, + numFrames: 40 + }; + console.log(options); + generatePreview(options).then(function(metaData) + { + console.log(metaData); resolve(); - }); + }) } else { @@ -125,7 +123,7 @@ module.exports = { const splitArray = publicVideos[i].name.split('/'); const name = splitArray[splitArray.length -1]; - + videoName = videoName.split('/').join(""); if(name === videoName) { return true; @@ -141,7 +139,8 @@ module.exports = const splitArray = publicVideos[i].name.split('/'); const name = splitArray[splitArray.length -1]; - if(name === videoName) + videoName = videoName.split('/').join(""); + if(name + "" === videoName) { return true; }