diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-03-10 14:39:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-10 14:39:40 +0100 |
commit | 8319d6ae72d4da6de51bd3d4b5c68040fc8dc3b4 (patch) | |
tree | 1f87041b2cd76222844960602cdc9f52fe206c7b /server/lib/activitypub | |
parent | edb868655e52f934a71141175cf9dc6cb4753e11 (diff) | |
download | PeerTube-8319d6ae72d4da6de51bd3d4b5c68040fc8dc3b4.tar.gz PeerTube-8319d6ae72d4da6de51bd3d4b5c68040fc8dc3b4.tar.zst PeerTube-8319d6ae72d4da6de51bd3d4b5c68040fc8dc3b4.zip |
Add video file metadata to download modal, via ffprobe (#2411)
* Add video file metadata via ffprobe
* Federate video file metadata
* Add tests for file metadata generation
* Complete tests for videoFile metadata federation
* Lint migration and video-file for metadata
* Objectify metadata from getter in ffmpeg-utils
* Add metadataUrl to all videoFiles
* Simplify metadata API middleware
* Load playlist in videoFile when requesting metadata
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r-- | server/lib/activitypub/videos.ts | 16 |
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' |
15 | import { VideoTorrentObject } from '../../../shared/models/activitypub/objects' | 16 | import { VideoTorrentObject } from '../../../shared/models/activitypub/objects' |
16 | import { VideoPrivacy } from '../../../shared/models/videos' | 17 | import { 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 | ||
530 | function 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 | |||
529 | async function createVideo (videoObject: VideoTorrentObject, channel: MChannelAccountLight, waitThumbnail = false) { | 534 | async 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, |