Browse Source

Updated file preview to take the video preview 5 minutes into to movie to prevent blank icons. Minor bug fixes.

pull/7/head
jrtechs 5 years ago
parent
commit
8984782b96
10 changed files with 82 additions and 20 deletions
  1. +6
    -0
      README.MD
  2. +11
    -4
      html/error.html
  3. +4
    -4
      html/videos.html
  4. +28
    -0
      package.json
  5. +0
    -3
      routes/icon.js
  6. +6
    -0
      routes/index.js
  7. +17
    -1
      routes/watch.js
  8. +6
    -5
      server.js
  9. +1
    -0
      utils.js
  10. +3
    -3
      videoManager.js

+ 6
- 0
README.MD View File

@ -23,6 +23,12 @@ npm install express-session --save
npm install whiskers --save npm install whiskers --save
``` ```
Dependencies
```bash
$apt-get install ffmpeg
```
Codacs which don't work Codacs which don't work
H.265 H.265

+ 11
- 4
html/error.html View File

@ -1,4 +1,11 @@
<center><h1 class="align-content-center">{errorMessage}</h1></center>
<br><br>
<img class="mx-auto d-block" src="/404.jpg" alt="Page not found" width="40%" />
<br><br>
<div class="row">
<div class="col-md-6">
<center><h1 class="align-content-center">{errorMessage}</h1></center>
<br>
<img class="mx-auto d-block" src="/404.jpg" alt="Page not found" width="60%" />
<br><br>
</div>
<div class="col-md-6">
{>login}
</div>
</div>

+ 4
- 4
html/videos.html View File

@ -9,10 +9,10 @@
<div class="row"> <div class="row">
{for video in private} {for video in private}
<div class="col-md-4 videoElement">
<div class="col-md-3 videoElement p-2">
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
<h2>{video.name}</h2>
<h4>{video.name}</h4>
</div> </div>
<div class="card-body"> <div class="card-body">
<a href="/watch?v={video.name}" class="" role="button" aria-pressed="true"> <a href="/watch?v={video.name}" class="" role="button" aria-pressed="true">
@ -23,10 +23,10 @@
</div> </div>
{/for} {/for}
{for video in public} {for video in public}
<div class="col-md-4 videoElement">
<div class="col-md-3 videoElement p-2">
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
<h2>{video.name}</h2>
<h4>{video.name}</h4>
</div> </div>
<div class="card-body"> <div class="card-body">
<a href="/watch?v={video.name}" class="" role="button" aria-pressed="true"> <a href="/watch?v={video.name}" class="" role="button" aria-pressed="true">

+ 28
- 0
package.json View File

@ -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"
}
}

+ 0
- 3
routes/icon.js View File

@ -20,8 +20,6 @@ routes.get('/', (request, result) =>
const splitArray = videoID.split('/'); const splitArray = videoID.split('/');
const name = splitArray[splitArray.length -1] + ".png"; const name = splitArray[splitArray.length -1] + ".png";
console.log(name);
var file=""; var file="";
if(!videoManager.isPublicVideo(videoID)) if(!videoManager.isPublicVideo(videoID))
@ -49,7 +47,6 @@ routes.get('/', (request, result) =>
catch(error) catch(error)
{ {
utils.printError(result, "Invalid Icon"); utils.printError(result, "Invalid Icon");
console.log(error);
} }
}); });

+ 6
- 0
routes/index.js View File

@ -30,4 +30,10 @@ routes.get('/', (request, result) =>
utils.renderHTML(request, result, "home.html", getHomePageInformation) utils.renderHTML(request, result, "home.html", getHomePageInformation)
}); });
routes.get('*', (request, result) =>
{
utils.printError(result, "Page not found.");
});
module.exports = routes; module.exports = routes;

+ 17
- 1
routes/watch.js View File

@ -4,16 +4,32 @@ const utils = require("../utils");
const configManager = require("../configManager"); const configManager = require("../configManager");
const videoManager = require("../videoManager");
function getVideoTemplateInfo(templateContext, request) function getVideoTemplateInfo(templateContext, request)
{ {
templateContext.api = request.session.API; templateContext.api = request.session.API;
templateContext.serverURL = configManager.getServerURL(); templateContext.serverURL = configManager.getServerURL();
templateContext.videoURL = request.query.v.split(" ").join("%20"); 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) => 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; module.exports = routes;

+ 6
- 5
server.js View File

@ -11,20 +11,21 @@ const app = express();
/**Initializes sessions for login */ /**Initializes sessions for login */
app.use(session( app.use(session(
{ secret: configLoader.getConfiguration().sessionSecret, { 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.urlencoded()); //for easy retrieval of post and get data
app.use(express.json()); app.use(express.json());
const routes = require('./routes');
app.use('/', routes);
app.use(express.static('css')); app.use(express.static('css'));
app.use(express.static('js')); app.use(express.static('js'));
app.use(express.static('img')); app.use(express.static('img'));
const routes = require('./routes');
app.use('/', routes);
app.listen(configLoader.getConfiguration().port, () => app.listen(configLoader.getConfiguration().port, () =>
console.log(`App listening on port ${configLoader.getConfiguration().port}!`) console.log(`App listening on port ${configLoader.getConfiguration().port}!`)
); );

+ 1
- 0
utils.js View File

@ -71,6 +71,7 @@ module.exports =
prom.push(fetchInTemplate(templateContext, "header", "./html/header.html")); prom.push(fetchInTemplate(templateContext, "header", "./html/header.html"));
prom.push(fetchInTemplate(templateContext, "footer", "./html/footer.html")); prom.push(fetchInTemplate(templateContext, "footer", "./html/footer.html"));
prom.push(fetchInTemplate(templateContext, "main", "./html/error.html")); prom.push(fetchInTemplate(templateContext, "main", "./html/error.html"));
prom.push(fetchInTemplate(templateContext, "login","./html/login.html"));
templateContext.errorMessage = errorMessage; templateContext.errorMessage = errorMessage;
Promise.all(prom).then(function(content) Promise.all(prom).then(function(content)

+ 3
- 3
videoManager.js View File

@ -18,7 +18,6 @@ module.exports =
{ {
recursive(rootDir, function (err, files) recursive(rootDir, function (err, files)
{ {
console.log(files);
files.forEach(file => files.forEach(file =>
{ {
var splitArray = file.split('/'); var splitArray = file.split('/');
@ -28,7 +27,8 @@ module.exports =
{ {
var options = { var options = {
width: 200, width: 200,
quality: 50
quality: 50,
previewTime: '00:05:00.000'
}; };
filepreview.generate(file, icon, options,function(error) { filepreview.generate(file, icon, options,function(error) {
@ -44,7 +44,7 @@ module.exports =
}); });
}).catch(function(error) }).catch(function(error)
{ {
console.log(error);
//console.log(error);
}) })
}, },

Loading…
Cancel
Save