diff options
author | Chocobozzz <me@florianbigard.com> | 2018-07-12 19:02:00 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-07-16 11:50:08 +0200 |
commit | 40e87e9ecc54e3513fb586928330a7855eb192c6 (patch) | |
tree | af1111ecba85f9cd8286811ff332a67cf21be2f6 /server/initializers | |
parent | d4557fd3ecc8d4ed4fb0e5c868929bc36c959ed2 (diff) | |
download | PeerTube-40e87e9ecc54e3513fb586928330a7855eb192c6.tar.gz PeerTube-40e87e9ecc54e3513fb586928330a7855eb192c6.tar.zst PeerTube-40e87e9ecc54e3513fb586928330a7855eb192c6.zip |
Implement captions/subtitles
Diffstat (limited to 'server/initializers')
-rw-r--r-- | server/initializers/constants.ts | 23 | ||||
-rw-r--r-- | server/initializers/database.ts | 2 |
2 files changed, 23 insertions, 2 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index c5bc886d8..49809e64c 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -138,6 +138,7 @@ const CONFIG = { | |||
138 | VIDEOS_DIR: buildPath(config.get<string>('storage.videos')), | 138 | VIDEOS_DIR: buildPath(config.get<string>('storage.videos')), |
139 | THUMBNAILS_DIR: buildPath(config.get<string>('storage.thumbnails')), | 139 | THUMBNAILS_DIR: buildPath(config.get<string>('storage.thumbnails')), |
140 | PREVIEWS_DIR: buildPath(config.get<string>('storage.previews')), | 140 | PREVIEWS_DIR: buildPath(config.get<string>('storage.previews')), |
141 | CAPTIONS_DIR: buildPath(config.get<string>('storage.captions')), | ||
141 | TORRENTS_DIR: buildPath(config.get<string>('storage.torrents')), | 142 | TORRENTS_DIR: buildPath(config.get<string>('storage.torrents')), |
142 | CACHE_DIR: buildPath(config.get<string>('storage.cache')) | 143 | CACHE_DIR: buildPath(config.get<string>('storage.cache')) |
143 | }, | 144 | }, |
@@ -183,6 +184,9 @@ const CONFIG = { | |||
183 | CACHE: { | 184 | CACHE: { |
184 | PREVIEWS: { | 185 | PREVIEWS: { |
185 | get SIZE () { return config.get<number>('cache.previews.size') } | 186 | get SIZE () { return config.get<number>('cache.previews.size') } |
187 | }, | ||
188 | VIDEO_CAPTIONS: { | ||
189 | get SIZE () { return config.get<number>('cache.captions.size') } | ||
186 | } | 190 | } |
187 | }, | 191 | }, |
188 | INSTANCE: { | 192 | INSTANCE: { |
@@ -225,6 +229,14 @@ const CONSTRAINTS_FIELDS = { | |||
225 | SUPPORT: { min: 3, max: 500 }, // Length | 229 | SUPPORT: { min: 3, max: 500 }, // Length |
226 | URL: { min: 3, max: 2000 } // Length | 230 | URL: { min: 3, max: 2000 } // Length |
227 | }, | 231 | }, |
232 | VIDEO_CAPTIONS: { | ||
233 | CAPTION_FILE: { | ||
234 | EXTNAME: [ '.vtt' ], | ||
235 | FILE_SIZE: { | ||
236 | max: 2 * 1024 * 1024 // 2MB | ||
237 | } | ||
238 | } | ||
239 | }, | ||
228 | VIDEOS: { | 240 | VIDEOS: { |
229 | NAME: { min: 3, max: 120 }, // Length | 241 | NAME: { min: 3, max: 120 }, // Length |
230 | LANGUAGE: { min: 1, max: 10 }, // Length | 242 | LANGUAGE: { min: 1, max: 10 }, // Length |
@@ -351,6 +363,10 @@ const IMAGE_MIMETYPE_EXT = { | |||
351 | 'image/jpeg': '.jpg' | 363 | 'image/jpeg': '.jpg' |
352 | } | 364 | } |
353 | 365 | ||
366 | const VIDEO_CAPTIONS_MIMETYPE_EXT = { | ||
367 | 'text/vtt': '.vtt' | ||
368 | } | ||
369 | |||
354 | // --------------------------------------------------------------------------- | 370 | // --------------------------------------------------------------------------- |
355 | 371 | ||
356 | const SERVER_ACTOR_NAME = 'peertube' | 372 | const SERVER_ACTOR_NAME = 'peertube' |
@@ -403,7 +419,8 @@ const STATIC_PATHS = { | |||
403 | THUMBNAILS: '/static/thumbnails/', | 419 | THUMBNAILS: '/static/thumbnails/', |
404 | TORRENTS: '/static/torrents/', | 420 | TORRENTS: '/static/torrents/', |
405 | WEBSEED: '/static/webseed/', | 421 | WEBSEED: '/static/webseed/', |
406 | AVATARS: '/static/avatars/' | 422 | AVATARS: '/static/avatars/', |
423 | VIDEO_CAPTIONS: '/static/video-captions/' | ||
407 | } | 424 | } |
408 | const STATIC_DOWNLOAD_PATHS = { | 425 | const STATIC_DOWNLOAD_PATHS = { |
409 | TORRENTS: '/download/torrents/', | 426 | TORRENTS: '/download/torrents/', |
@@ -435,7 +452,8 @@ const EMBED_SIZE = { | |||
435 | // Sub folders of cache directory | 452 | // Sub folders of cache directory |
436 | const CACHE = { | 453 | const CACHE = { |
437 | DIRECTORIES: { | 454 | DIRECTORIES: { |
438 | PREVIEWS: join(CONFIG.STORAGE.CACHE_DIR, 'previews') | 455 | PREVIEWS: join(CONFIG.STORAGE.CACHE_DIR, 'previews'), |
456 | VIDEO_CAPTIONS: join(CONFIG.STORAGE.CACHE_DIR, 'video-captions') | ||
439 | } | 457 | } |
440 | } | 458 | } |
441 | 459 | ||
@@ -490,6 +508,7 @@ updateWebserverConfig() | |||
490 | 508 | ||
491 | export { | 509 | export { |
492 | API_VERSION, | 510 | API_VERSION, |
511 | VIDEO_CAPTIONS_MIMETYPE_EXT, | ||
493 | AVATARS_SIZE, | 512 | AVATARS_SIZE, |
494 | ACCEPT_HEADERS, | 513 | ACCEPT_HEADERS, |
495 | BCRYPT_SALT_SIZE, | 514 | BCRYPT_SALT_SIZE, |
diff --git a/server/initializers/database.ts b/server/initializers/database.ts index 4d90c90fc..434d7ef19 100644 --- a/server/initializers/database.ts +++ b/server/initializers/database.ts | |||
@@ -23,6 +23,7 @@ import { VideoShareModel } from '../models/video/video-share' | |||
23 | import { VideoTagModel } from '../models/video/video-tag' | 23 | import { VideoTagModel } from '../models/video/video-tag' |
24 | import { CONFIG } from './constants' | 24 | import { CONFIG } from './constants' |
25 | import { ScheduleVideoUpdateModel } from '../models/video/schedule-video-update' | 25 | import { ScheduleVideoUpdateModel } from '../models/video/schedule-video-update' |
26 | import { VideoCaptionModel } from '../models/video/video-caption' | ||
26 | 27 | ||
27 | require('pg').defaults.parseInt8 = true // Avoid BIGINT to be converted to string | 28 | require('pg').defaults.parseInt8 = true // Avoid BIGINT to be converted to string |
28 | 29 | ||
@@ -71,6 +72,7 @@ async function initDatabaseModels (silent: boolean) { | |||
71 | VideoChannelModel, | 72 | VideoChannelModel, |
72 | VideoShareModel, | 73 | VideoShareModel, |
73 | VideoFileModel, | 74 | VideoFileModel, |
75 | VideoCaptionModel, | ||
74 | VideoBlacklistModel, | 76 | VideoBlacklistModel, |
75 | VideoTagModel, | 77 | VideoTagModel, |
76 | VideoModel, | 78 | VideoModel, |