From e27ff5da6ed7bc1f56f50f862b80fb0c7d8a6d98 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 18 Oct 2018 08:48:24 +0200 Subject: AP mimeType -> mediaType --- server/models/video/video-format-utils.ts | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'server/models/video/video-format-utils.ts') diff --git a/server/models/video/video-format-utils.ts b/server/models/video/video-format-utils.ts index 905e84449..e3f8d525b 100644 --- a/server/models/video/video-format-utils.ts +++ b/server/models/video/video-format-utils.ts @@ -208,6 +208,7 @@ function videoModelToActivityPubObject (video: VideoModel): VideoTorrentObject { url.push({ type: 'Link', mimeType: VIDEO_EXT_MIMETYPE[ file.extname ] as any, + mediaType: VIDEO_EXT_MIMETYPE[ file.extname ] as any, href: video.getVideoFileUrl(file, baseUrlHttp), height: file.resolution, size: file.size, @@ -217,6 +218,7 @@ function videoModelToActivityPubObject (video: VideoModel): VideoTorrentObject { url.push({ type: 'Link', mimeType: 'application/x-bittorrent' as 'application/x-bittorrent', + mediaType: 'application/x-bittorrent' as 'application/x-bittorrent', href: video.getTorrentUrl(file, baseUrlHttp), height: file.resolution }) @@ -224,6 +226,7 @@ function videoModelToActivityPubObject (video: VideoModel): VideoTorrentObject { url.push({ type: 'Link', mimeType: 'application/x-bittorrent;x-scheme-handler/magnet' as 'application/x-bittorrent;x-scheme-handler/magnet', + mediaType: 'application/x-bittorrent;x-scheme-handler/magnet' as 'application/x-bittorrent;x-scheme-handler/magnet', href: video.generateMagnetUri(file, baseUrlHttp, baseUrlWs), height: file.resolution }) @@ -233,6 +236,7 @@ function videoModelToActivityPubObject (video: VideoModel): VideoTorrentObject { url.push({ type: 'Link', mimeType: 'text/html', + mediaType: 'text/html', href: CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid }) -- cgit v1.2.3 From 14e2014acc1362cfbb770c051a7254b156cd8efb Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 11 Dec 2018 14:52:50 +0100 Subject: Support additional video extensions --- server/models/video/video-format-utils.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'server/models/video/video-format-utils.ts') diff --git a/server/models/video/video-format-utils.ts b/server/models/video/video-format-utils.ts index e3f8d525b..de0747f22 100644 --- a/server/models/video/video-format-utils.ts +++ b/server/models/video/video-format-utils.ts @@ -2,7 +2,7 @@ import { Video, VideoDetails, VideoFile } from '../../../shared/models/videos' import { VideoModel } from './video' import { VideoFileModel } from './video-file' import { ActivityUrlObject, VideoTorrentObject } from '../../../shared/models/activitypub/objects' -import { CONFIG, THUMBNAILS_SIZE, VIDEO_EXT_MIMETYPE } from '../../initializers' +import { CONFIG, MIMETYPES, THUMBNAILS_SIZE } from '../../initializers' import { VideoCaptionModel } from './video-caption' import { getVideoCommentsActivityPubUrl, @@ -207,8 +207,8 @@ function videoModelToActivityPubObject (video: VideoModel): VideoTorrentObject { for (const file of video.VideoFiles) { url.push({ type: 'Link', - mimeType: VIDEO_EXT_MIMETYPE[ file.extname ] as any, - mediaType: VIDEO_EXT_MIMETYPE[ file.extname ] as any, + mimeType: MIMETYPES.VIDEO.EXT_MIMETYPE[ file.extname ] as any, + mediaType: MIMETYPES.VIDEO.EXT_MIMETYPE[ file.extname ] as any, href: video.getVideoFileUrl(file, baseUrlHttp), height: file.resolution, size: file.size, -- cgit v1.2.3 From 092092969633bbcf6d4891a083ea497a7d5c3154 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 29 Jan 2019 08:37:25 +0100 Subject: Add hls support on server --- server/models/video/video-format-utils.ts | 61 ++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 2 deletions(-) (limited to 'server/models/video/video-format-utils.ts') diff --git a/server/models/video/video-format-utils.ts b/server/models/video/video-format-utils.ts index de0747f22..e49dbee30 100644 --- a/server/models/video/video-format-utils.ts +++ b/server/models/video/video-format-utils.ts @@ -1,7 +1,12 @@ import { Video, VideoDetails, VideoFile } from '../../../shared/models/videos' import { VideoModel } from './video' import { VideoFileModel } from './video-file' -import { ActivityUrlObject, VideoTorrentObject } from '../../../shared/models/activitypub/objects' +import { + ActivityPlaylistInfohashesObject, + ActivityPlaylistSegmentHashesObject, + ActivityUrlObject, + VideoTorrentObject +} from '../../../shared/models/activitypub/objects' import { CONFIG, MIMETYPES, THUMBNAILS_SIZE } from '../../initializers' import { VideoCaptionModel } from './video-caption' import { @@ -11,6 +16,8 @@ import { getVideoSharesActivityPubUrl } from '../../lib/activitypub' import { isArray } from '../../helpers/custom-validators/misc' +import { VideoStreamingPlaylist } from '../../../shared/models/videos/video-streaming-playlist.model' +import { VideoStreamingPlaylistModel } from './video-streaming-playlist' export type VideoFormattingJSONOptions = { completeDescription?: boolean @@ -120,7 +127,12 @@ function videoModelToFormattedDetailsJSON (video: VideoModel): VideoDetails { } }) + const { baseUrlHttp, baseUrlWs } = video.getBaseUrls() + const tags = video.Tags ? video.Tags.map(t => t.name) : [] + + const streamingPlaylists = streamingPlaylistsModelToFormattedJSON(video, video.VideoStreamingPlaylists) + const detailsJson = { support: video.support, descriptionPath: video.getDescriptionAPIPath(), @@ -133,7 +145,11 @@ function videoModelToFormattedDetailsJSON (video: VideoModel): VideoDetails { id: video.state, label: VideoModel.getStateLabel(video.state) }, - files: [] + + trackerUrls: video.getTrackerUrls(baseUrlHttp, baseUrlWs), + + files: [], + streamingPlaylists } // Format and sort video files @@ -142,6 +158,25 @@ function videoModelToFormattedDetailsJSON (video: VideoModel): VideoDetails { return Object.assign(formattedJson, detailsJson) } +function streamingPlaylistsModelToFormattedJSON (video: VideoModel, playlists: VideoStreamingPlaylistModel[]): VideoStreamingPlaylist[] { + if (isArray(playlists) === false) return [] + + return playlists + .map(playlist => { + const redundancies = isArray(playlist.RedundancyVideos) + ? playlist.RedundancyVideos.map(r => ({ baseUrl: r.fileUrl })) + : [] + + return { + id: playlist.id, + type: playlist.type, + playlistUrl: playlist.playlistUrl, + segmentsSha256Url: playlist.segmentsSha256Url, + redundancies + } as VideoStreamingPlaylist + }) +} + function videoFilesModelToFormattedJSON (video: VideoModel, videoFiles: VideoFileModel[]): VideoFile[] { const { baseUrlHttp, baseUrlWs } = video.getBaseUrls() @@ -232,6 +267,28 @@ function videoModelToActivityPubObject (video: VideoModel): VideoTorrentObject { }) } + for (const playlist of (video.VideoStreamingPlaylists || [])) { + let tag: (ActivityPlaylistSegmentHashesObject | ActivityPlaylistInfohashesObject)[] + + tag = playlist.p2pMediaLoaderInfohashes + .map(i => ({ type: 'Infohash' as 'Infohash', name: i })) + tag.push({ + type: 'Link', + name: 'sha256', + mimeType: 'application/json' as 'application/json', + mediaType: 'application/json' as 'application/json', + href: playlist.segmentsSha256Url + }) + + url.push({ + type: 'Link', + mimeType: 'application/x-mpegURL' as 'application/x-mpegURL', + mediaType: 'application/x-mpegURL' as 'application/x-mpegURL', + href: playlist.playlistUrl, + tag + }) + } + // Add video url too url.push({ type: 'Link', -- cgit v1.2.3