diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-10-16 10:05:49 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-10-16 10:07:26 +0200 |
commit | d8755eed1e452d2efbfc983af0e9d228d152bf6b (patch) | |
tree | db94181e7c993f67919f4ea2bb12f08401c437c2 /server/models/video/video.ts | |
parent | 334ddfa47120ae53bc2643792ec5e1065a4d1141 (diff) | |
download | PeerTube-d8755eed1e452d2efbfc983af0e9d228d152bf6b.tar.gz PeerTube-d8755eed1e452d2efbfc983af0e9d228d152bf6b.tar.zst PeerTube-d8755eed1e452d2efbfc983af0e9d228d152bf6b.zip |
Add oembed endpoint
Diffstat (limited to 'server/models/video/video.ts')
-rw-r--r-- | server/models/video/video.ts | 29 |
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 | |||
54 | let generateMagnetUri: VideoMethods.GenerateMagnetUri | 54 | let generateMagnetUri: VideoMethods.GenerateMagnetUri |
55 | let getVideoFilename: VideoMethods.GetVideoFilename | 55 | let getVideoFilename: VideoMethods.GetVideoFilename |
56 | let getThumbnailName: VideoMethods.GetThumbnailName | 56 | let getThumbnailName: VideoMethods.GetThumbnailName |
57 | let getThumbnailPath: VideoMethods.GetThumbnailPath | ||
57 | let getPreviewName: VideoMethods.GetPreviewName | 58 | let getPreviewName: VideoMethods.GetPreviewName |
59 | let getPreviewPath: VideoMethods.GetPreviewPath | ||
58 | let getTorrentFileName: VideoMethods.GetTorrentFileName | 60 | let getTorrentFileName: VideoMethods.GetTorrentFileName |
59 | let isOwned: VideoMethods.IsOwned | 61 | let isOwned: VideoMethods.IsOwned |
60 | let toFormattedJSON: VideoMethods.ToFormattedJSON | 62 | let toFormattedJSON: VideoMethods.ToFormattedJSON |
@@ -67,6 +69,7 @@ let createThumbnail: VideoMethods.CreateThumbnail | |||
67 | let getVideoFilePath: VideoMethods.GetVideoFilePath | 69 | let getVideoFilePath: VideoMethods.GetVideoFilePath |
68 | let createTorrentAndSetInfoHash: VideoMethods.CreateTorrentAndSetInfoHash | 70 | let createTorrentAndSetInfoHash: VideoMethods.CreateTorrentAndSetInfoHash |
69 | let getOriginalFileHeight: VideoMethods.GetOriginalFileHeight | 71 | let getOriginalFileHeight: VideoMethods.GetOriginalFileHeight |
72 | let getEmbedPath: VideoMethods.GetEmbedPath | ||
70 | 73 | ||
71 | let generateThumbnailFromData: VideoMethods.GenerateThumbnailFromData | 74 | let generateThumbnailFromData: VideoMethods.GenerateThumbnailFromData |
72 | let list: VideoMethods.List | 75 | let 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 | ||
377 | createThumbnail = function (this: VideoInstance, videoFile: VideoFileInstance) { | 383 | createThumbnail = 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 | ||
449 | getEmbedPath = function (this: VideoInstance) { | ||
450 | return '/videos/embed/' + this.uuid | ||
451 | } | ||
452 | |||
453 | getThumbnailPath = function (this: VideoInstance) { | ||
454 | return join(STATIC_PATHS.THUMBNAILS, this.getThumbnailName()) | ||
455 | } | ||
456 | |||
457 | getPreviewPath = function (this: VideoInstance) { | ||
458 | return join(STATIC_PATHS.PREVIEWS, this.getPreviewName()) | ||
459 | } | ||
460 | |||
441 | toFormattedJSON = function (this: VideoInstance) { | 461 | toFormattedJSON = 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: [] |