diff options
-rw-r--r-- | server/lib/job-queue/handlers/video-live-ending.ts | 9 | ||||
-rw-r--r-- | server/tests/api/live/live-save-replay.ts | 2 | ||||
-rw-r--r-- | shared/server-commands/videos/live.ts | 9 |
3 files changed, 17 insertions, 3 deletions
diff --git a/server/lib/job-queue/handlers/video-live-ending.ts b/server/lib/job-queue/handlers/video-live-ending.ts index 814f313a3..49feb53f2 100644 --- a/server/lib/job-queue/handlers/video-live-ending.ts +++ b/server/lib/job-queue/handlers/video-live-ending.ts | |||
@@ -20,6 +20,8 @@ import { MVideo, MVideoLive, MVideoLiveSession, MVideoWithAllFiles } from '@serv | |||
20 | import { ffprobePromise, getAudioStream, getVideoStreamDimensionsInfo, getVideoStreamFPS } from '@shared/ffmpeg' | 20 | import { ffprobePromise, getAudioStream, getVideoStreamDimensionsInfo, getVideoStreamFPS } from '@shared/ffmpeg' |
21 | import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models' | 21 | import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models' |
22 | import { logger, loggerTagsFactory } from '../../../helpers/logger' | 22 | import { logger, loggerTagsFactory } from '../../../helpers/logger' |
23 | import { peertubeTruncate } from '@server/helpers/core-utils' | ||
24 | import { CONSTRAINTS_FIELDS } from '@server/initializers/constants' | ||
23 | 25 | ||
24 | const lTags = loggerTagsFactory('live', 'job') | 26 | const lTags = loggerTagsFactory('live', 'job') |
25 | 27 | ||
@@ -88,8 +90,13 @@ async function saveReplayToExternalVideo (options: { | |||
88 | 90 | ||
89 | const replaySettings = await VideoLiveReplaySettingModel.load(liveSession.replaySettingId) | 91 | const replaySettings = await VideoLiveReplaySettingModel.load(liveSession.replaySettingId) |
90 | 92 | ||
93 | const videoNameSuffix = ` - ${new Date(publishedAt).toLocaleString()}` | ||
94 | const truncatedVideoName = peertubeTruncate(liveVideo.name, { | ||
95 | length: CONSTRAINTS_FIELDS.VIDEOS.NAME.max - videoNameSuffix.length | ||
96 | }) | ||
97 | |||
91 | const replayVideo = new VideoModel({ | 98 | const replayVideo = new VideoModel({ |
92 | name: `${liveVideo.name} - ${new Date(publishedAt).toLocaleString()}`, | 99 | name: truncatedVideoName + videoNameSuffix, |
93 | isLive: false, | 100 | isLive: false, |
94 | state: VideoState.TO_TRANSCODE, | 101 | state: VideoState.TO_TRANSCODE, |
95 | duration: 0, | 102 | duration: 0, |
diff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.ts index 8985c9b39..d554cf208 100644 --- a/server/tests/api/live/live-save-replay.ts +++ b/server/tests/api/live/live-save-replay.ts | |||
@@ -38,7 +38,7 @@ describe('Save replay setting', function () { | |||
38 | const attributes: LiveVideoCreate = { | 38 | const attributes: LiveVideoCreate = { |
39 | channelId: servers[0].store.channel.id, | 39 | channelId: servers[0].store.channel.id, |
40 | privacy: VideoPrivacy.PUBLIC, | 40 | privacy: VideoPrivacy.PUBLIC, |
41 | name: 'my super live', | 41 | name: 'live'.repeat(30), |
42 | saveReplay: options.replay, | 42 | saveReplay: options.replay, |
43 | replaySettings: options.replaySettings, | 43 | replaySettings: options.replaySettings, |
44 | permanentLive: options.permanent | 44 | permanentLive: options.permanent |
diff --git a/shared/server-commands/videos/live.ts b/shared/server-commands/videos/live.ts index 48464fb61..cebadb1db 100644 --- a/shared/server-commands/videos/live.ts +++ b/shared/server-commands/videos/live.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | import ffmpeg, { FfmpegCommand } from 'fluent-ffmpeg' | 1 | import ffmpeg, { FfmpegCommand } from 'fluent-ffmpeg' |
2 | import { truncate } from 'lodash' | ||
2 | import { buildAbsoluteFixturePath, wait } from '@shared/core-utils' | 3 | import { buildAbsoluteFixturePath, wait } from '@shared/core-utils' |
3 | import { VideoDetails, VideoInclude, VideoPrivacy } from '@shared/models' | 4 | import { VideoDetails, VideoInclude, VideoPrivacy } from '@shared/models' |
4 | import { PeerTubeServer } from '../server/server' | 5 | import { PeerTubeServer } from '../server/server' |
@@ -104,7 +105,13 @@ async function findExternalSavedVideo (server: PeerTubeServer, liveDetails: Vide | |||
104 | 105 | ||
105 | const { data } = await server.videos.list({ token: server.accessToken, sort: '-publishedAt', include, privacyOneOf }) | 106 | const { data } = await server.videos.list({ token: server.accessToken, sort: '-publishedAt', include, privacyOneOf }) |
106 | 107 | ||
107 | return data.find(v => v.name === liveDetails.name + ' - ' + new Date(liveDetails.publishedAt).toLocaleString()) | 108 | const videoNameSuffix = ` - ${new Date(liveDetails.publishedAt).toLocaleString()}` |
109 | const truncatedVideoName = truncate(liveDetails.name, { | ||
110 | length: 120 - videoNameSuffix.length | ||
111 | }) | ||
112 | const toFind = truncatedVideoName + videoNameSuffix | ||
113 | |||
114 | return data.find(v => v.name === toFind) | ||
108 | } | 115 | } |
109 | 116 | ||
110 | export { | 117 | export { |