aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
Diffstat (limited to 'server/models')
-rw-r--r--server/models/video/video-interface.ts6
-rw-r--r--server/models/video/video.ts29
2 files changed, 31 insertions, 4 deletions
diff --git a/server/models/video/video-interface.ts b/server/models/video/video-interface.ts
index 6a3db4f3e..1402df26a 100644
--- a/server/models/video/video-interface.ts
+++ b/server/models/video/video-interface.ts
@@ -32,6 +32,9 @@ export namespace VideoMethods {
32 export type OptimizeOriginalVideofile = (this: VideoInstance) => Promise<void> 32 export type OptimizeOriginalVideofile = (this: VideoInstance) => Promise<void>
33 export type TranscodeOriginalVideofile = (this: VideoInstance, resolution: number) => Promise<void> 33 export type TranscodeOriginalVideofile = (this: VideoInstance, resolution: number) => Promise<void>
34 export type GetOriginalFileHeight = (this: VideoInstance) => Promise<number> 34 export type GetOriginalFileHeight = (this: VideoInstance) => Promise<number>
35 export type GetEmbedPath = (this: VideoInstance) => string
36 export type GetThumbnailPath = (this: VideoInstance) => string
37 export type GetPreviewPath = (this: VideoInstance) => string
35 38
36 // Return thumbnail name 39 // Return thumbnail name
37 export type GenerateThumbnailFromData = (video: VideoInstance, thumbnailData: string) => Promise<string> 40 export type GenerateThumbnailFromData = (video: VideoInstance, thumbnailData: string) => Promise<string>
@@ -107,7 +110,9 @@ export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.In
107 getOriginalFile: VideoMethods.GetOriginalFile 110 getOriginalFile: VideoMethods.GetOriginalFile
108 generateMagnetUri: VideoMethods.GenerateMagnetUri 111 generateMagnetUri: VideoMethods.GenerateMagnetUri
109 getPreviewName: VideoMethods.GetPreviewName 112 getPreviewName: VideoMethods.GetPreviewName
113 getPreviewPath: VideoMethods.GetPreviewPath
110 getThumbnailName: VideoMethods.GetThumbnailName 114 getThumbnailName: VideoMethods.GetThumbnailName
115 getThumbnailPath: VideoMethods.GetThumbnailPath
111 getTorrentFileName: VideoMethods.GetTorrentFileName 116 getTorrentFileName: VideoMethods.GetTorrentFileName
112 getVideoFilename: VideoMethods.GetVideoFilename 117 getVideoFilename: VideoMethods.GetVideoFilename
113 getVideoFilePath: VideoMethods.GetVideoFilePath 118 getVideoFilePath: VideoMethods.GetVideoFilePath
@@ -122,6 +127,7 @@ export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.In
122 optimizeOriginalVideofile: VideoMethods.OptimizeOriginalVideofile 127 optimizeOriginalVideofile: VideoMethods.OptimizeOriginalVideofile
123 transcodeOriginalVideofile: VideoMethods.TranscodeOriginalVideofile 128 transcodeOriginalVideofile: VideoMethods.TranscodeOriginalVideofile
124 getOriginalFileHeight: VideoMethods.GetOriginalFileHeight 129 getOriginalFileHeight: VideoMethods.GetOriginalFileHeight
130 getEmbedPath: VideoMethods.GetEmbedPath
125 131
126 setTags: Sequelize.HasManySetAssociationsMixin<TagAttributes, string> 132 setTags: Sequelize.HasManySetAssociationsMixin<TagAttributes, string>
127 addVideoFile: Sequelize.HasManyAddAssociationMixin<VideoFileAttributes, string> 133 addVideoFile: Sequelize.HasManyAddAssociationMixin<VideoFileAttributes, string>
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: []