From 6302d599cdf98b5a5363a2a1dcdc266447950191 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 15 Feb 2021 14:08:16 +0100 Subject: Generate a name for caption files --- server/lib/activitypub/playlist.ts | 2 -- server/lib/activitypub/videos.ts | 21 ++++++++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'server/lib/activitypub') diff --git a/server/lib/activitypub/playlist.ts b/server/lib/activitypub/playlist.ts index 8b54a001a..53298e968 100644 --- a/server/lib/activitypub/playlist.ts +++ b/server/lib/activitypub/playlist.ts @@ -99,8 +99,6 @@ async function createOrUpdateVideoPlaylist (playlistObject: PlaylistObject, byAc return Promise.resolve() }) - logger.info('toto', { playlist, id: playlist.id }) - const refreshedPlaylist = await VideoPlaylistModel.loadWithAccountAndChannel(playlist.id, null) if (playlistObject.icon) { diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts index b5a199e67..201ef0302 100644 --- a/server/lib/activitypub/videos.ts +++ b/server/lib/activitypub/videos.ts @@ -56,6 +56,7 @@ import { MVideoAccountLightBlacklistAllFiles, MVideoAP, MVideoAPWithoutCaption, + MVideoCaption, MVideoFile, MVideoFullLight, MVideoId, @@ -90,7 +91,7 @@ async function federateVideoIfNeeded (videoArg: MVideoAPWithoutCaption, isNewVid // Fetch more attributes that we will need to serialize in AP object if (isArray(video.VideoCaptions) === false) { video.VideoCaptions = await video.$get('VideoCaptions', { - attributes: [ 'language' ], + attributes: [ 'filename', 'language' ], transaction }) } @@ -423,7 +424,14 @@ async function updateVideoFromAP (options: { await VideoCaptionModel.deleteAllCaptionsOfRemoteVideo(videoUpdated.id, t) const videoCaptionsPromises = videoObject.subtitleLanguage.map(c => { - return VideoCaptionModel.insertOrReplaceLanguage(videoUpdated.id, c.identifier, c.url, t) + const caption = new VideoCaptionModel({ + videoId: videoUpdated.id, + filename: VideoCaptionModel.generateCaptionName(c.identifier), + language: c.identifier, + fileUrl: c.url + }) as MVideoCaption + + return VideoCaptionModel.insertOrReplaceLanguage(caption, t) }) await Promise.all(videoCaptionsPromises) } @@ -629,7 +637,14 @@ async function createVideo (videoObject: VideoObject, channel: MChannelAccountLi // Process captions const videoCaptionsPromises = videoObject.subtitleLanguage.map(c => { - return VideoCaptionModel.insertOrReplaceLanguage(videoCreated.id, c.identifier, c.url, t) + const caption = new VideoCaptionModel({ + videoId: videoCreated.id, + filename: VideoCaptionModel.generateCaptionName(c.identifier), + language: c.identifier, + fileUrl: c.url + }) as MVideoCaption + + return VideoCaptionModel.insertOrReplaceLanguage(caption, t) }) await Promise.all(videoCaptionsPromises) -- cgit v1.2.3