} from '../../../shared/index'
import { VideoTorrentObject } from '../../../shared/models/activitypub/objects'
import { VideoPrivacy } from '../../../shared/models/videos'
-import { sanitizeAndCheckVideoTorrentObject } from '../../helpers/custom-validators/activitypub/videos'
+import { isAPVideoFileMetadataObject, sanitizeAndCheckVideoTorrentObject } from '../../helpers/custom-validators/activitypub/videos'
import { isVideoFileInfoHashValid } from '../../helpers/custom-validators/videos'
import { deleteNonExistingModels, resetSequelizeInstance, retryTransactionWrapper } from '../../helpers/database-utils'
import { logger } from '../../helpers/logger'
P2P_MEDIA_LOADER_PEER_VERSION,
PREVIEWS_SIZE,
REMOTE_SCHEME,
- STATIC_PATHS, THUMBNAILS_SIZE
+ STATIC_PATHS,
+ THUMBNAILS_SIZE
} from '../../initializers/constants'
import { TagModel } from '../../models/video/tag'
import { VideoModel } from '../../models/video/video'
MVideoAPWithoutCaption,
MVideoFile,
MVideoFullLight,
- MVideoId, MVideoImmutable,
+ MVideoId,
+ MVideoImmutable,
MVideoThumbnail
} from '../../typings/models'
import { MThumbnail } from '../../typings/models/video/thumbnail'
logger.info('Fetching remote video %s.', videoUrl)
- const { response, body } = await doRequest(options)
+ const { response, body } = await doRequest<any>(options)
if (sanitizeAndCheckVideoTorrentObject(body) === false || checkUrlsSameHost(body.id, videoUrl) !== true) {
logger.debug('Remote video JSON is not valid.', { body })
json: true
}
- const { body } = await doRequest(options)
+ const { body } = await doRequest<any>(options)
return body.description ? body.description : ''
}
const mimeTypes = Object.keys(MIMETYPES.VIDEO.MIMETYPE_EXT)
const urlMediaType = url.mediaType
- return mimeTypes.indexOf(urlMediaType) !== -1 && urlMediaType.startsWith('video/')
+ return mimeTypes.includes(urlMediaType) && urlMediaType.startsWith('video/')
}
function isAPStreamingPlaylistUrlObject (url: ActivityUrlObject): url is ActivityPlaylistUrlObject {
}
function videoActivityObjectToDBAttributes (videoChannel: MChannelId, videoObject: VideoTorrentObject, to: string[] = []) {
- const privacy = to.indexOf(ACTIVITY_PUB.PUBLIC) !== -1 ? VideoPrivacy.PUBLIC : VideoPrivacy.UNLISTED
- const duration = videoObject.duration.replace(/[^\d]+/, '')
+ const privacy = to.includes(ACTIVITY_PUB.PUBLIC)
+ ? VideoPrivacy.PUBLIC
+ : VideoPrivacy.UNLISTED
+ const duration = videoObject.duration.replace(/[^\d]+/, '')
const language = videoObject.language?.identifier
const category = videoObject.category
throw new Error('Cannot parse magnet URI ' + magnet.href)
}
+ // Fetch associated metadata url, if any
+ const metadata = urls.filter(isAPVideoFileMetadataObject)
+ .find(u => {
+ return u.height === fileUrl.height &&
+ u.fps === fileUrl.fps &&
+ u.rel.includes(fileUrl.mediaType)
+ })
+
const mediaType = fileUrl.mediaType
const attribute = {
extname: MIMETYPES.VIDEO.MIMETYPE_EXT[mediaType],
resolution: fileUrl.height,
size: fileUrl.size,
fps: fileUrl.fps || -1,
+ metadataUrl: metadata?.href,
// This is a video file owned by a video or by a streaming playlist
videoId: (videoOrPlaylist as MStreamingPlaylist).playlistUrl ? null : videoOrPlaylist.id,