From 7b81edc854902a536083298472bf92bb6726edcf Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 10 Mar 2020 14:49:02 +0100 Subject: Video file metadata PR cleanup --- server/lib/activitypub/videos.ts | 26 ++++++++++++-------------- server/lib/video-transcoding.ts | 3 --- 2 files changed, 12 insertions(+), 17 deletions(-) (limited to 'server/lib') diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts index 30de4714c..452e43c8c 100644 --- a/server/lib/activitypub/videos.ts +++ b/server/lib/activitypub/videos.ts @@ -9,13 +9,13 @@ import { ActivityPlaylistUrlObject, ActivityTagObject, ActivityUrlObject, + ActivityVideoFileMetadataObject, ActivityVideoUrlObject, - VideoState, - ActivityVideoFileMetadataObject + VideoState } 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 { sanitizeAndCheckVideoTorrentObject, isAPVideoFileMetadataObject } 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' @@ -26,7 +26,8 @@ import { 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' @@ -69,7 +70,8 @@ import { MVideoAPWithoutCaption, MVideoFile, MVideoFullLight, - MVideoId, MVideoImmutable, + MVideoId, + MVideoImmutable, MVideoThumbnail } from '../../typings/models' import { MThumbnail } from '../../typings/models/video/thumbnail' @@ -527,10 +529,6 @@ function isAPHashTagObject (url: any): url is ActivityHashTagObject { return url && url.type === 'Hashtag' } -function isAPVideoFileMetadataObject (url: any): url is ActivityVideoFileMetadataObject { - return url && url.type === 'Link' && url.mediaType === 'application/json' && url.hasAttribute('rel') && url.rel.includes('metadata') -} - async function createVideo (videoObject: VideoTorrentObject, channel: MChannelAccountLight, waitThumbnail = false) { logger.debug('Adding remote video %s.', videoObject.id) @@ -701,11 +699,11 @@ function videoFileActivityUrlToDBAttributes ( // Fetch associated metadata url, if any const metadata = urls.filter(isAPVideoFileMetadataObject) - .find(u => - u.height === fileUrl.height && - u.fps === fileUrl.fps && - u.rel.includes(fileUrl.mediaType) - ) + .find(u => { + return u.height === fileUrl.height && + u.fps === fileUrl.fps && + u.rel.includes(fileUrl.mediaType) + }) const mediaType = fileUrl.mediaType const attribute = { diff --git a/server/lib/video-transcoding.ts b/server/lib/video-transcoding.ts index 444b0d954..bde4c2633 100644 --- a/server/lib/video-transcoding.ts +++ b/server/lib/video-transcoding.ts @@ -237,12 +237,9 @@ async function onVideoFileTranscoding (video: MVideoWithFile, videoFile: MVideoF await move(transcodingPath, outputPath) - const extractedVideo = extractVideo(video) - videoFile.size = stats.size videoFile.fps = fps videoFile.metadata = metadata - videoFile.metadataUrl = extractedVideo.getVideoFileMetadataUrl(videoFile, extractedVideo.getBaseUrls().baseUrlHttp) await createTorrentAndSetInfoHash(video, videoFile) -- cgit v1.2.3