aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api')
-rw-r--r--server/controllers/api/config.ts6
-rw-r--r--server/controllers/api/videos/index.ts12
2 files changed, 13 insertions, 5 deletions
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts
index 113c1e9db..70e8aa970 100644
--- a/server/controllers/api/config.ts
+++ b/server/controllers/api/config.ts
@@ -95,6 +95,9 @@ async function getConfig (req: express.Request, res: express.Response) {
95 hls: { 95 hls: {
96 enabled: CONFIG.TRANSCODING.HLS.ENABLED 96 enabled: CONFIG.TRANSCODING.HLS.ENABLED
97 }, 97 },
98 webtorrent: {
99 enabled: CONFIG.TRANSCODING.WEBTORRENT.ENABLED
100 },
98 enabledResolutions: getEnabledResolutions() 101 enabledResolutions: getEnabledResolutions()
99 }, 102 },
100 import: { 103 import: {
@@ -304,6 +307,9 @@ function customConfig (): CustomConfig {
304 '1080p': CONFIG.TRANSCODING.RESOLUTIONS[ '1080p' ], 307 '1080p': CONFIG.TRANSCODING.RESOLUTIONS[ '1080p' ],
305 '2160p': CONFIG.TRANSCODING.RESOLUTIONS[ '2160p' ] 308 '2160p': CONFIG.TRANSCODING.RESOLUTIONS[ '2160p' ]
306 }, 309 },
310 webtorrent: {
311 enabled: CONFIG.TRANSCODING.WEBTORRENT.ENABLED
312 },
307 hls: { 313 hls: {
308 enabled: CONFIG.TRANSCODING.HLS.ENABLED 314 enabled: CONFIG.TRANSCODING.HLS.ENABLED
309 } 315 }
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 0d1fbc8f4..78948ff24 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -64,6 +64,8 @@ import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type'
64import { VideoTranscodingPayload } from '../../../lib/job-queue/handlers/video-transcoding' 64import { VideoTranscodingPayload } from '../../../lib/job-queue/handlers/video-transcoding'
65import { Hooks } from '../../../lib/plugins/hooks' 65import { Hooks } from '../../../lib/plugins/hooks'
66import { MVideoDetails, MVideoFullLight } from '@server/typings/models' 66import { MVideoDetails, MVideoFullLight } from '@server/typings/models'
67import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
68import { getVideoFilename, getVideoFilePath } from '@server/lib/video-paths'
67 69
68const auditLogger = auditLoggerFactory('videos') 70const auditLogger = auditLoggerFactory('videos')
69const videosRouter = express.Router() 71const videosRouter = express.Router()
@@ -203,7 +205,8 @@ async function addVideo (req: express.Request, res: express.Response) {
203 205
204 const videoFile = new VideoFileModel({ 206 const videoFile = new VideoFileModel({
205 extname: extname(videoPhysicalFile.filename), 207 extname: extname(videoPhysicalFile.filename),
206 size: videoPhysicalFile.size 208 size: videoPhysicalFile.size,
209 videoStreamingPlaylistId: null
207 }) 210 })
208 211
209 if (videoFile.isAudio()) { 212 if (videoFile.isAudio()) {
@@ -214,11 +217,10 @@ async function addVideo (req: express.Request, res: express.Response) {
214 } 217 }
215 218
216 // Move physical file 219 // Move physical file
217 const videoDir = CONFIG.STORAGE.VIDEOS_DIR 220 const destination = getVideoFilePath(video, videoFile)
218 const destination = join(videoDir, video.getVideoFilename(videoFile))
219 await move(videoPhysicalFile.path, destination) 221 await move(videoPhysicalFile.path, destination)
220 // This is important in case if there is another attempt in the retry process 222 // This is important in case if there is another attempt in the retry process
221 videoPhysicalFile.filename = video.getVideoFilename(videoFile) 223 videoPhysicalFile.filename = getVideoFilePath(video, videoFile)
222 videoPhysicalFile.path = destination 224 videoPhysicalFile.path = destination
223 225
224 // Process thumbnail or create it from the video 226 // Process thumbnail or create it from the video
@@ -234,7 +236,7 @@ async function addVideo (req: express.Request, res: express.Response) {
234 : await generateVideoMiniature(video, videoFile, ThumbnailType.PREVIEW) 236 : await generateVideoMiniature(video, videoFile, ThumbnailType.PREVIEW)
235 237
236 // Create the torrent file 238 // Create the torrent file
237 await video.createTorrentAndSetInfoHash(videoFile) 239 await createTorrentAndSetInfoHash(video, videoFile)
238 240
239 const { videoCreated } = await sequelizeTypescript.transaction(async t => { 241 const { videoCreated } = await sequelizeTypescript.transaction(async t => {
240 const sequelizeOptions = { transaction: t } 242 const sequelizeOptions = { transaction: t }