AP mimeType -> mediaType
This commit is contained in:
parent
244b4ae397
commit
e27ff5da6e
|
@ -81,19 +81,20 @@ function isRemoteVideoUrlValid (url: any) {
|
|||
|
||||
return url.type === 'Link' &&
|
||||
(
|
||||
ACTIVITY_PUB.URL_MIME_TYPES.VIDEO.indexOf(url.mimeType) !== -1 &&
|
||||
// TODO: remove mimeType (backward compatibility, introduced in v1.1.0)
|
||||
ACTIVITY_PUB.URL_MIME_TYPES.VIDEO.indexOf(url.mediaType || url.mimeType) !== -1 &&
|
||||
isActivityPubUrlValid(url.href) &&
|
||||
validator.isInt(url.height + '', { min: 0 }) &&
|
||||
validator.isInt(url.size + '', { min: 0 }) &&
|
||||
(!url.fps || validator.isInt(url.fps + '', { min: -1 }))
|
||||
) ||
|
||||
(
|
||||
ACTIVITY_PUB.URL_MIME_TYPES.TORRENT.indexOf(url.mimeType) !== -1 &&
|
||||
ACTIVITY_PUB.URL_MIME_TYPES.TORRENT.indexOf(url.mediaType || url.mimeType) !== -1 &&
|
||||
isActivityPubUrlValid(url.href) &&
|
||||
validator.isInt(url.height + '', { min: 0 })
|
||||
) ||
|
||||
(
|
||||
ACTIVITY_PUB.URL_MIME_TYPES.MAGNET.indexOf(url.mimeType) !== -1 &&
|
||||
ACTIVITY_PUB.URL_MIME_TYPES.MAGNET.indexOf(url.mediaType || url.mimeType) !== -1 &&
|
||||
validator.isLength(url.href, { min: 5 }) &&
|
||||
validator.isInt(url.height + '', { min: 0 })
|
||||
)
|
||||
|
|
|
@ -310,7 +310,8 @@ export {
|
|||
function isActivityVideoUrlObject (url: ActivityUrlObject): url is ActivityVideoUrlObject {
|
||||
const mimeTypes = Object.keys(VIDEO_MIMETYPE_EXT)
|
||||
|
||||
return mimeTypes.indexOf(url.mimeType) !== -1 && url.mimeType.startsWith('video/')
|
||||
const urlMediaType = url.mediaType || url.mimeType
|
||||
return mimeTypes.indexOf(urlMediaType) !== -1 && urlMediaType.startsWith('video/')
|
||||
}
|
||||
|
||||
async function createVideo (videoObject: VideoTorrentObject, channelActor: ActorModel, waitThumbnail = false) {
|
||||
|
@ -468,7 +469,8 @@ function videoFileActivityUrlToDBAttributes (video: VideoModel, videoObject: Vid
|
|||
for (const fileUrl of fileUrls) {
|
||||
// Fetch associated magnet uri
|
||||
const magnet = videoObject.url.find(u => {
|
||||
return u.mimeType === 'application/x-bittorrent;x-scheme-handler/magnet' && u.height === fileUrl.height
|
||||
const mediaType = u.mediaType || u.mimeType
|
||||
return mediaType === 'application/x-bittorrent;x-scheme-handler/magnet' && (u as any).height === fileUrl.height
|
||||
})
|
||||
|
||||
if (!magnet) throw new Error('Cannot find associated magnet uri for file ' + fileUrl.href)
|
||||
|
@ -478,8 +480,9 @@ function videoFileActivityUrlToDBAttributes (video: VideoModel, videoObject: Vid
|
|||
throw new Error('Cannot parse magnet URI ' + magnet.href)
|
||||
}
|
||||
|
||||
const mediaType = fileUrl.mediaType || fileUrl.mimeType
|
||||
const attribute = {
|
||||
extname: VIDEO_MIMETYPE_EXT[ fileUrl.mimeType ],
|
||||
extname: VIDEO_MIMETYPE_EXT[ mediaType ],
|
||||
infoHash: parsed.infoHash,
|
||||
resolution: fileUrl.height,
|
||||
size: fileUrl.size,
|
||||
|
|
|
@ -408,6 +408,7 @@ export class VideoRedundancyModel extends Model<VideoRedundancyModel> {
|
|||
url: {
|
||||
type: 'Link',
|
||||
mimeType: VIDEO_EXT_MIMETYPE[ this.VideoFile.extname ] as any,
|
||||
mediaType: VIDEO_EXT_MIMETYPE[ this.VideoFile.extname ] as any,
|
||||
href: this.fileUrl,
|
||||
height: this.VideoFile.resolution,
|
||||
size: this.VideoFile.size,
|
||||
|
|
|
@ -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
|
||||
})
|
||||
|
||||
|
|
|
@ -19,7 +19,9 @@ export interface ActivityIconObject {
|
|||
|
||||
export type ActivityVideoUrlObject = {
|
||||
type: 'Link'
|
||||
mimeType: 'video/mp4' | 'video/webm' | 'video/ogg'
|
||||
// TODO: remove mimeType (backward compatibility, introduced in v1.1.0)
|
||||
mimeType?: 'video/mp4' | 'video/webm' | 'video/ogg'
|
||||
mediaType: 'video/mp4' | 'video/webm' | 'video/ogg'
|
||||
href: string
|
||||
height: number
|
||||
size: number
|
||||
|
@ -31,14 +33,18 @@ export type ActivityUrlObject =
|
|||
|
|
||||
{
|
||||
type: 'Link'
|
||||
mimeType: 'application/x-bittorrent' | 'application/x-bittorrent;x-scheme-handler/magnet'
|
||||
// TODO: remove mimeType (backward compatibility, introduced in v1.1.0)
|
||||
mimeType?: 'application/x-bittorrent' | 'application/x-bittorrent;x-scheme-handler/magnet'
|
||||
mediaType: 'application/x-bittorrent' | 'application/x-bittorrent;x-scheme-handler/magnet'
|
||||
href: string
|
||||
height: number
|
||||
}
|
||||
|
|
||||
{
|
||||
type: 'Link'
|
||||
mimeType: 'text/html'
|
||||
// TODO: remove mimeType (backward compatibility, introduced in v1.1.0)
|
||||
mimeType?: 'text/html'
|
||||
mediaType: 'text/html'
|
||||
href: string
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue