From ae22c59f14d0d553f60b281948b6c232c2aca178 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 29 Jun 2023 08:57:19 +0200 Subject: Fix broken replay with long live video name --- shared/server-commands/videos/live.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'shared/server-commands') 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 @@ import ffmpeg, { FfmpegCommand } from 'fluent-ffmpeg' +import { truncate } from 'lodash' import { buildAbsoluteFixturePath, wait } from '@shared/core-utils' import { VideoDetails, VideoInclude, VideoPrivacy } from '@shared/models' import { PeerTubeServer } from '../server/server' @@ -104,7 +105,13 @@ async function findExternalSavedVideo (server: PeerTubeServer, liveDetails: Vide const { data } = await server.videos.list({ token: server.accessToken, sort: '-publishedAt', include, privacyOneOf }) - return data.find(v => v.name === liveDetails.name + ' - ' + new Date(liveDetails.publishedAt).toLocaleString()) + const videoNameSuffix = ` - ${new Date(liveDetails.publishedAt).toLocaleString()}` + const truncatedVideoName = truncate(liveDetails.name, { + length: 120 - videoNameSuffix.length + }) + const toFind = truncatedVideoName + videoNameSuffix + + return data.find(v => v.name === toFind) } export { -- cgit v1.2.3