diff --git a/README.MD b/README.MD index 945654e..76b6ed3 100644 --- a/README.MD +++ b/README.MD @@ -23,6 +23,12 @@ npm install express-session --save npm install whiskers --save ``` +Dependencies + +```bash +$apt-get install ffmpeg +``` + Codacs which don't work H.265 diff --git a/html/error.html b/html/error.html index 1549c1f..678c3ef 100644 --- a/html/error.html +++ b/html/error.html @@ -1,4 +1,11 @@ -

{errorMessage}

-

-Page not found -

\ No newline at end of file +
+
+

{errorMessage}

+
+ Page not found +

+
+
+ {>login} +
+
diff --git a/html/videos.html b/html/videos.html index 6786e57..6ef6dcf 100644 --- a/html/videos.html +++ b/html/videos.html @@ -9,10 +9,10 @@
{for video in private} -
+
-

{video.name}

+

{video.name}

{/for} {for video in public} -
+
-

{video.name}

+

{video.name}

diff --git a/package.json b/package.json new file mode 100644 index 0000000..d568e42 --- /dev/null +++ b/package.json @@ -0,0 +1,28 @@ +{ + "name": "HomeBrewPlex", + "version": "0.1.0", + "description": "Light weight alternative for Plex", + "main": "server.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "start": "node server.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/jrtechs/HomeBrewPlex.git" + }, + "author": "Jeffery Russell", + "license": "MPL 2.0", + "bugs": { + "url": "https://github.com/jrtechs/HomeBrewPlex/issues" + }, + "homepage": "https://github.com/jrtechs/HomeBrewPlex#readme", + "dependencies": { + "download-file": "^0.1.5", + "express-session": "^1.15.6", + "fs": "0.0.2", + "path": "^0.12.7", + "url": "^0.11.0", + "whiskers": "^0.4.0" + } +} diff --git a/routes/icon.js b/routes/icon.js index 2c438ba..4053872 100644 --- a/routes/icon.js +++ b/routes/icon.js @@ -20,8 +20,6 @@ routes.get('/', (request, result) => const splitArray = videoID.split('/'); const name = splitArray[splitArray.length -1] + ".png"; - console.log(name); - var file=""; if(!videoManager.isPublicVideo(videoID)) @@ -49,7 +47,6 @@ routes.get('/', (request, result) => catch(error) { utils.printError(result, "Invalid Icon"); - console.log(error); } }); diff --git a/routes/index.js b/routes/index.js index a18abd0..4d37cb6 100644 --- a/routes/index.js +++ b/routes/index.js @@ -30,4 +30,10 @@ routes.get('/', (request, result) => utils.renderHTML(request, result, "home.html", getHomePageInformation) }); + +routes.get('*', (request, result) => +{ + utils.printError(result, "Page not found."); +}); + module.exports = routes; \ No newline at end of file diff --git a/routes/watch.js b/routes/watch.js index f88b15a..626adb8 100644 --- a/routes/watch.js +++ b/routes/watch.js @@ -4,16 +4,32 @@ const utils = require("../utils"); const configManager = require("../configManager"); +const videoManager = require("../videoManager"); + function getVideoTemplateInfo(templateContext, request) { templateContext.api = request.session.API; templateContext.serverURL = configManager.getServerURL(); templateContext.videoURL = request.query.v.split(" ").join("%20"); + + if(utils.checkPrivilege(request) === utils.PRIVILEGE.NOBODY + && !videoManager.isPublicVideo(request.query.v)) + { + throw "Video either doesn't exist or you need to log in."; + } } routes.get('/', (request, result) => { - utils.renderHTML(request, result, "watch.html", getVideoTemplateInfo) + try + { + utils.renderHTML(request, result, "watch.html", getVideoTemplateInfo) + } + catch(error) + { + utils.printError(result, error); + } + }); module.exports = routes; \ No newline at end of file diff --git a/server.js b/server.js index c72dfdb..58e1792 100644 --- a/server.js +++ b/server.js @@ -11,20 +11,21 @@ const app = express(); /**Initializes sessions for login */ app.use(session( { secret: configLoader.getConfiguration().sessionSecret, - cookie: { maxAge: 6000000 } - } + cookie: { maxAge: 6000000 }} )); app.use(express.urlencoded()); //for easy retrieval of post and get data app.use(express.json()); -const routes = require('./routes'); -app.use('/', routes); - app.use(express.static('css')); app.use(express.static('js')); app.use(express.static('img')); +const routes = require('./routes'); +app.use('/', routes); + + + app.listen(configLoader.getConfiguration().port, () => console.log(`App listening on port ${configLoader.getConfiguration().port}!`) ); \ No newline at end of file diff --git a/utils.js b/utils.js index 117ef2c..bd7866c 100644 --- a/utils.js +++ b/utils.js @@ -71,6 +71,7 @@ module.exports = prom.push(fetchInTemplate(templateContext, "header", "./html/header.html")); prom.push(fetchInTemplate(templateContext, "footer", "./html/footer.html")); prom.push(fetchInTemplate(templateContext, "main", "./html/error.html")); + prom.push(fetchInTemplate(templateContext, "login","./html/login.html")); templateContext.errorMessage = errorMessage; Promise.all(prom).then(function(content) diff --git a/videoManager.js b/videoManager.js index b98b49f..37cf0b3 100644 --- a/videoManager.js +++ b/videoManager.js @@ -18,7 +18,6 @@ module.exports = { recursive(rootDir, function (err, files) { - console.log(files); files.forEach(file => { var splitArray = file.split('/'); @@ -28,7 +27,8 @@ module.exports = { var options = { width: 200, - quality: 50 + quality: 50, + previewTime: '00:05:00.000' }; filepreview.generate(file, icon, options,function(error) { @@ -44,7 +44,7 @@ module.exports = }); }).catch(function(error) { - console.log(error); + //console.log(error); }) },