aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video/video.ts')
-rw-r--r--server/models/video/video.ts29
1 files changed, 25 insertions, 4 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 2ba6cf25f..0d0048b4a 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -54,7 +54,9 @@ let getOriginalFile: VideoMethods.GetOriginalFile
54let generateMagnetUri: VideoMethods.GenerateMagnetUri 54let generateMagnetUri: VideoMethods.GenerateMagnetUri
55let getVideoFilename: VideoMethods.GetVideoFilename 55let getVideoFilename: VideoMethods.GetVideoFilename
56let getThumbnailName: VideoMethods.GetThumbnailName 56let getThumbnailName: VideoMethods.GetThumbnailName
57let getThumbnailPath: VideoMethods.GetThumbnailPath
57let getPreviewName: VideoMethods.GetPreviewName 58let getPreviewName: VideoMethods.GetPreviewName
59let getPreviewPath: VideoMethods.GetPreviewPath
58let getTorrentFileName: VideoMethods.GetTorrentFileName 60let getTorrentFileName: VideoMethods.GetTorrentFileName
59let isOwned: VideoMethods.IsOwned 61let isOwned: VideoMethods.IsOwned
60let toFormattedJSON: VideoMethods.ToFormattedJSON 62let toFormattedJSON: VideoMethods.ToFormattedJSON
@@ -67,6 +69,7 @@ let createThumbnail: VideoMethods.CreateThumbnail
67let getVideoFilePath: VideoMethods.GetVideoFilePath 69let getVideoFilePath: VideoMethods.GetVideoFilePath
68let createTorrentAndSetInfoHash: VideoMethods.CreateTorrentAndSetInfoHash 70let createTorrentAndSetInfoHash: VideoMethods.CreateTorrentAndSetInfoHash
69let getOriginalFileHeight: VideoMethods.GetOriginalFileHeight 71let getOriginalFileHeight: VideoMethods.GetOriginalFileHeight
72let getEmbedPath: VideoMethods.GetEmbedPath
70 73
71let generateThumbnailFromData: VideoMethods.GenerateThumbnailFromData 74let generateThumbnailFromData: VideoMethods.GenerateThumbnailFromData
72let list: VideoMethods.List 75let list: VideoMethods.List
@@ -252,7 +255,9 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da
252 createTorrentAndSetInfoHash, 255 createTorrentAndSetInfoHash,
253 generateMagnetUri, 256 generateMagnetUri,
254 getPreviewName, 257 getPreviewName,
258 getPreviewPath,
255 getThumbnailName, 259 getThumbnailName,
260 getThumbnailPath,
256 getTorrentFileName, 261 getTorrentFileName,
257 getVideoFilename, 262 getVideoFilename,
258 getVideoFilePath, 263 getVideoFilePath,
@@ -267,7 +272,8 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da
267 toUpdateRemoteJSON, 272 toUpdateRemoteJSON,
268 optimizeOriginalVideofile, 273 optimizeOriginalVideofile,
269 transcodeOriginalVideofile, 274 transcodeOriginalVideofile,
270 getOriginalFileHeight 275 getOriginalFileHeight,
276 getEmbedPath
271 ] 277 ]
272 addMethodsToModel(Video, classMethods, instanceMethods) 278 addMethodsToModel(Video, classMethods, instanceMethods)
273 279
@@ -375,11 +381,13 @@ createPreview = function (this: VideoInstance, videoFile: VideoFileInstance) {
375} 381}
376 382
377createThumbnail = function (this: VideoInstance, videoFile: VideoFileInstance) { 383createThumbnail = function (this: VideoInstance, videoFile: VideoFileInstance) {
384 const imageSize = THUMBNAILS_SIZE.width + 'x' + THUMBNAILS_SIZE.height
385
378 return generateImageFromVideoFile( 386 return generateImageFromVideoFile(
379 this.getVideoFilePath(videoFile), 387 this.getVideoFilePath(videoFile),
380 CONFIG.STORAGE.THUMBNAILS_DIR, 388 CONFIG.STORAGE.THUMBNAILS_DIR,
381 this.getThumbnailName(), 389 this.getThumbnailName(),
382 THUMBNAILS_SIZE 390 imageSize
383 ) 391 )
384} 392}
385 393
@@ -438,6 +446,18 @@ generateMagnetUri = function (this: VideoInstance, videoFile: VideoFileInstance)
438 return magnetUtil.encode(magnetHash) 446 return magnetUtil.encode(magnetHash)
439} 447}
440 448
449getEmbedPath = function (this: VideoInstance) {
450 return '/videos/embed/' + this.uuid
451}
452
453getThumbnailPath = function (this: VideoInstance) {
454 return join(STATIC_PATHS.THUMBNAILS, this.getThumbnailName())
455}
456
457getPreviewPath = function (this: VideoInstance) {
458 return join(STATIC_PATHS.PREVIEWS, this.getPreviewName())
459}
460
441toFormattedJSON = function (this: VideoInstance) { 461toFormattedJSON = function (this: VideoInstance) {
442 let podHost 462 let podHost
443 463
@@ -480,8 +500,9 @@ toFormattedJSON = function (this: VideoInstance) {
480 likes: this.likes, 500 likes: this.likes,
481 dislikes: this.dislikes, 501 dislikes: this.dislikes,
482 tags: map<TagInstance, string>(this.Tags, 'name'), 502 tags: map<TagInstance, string>(this.Tags, 'name'),
483 thumbnailPath: join(STATIC_PATHS.THUMBNAILS, this.getThumbnailName()), 503 thumbnailPath: this.getThumbnailPath(),
484 previewPath: join(STATIC_PATHS.PREVIEWS, this.getPreviewName()), 504 previewPath: this.getPreviewPath(),
505 embedPath: this.getEmbedPath(),
485 createdAt: this.createdAt, 506 createdAt: this.createdAt,
486 updatedAt: this.updatedAt, 507 updatedAt: this.updatedAt,
487 files: [] 508 files: []