Skip to content

Commit

Permalink
update media types
Browse files Browse the repository at this point in the history
  • Loading branch information
khanhtc1202 committed Jan 18, 2018
1 parent c8c41f4 commit a193253
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
media/*
media/*.mp4
media/*.mkv
node_modules/
*.pyc
*.log
Empty file added media/.gitkeep
Empty file.
6 changes: 4 additions & 2 deletions server/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ var config = {
mediaPath: rootPath + '/../media/',
mediaDummyPath: rootPath + '/../dummy_files/nope.mp4',
logPath: rootPath + '/../logs/run.log',
mediaBaseUrl: 'http://fromnoobstogeeks.com:7001/'
mediaBaseUrl: 'http://fromnoobstogeeks.com:7001/',
mediaTypes: ['.mp4', '.mkv']
},
port: port
},
Expand All @@ -23,7 +24,8 @@ var config = {
mediaPath: rootPath + '/../media/',
mediaDummyPath: rootPath + '/../dummy_files/nope.mp4',
logPath: rootPath + '/../logs/run.log',
mediaBaseUrl: 'http://fromnoobstogeeks.com:7001/'
mediaBaseUrl: 'http://fromnoobstogeeks.com:7001/',
mediaTypes: ['.mp4', '.mkv']
},
port: port
}
Expand Down
15 changes: 9 additions & 6 deletions server/controllers/videos.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
module.exports = function(config, utils) {
var fs = require('fs');
var path = require('path');
var obj = {};

obj.list = function(req, res, next) {
var mediaFiles = [];
fs.readdirSync(config.app.mediaPath).forEach(function(file) {
mediaFiles[mediaFiles.length] = {
"name": file,
"url": utils.createUrl('video', file),
"delete": utils.createUrl('delete', file)
};
console.log("Loaded file " + file + " ready to view!");
if (config.app.mediaTypes.indexOf(path.extname(file)) > -1) {
mediaFiles[mediaFiles.length] = {
"name": file,
"url": utils.createUrl('video', file),
"delete": utils.createUrl('delete', file)
};
console.log("Loaded file " + file + " ready to view!");
}
});
res.render('videos', { 'data': mediaFiles });
};
Expand Down

0 comments on commit a193253

Please sign in to comment.