aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-03-10 14:49:02 +0100
committerChocobozzz <me@florianbigard.com>2020-03-10 16:18:29 +0100
commit7b81edc854902a536083298472bf92bb6726edcf (patch)
tree822dae6b6d4755ac9afffe2569b74dcb45da5535 /server/lib
parent8319d6ae72d4da6de51bd3d4b5c68040fc8dc3b4 (diff)
downloadPeerTube-7b81edc854902a536083298472bf92bb6726edcf.tar.gz
PeerTube-7b81edc854902a536083298472bf92bb6726edcf.tar.zst
PeerTube-7b81edc854902a536083298472bf92bb6726edcf.zip
Video file metadata PR cleanup
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/activitypub/videos.ts26
-rw-r--r--server/lib/video-transcoding.ts3
2 files changed, 12 insertions, 17 deletions
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 {
9 ActivityPlaylistUrlObject, 9 ActivityPlaylistUrlObject,
10 ActivityTagObject, 10 ActivityTagObject,
11 ActivityUrlObject, 11 ActivityUrlObject,
12 ActivityVideoFileMetadataObject,
12 ActivityVideoUrlObject, 13 ActivityVideoUrlObject,
13 VideoState, 14 VideoState
14 ActivityVideoFileMetadataObject
15} from '../../../shared/index' 15} from '../../../shared/index'
16import { VideoTorrentObject } from '../../../shared/models/activitypub/objects' 16import { VideoTorrentObject } from '../../../shared/models/activitypub/objects'
17import { VideoPrivacy } from '../../../shared/models/videos' 17import { VideoPrivacy } from '../../../shared/models/videos'
18import { sanitizeAndCheckVideoTorrentObject } from '../../helpers/custom-validators/activitypub/videos' 18import { sanitizeAndCheckVideoTorrentObject, isAPVideoFileMetadataObject } from '../../helpers/custom-validators/activitypub/videos'
19import { isVideoFileInfoHashValid } from '../../helpers/custom-validators/videos' 19import { isVideoFileInfoHashValid } from '../../helpers/custom-validators/videos'
20import { deleteNonExistingModels, resetSequelizeInstance, retryTransactionWrapper } from '../../helpers/database-utils' 20import { deleteNonExistingModels, resetSequelizeInstance, retryTransactionWrapper } from '../../helpers/database-utils'
21import { logger } from '../../helpers/logger' 21import { logger } from '../../helpers/logger'
@@ -26,7 +26,8 @@ import {
26 P2P_MEDIA_LOADER_PEER_VERSION, 26 P2P_MEDIA_LOADER_PEER_VERSION,
27 PREVIEWS_SIZE, 27 PREVIEWS_SIZE,
28 REMOTE_SCHEME, 28 REMOTE_SCHEME,
29 STATIC_PATHS, THUMBNAILS_SIZE 29 STATIC_PATHS,
30 THUMBNAILS_SIZE
30} from '../../initializers/constants' 31} from '../../initializers/constants'
31import { TagModel } from '../../models/video/tag' 32import { TagModel } from '../../models/video/tag'
32import { VideoModel } from '../../models/video/video' 33import { VideoModel } from '../../models/video/video'
@@ -69,7 +70,8 @@ import {
69 MVideoAPWithoutCaption, 70 MVideoAPWithoutCaption,
70 MVideoFile, 71 MVideoFile,
71 MVideoFullLight, 72 MVideoFullLight,
72 MVideoId, MVideoImmutable, 73 MVideoId,
74 MVideoImmutable,
73 MVideoThumbnail 75 MVideoThumbnail
74} from '../../typings/models' 76} from '../../typings/models'
75import { MThumbnail } from '../../typings/models/video/thumbnail' 77import { MThumbnail } from '../../typings/models/video/thumbnail'
@@ -527,10 +529,6 @@ function isAPHashTagObject (url: any): url is ActivityHashTagObject {
527 return url && url.type === 'Hashtag' 529 return url && url.type === 'Hashtag'
528} 530}
529 531
530function isAPVideoFileMetadataObject (url: any): url is ActivityVideoFileMetadataObject {
531 return url && url.type === 'Link' && url.mediaType === 'application/json' && url.hasAttribute('rel') && url.rel.includes('metadata')
532}
533
534async function createVideo (videoObject: VideoTorrentObject, channel: MChannelAccountLight, waitThumbnail = false) { 532async function createVideo (videoObject: VideoTorrentObject, channel: MChannelAccountLight, waitThumbnail = false) {
535 logger.debug('Adding remote video %s.', videoObject.id) 533 logger.debug('Adding remote video %s.', videoObject.id)
536 534
@@ -701,11 +699,11 @@ function videoFileActivityUrlToDBAttributes (
701 699
702 // Fetch associated metadata url, if any 700 // Fetch associated metadata url, if any
703 const metadata = urls.filter(isAPVideoFileMetadataObject) 701 const metadata = urls.filter(isAPVideoFileMetadataObject)
704 .find(u => 702 .find(u => {
705 u.height === fileUrl.height && 703 return u.height === fileUrl.height &&
706 u.fps === fileUrl.fps && 704 u.fps === fileUrl.fps &&
707 u.rel.includes(fileUrl.mediaType) 705 u.rel.includes(fileUrl.mediaType)
708 ) 706 })
709 707
710 const mediaType = fileUrl.mediaType 708 const mediaType = fileUrl.mediaType
711 const attribute = { 709 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
237 237
238 await move(transcodingPath, outputPath) 238 await move(transcodingPath, outputPath)
239 239
240 const extractedVideo = extractVideo(video)
241
242 videoFile.size = stats.size 240 videoFile.size = stats.size
243 videoFile.fps = fps 241 videoFile.fps = fps
244 videoFile.metadata = metadata 242 videoFile.metadata = metadata
245 videoFile.metadataUrl = extractedVideo.getVideoFileMetadataUrl(videoFile, extractedVideo.getBaseUrls().baseUrlHttp)
246 243
247 await createTorrentAndSetInfoHash(video, videoFile) 244 await createTorrentAndSetInfoHash(video, videoFile)
248 245