} from '../../lib/activitypub/url'
import {
MStreamingPlaylistRedundanciesOpt,
- MStreamingPlaylistVideo,
MVideo,
MVideoAP,
MVideoFile,
MVideoFormattable,
- MVideoFormattableDetails,
- MVideoWithHost
+ MVideoFormattableDetails
} from '../../types/models'
import { MVideoFileRedundanciesOpt } from '../../types/models/video/video-file'
import { VideoModel } from './video'
}
})
- const { baseUrlHttp, baseUrlWs } = video.getBaseUrls()
-
const tags = video.Tags ? video.Tags.map(t => t.name) : []
const streamingPlaylists = streamingPlaylistsModelToFormattedJSON(video, video.VideoStreamingPlaylists)
label: VideoModel.getStateLabel(video.state)
},
- trackerUrls: video.getTrackerUrls(baseUrlHttp, baseUrlWs),
+ trackerUrls: video.getTrackerUrls(),
files: [],
streamingPlaylists
}
// Format and sort video files
- detailsJson.files = videoFilesModelToFormattedJSON(video, video, baseUrlHttp, baseUrlWs, video.VideoFiles)
+ detailsJson.files = videoFilesModelToFormattedJSON(video, video.VideoFiles)
return Object.assign(formattedJson, detailsJson)
}
): VideoStreamingPlaylist[] {
if (isArray(playlists) === false) return []
- const { baseUrlHttp, baseUrlWs } = video.getBaseUrls()
-
return playlists
.map(playlist => {
- const playlistWithVideo = Object.assign(playlist, { Video: video })
-
const redundancies = isArray(playlist.RedundancyVideos)
? playlist.RedundancyVideos.map(r => ({ baseUrl: r.fileUrl }))
: []
- const files = videoFilesModelToFormattedJSON(playlistWithVideo, video, baseUrlHttp, baseUrlWs, playlist.VideoFiles)
+ const files = videoFilesModelToFormattedJSON(video, playlist.VideoFiles)
return {
id: playlist.id,
return -1
}
-// FIXME: refactor/merge model and video arguments
function videoFilesModelToFormattedJSON (
- model: MVideo | MStreamingPlaylistVideo,
video: MVideoFormattableDetails,
- baseUrlHttp: string,
- baseUrlWs: string,
- videoFiles: MVideoFileRedundanciesOpt[]
+ videoFiles: MVideoFileRedundanciesOpt[],
+ includeMagnet = true
): VideoFile[] {
+ const trackerUrls = includeMagnet
+ ? video.getTrackerUrls()
+ : []
+
return [ ...videoFiles ]
.filter(f => !f.isLive())
.sort(sortByResolutionDesc)
label: videoFile.resolution + 'p'
},
- // FIXME: deprecated in 3.2
- magnetUri: generateMagnetUri(model, video, videoFile, baseUrlHttp, baseUrlWs),
+ magnetUri: includeMagnet && videoFile.torrentFilename
+ ? generateMagnetUri(video, videoFile, trackerUrls)
+ : undefined,
size: videoFile.size,
fps: videoFile.fps,
})
}
-// FIXME: refactor/merge model and video arguments
function addVideoFilesInAPAcc (
acc: ActivityUrlObject[] | ActivityTagObject[],
- model: MVideoAP | MStreamingPlaylistVideo,
- video: MVideoWithHost,
- baseUrlHttp: string,
- baseUrlWs: string,
+ video: MVideo,
files: MVideoFile[]
) {
+ const trackerUrls = video.getTrackerUrls()
+
const sortedFiles = [ ...files ]
.filter(f => !f.isLive())
.sort(sortByResolutionDesc)
acc.push({
type: 'Link',
mediaType: 'application/x-bittorrent;x-scheme-handler/magnet' as 'application/x-bittorrent;x-scheme-handler/magnet',
- href: generateMagnetUri(model, video, file, baseUrlHttp, baseUrlWs),
+ href: generateMagnetUri(video, file, trackerUrls),
height: file.resolution
})
}
}
function videoModelToActivityPubObject (video: MVideoAP): VideoObject {
- const { baseUrlHttp, baseUrlWs } = video.getBaseUrls()
if (!video.Tags) video.Tags = []
const tag = video.Tags.map(t => ({
}
]
- addVideoFilesInAPAcc(url, video, video, baseUrlHttp, baseUrlWs, video.VideoFiles || [])
+ addVideoFilesInAPAcc(url, video, video.VideoFiles || [])
for (const playlist of (video.VideoStreamingPlaylists || [])) {
const tag = playlist.p2pMediaLoaderInfohashes
href: playlist.segmentsSha256Url
})
- const playlistWithVideo = Object.assign(playlist, { Video: video })
- addVideoFilesInAPAcc(tag, playlistWithVideo, video, baseUrlHttp, baseUrlWs, playlist.VideoFiles || [])
+ addVideoFilesInAPAcc(tag, video, playlist.VideoFiles || [])
url.push({
type: 'Link',
})
}
+ for (const trackerUrl of video.getTrackerUrls()) {
+ const rel2 = trackerUrl.startsWith('http')
+ ? 'http'
+ : 'websocket'
+
+ url.push({
+ type: 'Link',
+ name: `tracker-${rel2}`,
+ rel: [ 'tracker', rel2 ],
+ href: trackerUrl
+ })
+ }
+
const subtitleLanguage = []
for (const caption of video.VideoCaptions) {
subtitleLanguage.push({