]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/server-commands/videos/live.ts
Fix broken replay with long live video name
[github/Chocobozzz/PeerTube.git] / shared / server-commands / videos / live.ts
index 48464fb6110153f7aca4a370e675bd5c1c71f7e7..cebadb1dbb008b23a367cf772f55b88fd052052e 100644 (file)
@@ -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 {