diff options
author | Chocobozzz <me@florianbigard.com> | 2018-07-16 14:22:16 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-07-16 14:31:40 +0200 |
commit | f4001cf408a99049d01a356bfb20a62342de06ea (patch) | |
tree | 421776dfe64335dca2725ac3ac5f3b3e6b7564c6 /server/initializers | |
parent | 16f7022b06fb76c0b00c23c970bc8df605b0ec63 (diff) | |
download | PeerTube-f4001cf408a99049d01a356bfb20a62342de06ea.tar.gz PeerTube-f4001cf408a99049d01a356bfb20a62342de06ea.tar.zst PeerTube-f4001cf408a99049d01a356bfb20a62342de06ea.zip |
Handle .srt subtitles
Diffstat (limited to 'server/initializers')
-rw-r--r-- | server/initializers/constants.ts | 17 | ||||
-rw-r--r-- | server/initializers/installer.ts | 6 |
2 files changed, 16 insertions, 7 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 49809e64c..3837f7062 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -231,7 +231,7 @@ const CONSTRAINTS_FIELDS = { | |||
231 | }, | 231 | }, |
232 | VIDEO_CAPTIONS: { | 232 | VIDEO_CAPTIONS: { |
233 | CAPTION_FILE: { | 233 | CAPTION_FILE: { |
234 | EXTNAME: [ '.vtt' ], | 234 | EXTNAME: [ '.vtt', '.srt' ], |
235 | FILE_SIZE: { | 235 | FILE_SIZE: { |
236 | max: 2 * 1024 * 1024 // 2MB | 236 | max: 2 * 1024 * 1024 // 2MB |
237 | } | 237 | } |
@@ -364,7 +364,8 @@ const IMAGE_MIMETYPE_EXT = { | |||
364 | } | 364 | } |
365 | 365 | ||
366 | const VIDEO_CAPTIONS_MIMETYPE_EXT = { | 366 | const VIDEO_CAPTIONS_MIMETYPE_EXT = { |
367 | 'text/vtt': '.vtt' | 367 | 'text/vtt': '.vtt', |
368 | 'application/x-subrip': '.srt' | ||
368 | } | 369 | } |
369 | 370 | ||
370 | // --------------------------------------------------------------------------- | 371 | // --------------------------------------------------------------------------- |
@@ -451,9 +452,13 @@ const EMBED_SIZE = { | |||
451 | 452 | ||
452 | // Sub folders of cache directory | 453 | // Sub folders of cache directory |
453 | const CACHE = { | 454 | const CACHE = { |
454 | DIRECTORIES: { | 455 | PREVIEWS: { |
455 | PREVIEWS: join(CONFIG.STORAGE.CACHE_DIR, 'previews'), | 456 | DIRECTORY: join(CONFIG.STORAGE.CACHE_DIR, 'previews'), |
456 | VIDEO_CAPTIONS: join(CONFIG.STORAGE.CACHE_DIR, 'video-captions') | 457 | MAX_AGE: 1000 * 3600 * 3 // 3 hours |
458 | }, | ||
459 | VIDEO_CAPTIONS: { | ||
460 | DIRECTORY: join(CONFIG.STORAGE.CACHE_DIR, 'video-captions'), | ||
461 | MAX_AGE: 1000 * 3600 * 3 // 3 hours | ||
457 | } | 462 | } |
458 | } | 463 | } |
459 | 464 | ||
@@ -500,6 +505,8 @@ if (isTestInstance() === true) { | |||
500 | VIDEO_VIEW_LIFETIME = 1000 // 1 second | 505 | VIDEO_VIEW_LIFETIME = 1000 // 1 second |
501 | 506 | ||
502 | JOB_ATTEMPTS['email'] = 1 | 507 | JOB_ATTEMPTS['email'] = 1 |
508 | |||
509 | CACHE.VIDEO_CAPTIONS.MAX_AGE = 3000 | ||
503 | } | 510 | } |
504 | 511 | ||
505 | updateWebserverConfig() | 512 | updateWebserverConfig() |
diff --git a/server/initializers/installer.ts b/server/initializers/installer.ts index b0084b368..1f513a9c3 100644 --- a/server/initializers/installer.ts +++ b/server/initializers/installer.ts | |||
@@ -33,7 +33,8 @@ export { | |||
33 | // --------------------------------------------------------------------------- | 33 | // --------------------------------------------------------------------------- |
34 | 34 | ||
35 | function removeCacheDirectories () { | 35 | function removeCacheDirectories () { |
36 | const cacheDirectories = CACHE.DIRECTORIES | 36 | const cacheDirectories = Object.keys(CACHE) |
37 | .map(k => CACHE[k].DIRECTORY) | ||
37 | 38 | ||
38 | const tasks: Promise<any>[] = [] | 39 | const tasks: Promise<any>[] = [] |
39 | 40 | ||
@@ -48,7 +49,8 @@ function removeCacheDirectories () { | |||
48 | 49 | ||
49 | function createDirectoriesIfNotExist () { | 50 | function createDirectoriesIfNotExist () { |
50 | const storage = CONFIG.STORAGE | 51 | const storage = CONFIG.STORAGE |
51 | const cacheDirectories = CACHE.DIRECTORIES | 52 | const cacheDirectories = Object.keys(CACHE) |
53 | .map(k => CACHE[k].DIRECTORY) | ||
52 | 54 | ||
53 | const tasks = [] | 55 | const tasks = [] |
54 | for (const key of Object.keys(storage)) { | 56 | for (const key of Object.keys(storage)) { |