aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r--server/lib/activitypub/videos.ts16
1 files changed, 15 insertions, 1 deletions
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts
index bce1666be..30de4714c 100644
--- a/server/lib/activitypub/videos.ts
+++ b/server/lib/activitypub/videos.ts
@@ -10,7 +10,8 @@ import {
10 ActivityTagObject, 10 ActivityTagObject,
11 ActivityUrlObject, 11 ActivityUrlObject,
12 ActivityVideoUrlObject, 12 ActivityVideoUrlObject,
13 VideoState 13 VideoState,
14 ActivityVideoFileMetadataObject
14} from '../../../shared/index' 15} from '../../../shared/index'
15import { VideoTorrentObject } from '../../../shared/models/activitypub/objects' 16import { VideoTorrentObject } from '../../../shared/models/activitypub/objects'
16import { VideoPrivacy } from '../../../shared/models/videos' 17import { VideoPrivacy } from '../../../shared/models/videos'
@@ -526,6 +527,10 @@ function isAPHashTagObject (url: any): url is ActivityHashTagObject {
526 return url && url.type === 'Hashtag' 527 return url && url.type === 'Hashtag'
527} 528}
528 529
530function isAPVideoFileMetadataObject (url: any): url is ActivityVideoFileMetadataObject {
531 return url && url.type === 'Link' && url.mediaType === 'application/json' && url.hasAttribute('rel') && url.rel.includes('metadata')
532}
533
529async function createVideo (videoObject: VideoTorrentObject, channel: MChannelAccountLight, waitThumbnail = false) { 534async function createVideo (videoObject: VideoTorrentObject, channel: MChannelAccountLight, waitThumbnail = false) {
530 logger.debug('Adding remote video %s.', videoObject.id) 535 logger.debug('Adding remote video %s.', videoObject.id)
531 536
@@ -694,6 +699,14 @@ function videoFileActivityUrlToDBAttributes (
694 throw new Error('Cannot parse magnet URI ' + magnet.href) 699 throw new Error('Cannot parse magnet URI ' + magnet.href)
695 } 700 }
696 701
702 // Fetch associated metadata url, if any
703 const metadata = urls.filter(isAPVideoFileMetadataObject)
704 .find(u =>
705 u.height === fileUrl.height &&
706 u.fps === fileUrl.fps &&
707 u.rel.includes(fileUrl.mediaType)
708 )
709
697 const mediaType = fileUrl.mediaType 710 const mediaType = fileUrl.mediaType
698 const attribute = { 711 const attribute = {
699 extname: MIMETYPES.VIDEO.MIMETYPE_EXT[mediaType], 712 extname: MIMETYPES.VIDEO.MIMETYPE_EXT[mediaType],
@@ -701,6 +714,7 @@ function videoFileActivityUrlToDBAttributes (
701 resolution: fileUrl.height, 714 resolution: fileUrl.height,
702 size: fileUrl.size, 715 size: fileUrl.size,
703 fps: fileUrl.fps || -1, 716 fps: fileUrl.fps || -1,
717 metadataUrl: metadata?.href,
704 718
705 // This is a video file owned by a video or by a streaming playlist 719 // This is a video file owned by a video or by a streaming playlist
706 videoId: (videoOrPlaylist as MStreamingPlaylist).playlistUrl ? null : videoOrPlaylist.id, 720 videoId: (videoOrPlaylist as MStreamingPlaylist).playlistUrl ? null : videoOrPlaylist.id,