aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-02-15 14:08:16 +0100
committerChocobozzz <chocobozzz@cpy.re>2021-02-16 10:36:44 +0100
commit6302d599cdf98b5a5363a2a1dcdc266447950191 (patch)
treeb7dc6dc0f08f0fb8a20720242c9c0a71afeeaa3f /server/lib/activitypub
parenta8b1b40485145ac1eae513a661d7dd6e0986ce96 (diff)
downloadPeerTube-6302d599cdf98b5a5363a2a1dcdc266447950191.tar.gz
PeerTube-6302d599cdf98b5a5363a2a1dcdc266447950191.tar.zst
PeerTube-6302d599cdf98b5a5363a2a1dcdc266447950191.zip
Generate a name for caption files
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r--server/lib/activitypub/playlist.ts2
-rw-r--r--server/lib/activitypub/videos.ts21
2 files changed, 18 insertions, 5 deletions
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
99 return Promise.resolve() 99 return Promise.resolve()
100 }) 100 })
101 101
102 logger.info('toto', { playlist, id: playlist.id })
103
104 const refreshedPlaylist = await VideoPlaylistModel.loadWithAccountAndChannel(playlist.id, null) 102 const refreshedPlaylist = await VideoPlaylistModel.loadWithAccountAndChannel(playlist.id, null)
105 103
106 if (playlistObject.icon) { 104 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 {
56 MVideoAccountLightBlacklistAllFiles, 56 MVideoAccountLightBlacklistAllFiles,
57 MVideoAP, 57 MVideoAP,
58 MVideoAPWithoutCaption, 58 MVideoAPWithoutCaption,
59 MVideoCaption,
59 MVideoFile, 60 MVideoFile,
60 MVideoFullLight, 61 MVideoFullLight,
61 MVideoId, 62 MVideoId,
@@ -90,7 +91,7 @@ async function federateVideoIfNeeded (videoArg: MVideoAPWithoutCaption, isNewVid
90 // Fetch more attributes that we will need to serialize in AP object 91 // Fetch more attributes that we will need to serialize in AP object
91 if (isArray(video.VideoCaptions) === false) { 92 if (isArray(video.VideoCaptions) === false) {
92 video.VideoCaptions = await video.$get('VideoCaptions', { 93 video.VideoCaptions = await video.$get('VideoCaptions', {
93 attributes: [ 'language' ], 94 attributes: [ 'filename', 'language' ],
94 transaction 95 transaction
95 }) 96 })
96 } 97 }
@@ -423,7 +424,14 @@ async function updateVideoFromAP (options: {
423 await VideoCaptionModel.deleteAllCaptionsOfRemoteVideo(videoUpdated.id, t) 424 await VideoCaptionModel.deleteAllCaptionsOfRemoteVideo(videoUpdated.id, t)
424 425
425 const videoCaptionsPromises = videoObject.subtitleLanguage.map(c => { 426 const videoCaptionsPromises = videoObject.subtitleLanguage.map(c => {
426 return VideoCaptionModel.insertOrReplaceLanguage(videoUpdated.id, c.identifier, c.url, t) 427 const caption = new VideoCaptionModel({
428 videoId: videoUpdated.id,
429 filename: VideoCaptionModel.generateCaptionName(c.identifier),
430 language: c.identifier,
431 fileUrl: c.url
432 }) as MVideoCaption
433
434 return VideoCaptionModel.insertOrReplaceLanguage(caption, t)
427 }) 435 })
428 await Promise.all(videoCaptionsPromises) 436 await Promise.all(videoCaptionsPromises)
429 } 437 }
@@ -629,7 +637,14 @@ async function createVideo (videoObject: VideoObject, channel: MChannelAccountLi
629 637
630 // Process captions 638 // Process captions
631 const videoCaptionsPromises = videoObject.subtitleLanguage.map(c => { 639 const videoCaptionsPromises = videoObject.subtitleLanguage.map(c => {
632 return VideoCaptionModel.insertOrReplaceLanguage(videoCreated.id, c.identifier, c.url, t) 640 const caption = new VideoCaptionModel({
641 videoId: videoCreated.id,
642 filename: VideoCaptionModel.generateCaptionName(c.identifier),
643 language: c.identifier,
644 fileUrl: c.url
645 }) as MVideoCaption
646
647 return VideoCaptionModel.insertOrReplaceLanguage(caption, t)
633 }) 648 })
634 await Promise.all(videoCaptionsPromises) 649 await Promise.all(videoCaptionsPromises)
635 650