aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/v1/videos.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-03-16 22:29:27 +0100
committerChocobozzz <florian.bigard@gmail.com>2016-03-16 22:29:27 +0100
commitf0f5567b6918fc60c8cab15e13aec03a89a91dfb (patch)
tree99dfdb9fa8273c9cda1360fd3b6bfccc515bf8be /server/controllers/api/v1/videos.js
parent5101105ef91bfe478f97546b78b321882da2079c (diff)
downloadPeerTube-f0f5567b6918fc60c8cab15e13aec03a89a91dfb.tar.gz
PeerTube-f0f5567b6918fc60c8cab15e13aec03a89a91dfb.tar.zst
PeerTube-f0f5567b6918fc60c8cab15e13aec03a89a91dfb.zip
Use const/let now we use node 4.2
Diffstat (limited to 'server/controllers/api/v1/videos.js')
-rw-r--r--server/controllers/api/v1/videos.js50
1 files changed, 25 insertions, 25 deletions
diff --git a/server/controllers/api/v1/videos.js b/server/controllers/api/v1/videos.js
index 76cad62d1..1eea417d4 100644
--- a/server/controllers/api/v1/videos.js
+++ b/server/controllers/api/v1/videos.js
@@ -1,41 +1,41 @@
1'use strict' 1'use strict'
2 2
3var config = require('config') 3const config = require('config')
4var crypto = require('crypto') 4const crypto = require('crypto')
5var express = require('express') 5const express = require('express')
6var multer = require('multer') 6const multer = require('multer')
7 7
8var logger = require('../../../helpers/logger') 8const logger = require('../../../helpers/logger')
9var friends = require('../../../lib/friends') 9const friends = require('../../../lib/friends')
10var middleware = require('../../../middlewares') 10const middleware = require('../../../middlewares')
11var cacheMiddleware = middleware.cache 11const cacheMiddleware = middleware.cache
12var reqValidator = middleware.reqValidators.videos 12const reqValidator = middleware.reqValidators.videos
13var Videos = require('../../../models/videos') // model 13const Videos = require('../../../models/videos') // model
14var videos = require('../../../lib/videos') 14const videos = require('../../../lib/videos')
15var webtorrent = require('../../../lib/webtorrent') 15const webtorrent = require('../../../lib/webtorrent')
16 16
17var router = express.Router() 17const router = express.Router()
18var uploads = config.get('storage.uploads') 18const uploads = config.get('storage.uploads')
19 19
20// multer configuration 20// multer configuration
21var storage = multer.diskStorage({ 21const storage = multer.diskStorage({
22 destination: function (req, file, cb) { 22 destination: function (req, file, cb) {
23 cb(null, uploads) 23 cb(null, uploads)
24 }, 24 },
25 25
26 filename: function (req, file, cb) { 26 filename: function (req, file, cb) {
27 var extension = '' 27 let extension = ''
28 if (file.mimetype === 'video/webm') extension = 'webm' 28 if (file.mimetype === 'video/webm') extension = 'webm'
29 else if (file.mimetype === 'video/mp4') extension = 'mp4' 29 else if (file.mimetype === 'video/mp4') extension = 'mp4'
30 else if (file.mimetype === 'video/ogg') extension = 'ogv' 30 else if (file.mimetype === 'video/ogg') extension = 'ogv'
31 crypto.pseudoRandomBytes(16, function (err, raw) { 31 crypto.pseudoRandomBytes(16, function (err, raw) {
32 var fieldname = err ? undefined : raw.toString('hex') 32 const fieldname = err ? undefined : raw.toString('hex')
33 cb(null, fieldname + '.' + extension) 33 cb(null, fieldname + '.' + extension)
34 }) 34 })
35 } 35 }
36}) 36})
37 37
38var reqFiles = multer({ storage: storage }).fields([{ name: 'input_video', maxCount: 1 }]) 38const reqFiles = multer({ storage: storage }).fields([{ name: 'input_video', maxCount: 1 }])
39 39
40router.get('/', cacheMiddleware.cache(false), listVideos) 40router.get('/', cacheMiddleware.cache(false), listVideos)
41router.post('/', reqFiles, reqValidator.videosAdd, cacheMiddleware.cache(false), addVideo) 41router.post('/', reqFiles, reqValidator.videosAdd, cacheMiddleware.cache(false), addVideo)
@@ -50,8 +50,8 @@ module.exports = router
50// --------------------------------------------------------------------------- 50// ---------------------------------------------------------------------------
51 51
52function addVideo (req, res, next) { 52function addVideo (req, res, next) {
53 var video_file = req.files.input_video[0] 53 const video_file = req.files.input_video[0]
54 var video_infos = req.body 54 const video_infos = req.body
55 55
56 videos.seed(video_file.path, function (err, torrent) { 56 videos.seed(video_file.path, function (err, torrent) {
57 if (err) { 57 if (err) {
@@ -59,7 +59,7 @@ function addVideo (req, res, next) {
59 return next(err) 59 return next(err)
60 } 60 }
61 61
62 var video_data = { 62 const video_data = {
63 name: video_infos.name, 63 name: video_infos.name,
64 namePath: video_file.filename, 64 namePath: video_file.filename,
65 description: video_infos.description, 65 description: video_infos.description,
@@ -103,7 +103,7 @@ function listVideos (req, res, next) {
103} 103}
104 104
105function removeVideo (req, res, next) { 105function removeVideo (req, res, next) {
106 var video_id = req.params.id 106 const video_id = req.params.id
107 Videos.get(video_id, function (err, video) { 107 Videos.get(video_id, function (err, video) {
108 if (err) return next(err) 108 if (err) return next(err)
109 109
@@ -111,7 +111,7 @@ function removeVideo (req, res, next) {
111 Videos.removeOwned(req.params.id, function (err) { 111 Videos.removeOwned(req.params.id, function (err) {
112 if (err) return next(err) 112 if (err) return next(err)
113 113
114 var params = { 114 const params = {
115 name: video.name, 115 name: video.name,
116 magnetUri: video.magnetUri 116 magnetUri: video.magnetUri
117 } 117 }