mirror of https://github.com/Chocobozzz/PeerTube
				
				
				
			Fix broken replay with long live video name
							parent
							
								
									ba278fa51d
								
							
						
					
					
						commit
						ae22c59f14
					
				| 
						 | 
					@ -20,6 +20,8 @@ import { MVideo, MVideoLive, MVideoLiveSession, MVideoWithAllFiles } from '@serv
 | 
				
			||||||
import { ffprobePromise, getAudioStream, getVideoStreamDimensionsInfo, getVideoStreamFPS } from '@shared/ffmpeg'
 | 
					import { ffprobePromise, getAudioStream, getVideoStreamDimensionsInfo, getVideoStreamFPS } from '@shared/ffmpeg'
 | 
				
			||||||
import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models'
 | 
					import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models'
 | 
				
			||||||
import { logger, loggerTagsFactory } from '../../../helpers/logger'
 | 
					import { logger, loggerTagsFactory } from '../../../helpers/logger'
 | 
				
			||||||
 | 
					import { peertubeTruncate } from '@server/helpers/core-utils'
 | 
				
			||||||
 | 
					import { CONSTRAINTS_FIELDS } from '@server/initializers/constants'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const lTags = loggerTagsFactory('live', 'job')
 | 
					const lTags = loggerTagsFactory('live', 'job')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -88,8 +90,13 @@ async function saveReplayToExternalVideo (options: {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const replaySettings = await VideoLiveReplaySettingModel.load(liveSession.replaySettingId)
 | 
					  const replaySettings = await VideoLiveReplaySettingModel.load(liveSession.replaySettingId)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const videoNameSuffix = ` - ${new Date(publishedAt).toLocaleString()}`
 | 
				
			||||||
 | 
					  const truncatedVideoName = peertubeTruncate(liveVideo.name, {
 | 
				
			||||||
 | 
					    length: CONSTRAINTS_FIELDS.VIDEOS.NAME.max - videoNameSuffix.length
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const replayVideo = new VideoModel({
 | 
					  const replayVideo = new VideoModel({
 | 
				
			||||||
    name: `${liveVideo.name} - ${new Date(publishedAt).toLocaleString()}`,
 | 
					    name: truncatedVideoName + videoNameSuffix,
 | 
				
			||||||
    isLive: false,
 | 
					    isLive: false,
 | 
				
			||||||
    state: VideoState.TO_TRANSCODE,
 | 
					    state: VideoState.TO_TRANSCODE,
 | 
				
			||||||
    duration: 0,
 | 
					    duration: 0,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -38,7 +38,7 @@ describe('Save replay setting', function () {
 | 
				
			||||||
    const attributes: LiveVideoCreate = {
 | 
					    const attributes: LiveVideoCreate = {
 | 
				
			||||||
      channelId: servers[0].store.channel.id,
 | 
					      channelId: servers[0].store.channel.id,
 | 
				
			||||||
      privacy: VideoPrivacy.PUBLIC,
 | 
					      privacy: VideoPrivacy.PUBLIC,
 | 
				
			||||||
      name: 'my super live',
 | 
					      name: 'live'.repeat(30),
 | 
				
			||||||
      saveReplay: options.replay,
 | 
					      saveReplay: options.replay,
 | 
				
			||||||
      replaySettings: options.replaySettings,
 | 
					      replaySettings: options.replaySettings,
 | 
				
			||||||
      permanentLive: options.permanent
 | 
					      permanentLive: options.permanent
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,5 @@
 | 
				
			||||||
import ffmpeg, { FfmpegCommand } from 'fluent-ffmpeg'
 | 
					import ffmpeg, { FfmpegCommand } from 'fluent-ffmpeg'
 | 
				
			||||||
 | 
					import { truncate } from 'lodash'
 | 
				
			||||||
import { buildAbsoluteFixturePath, wait } from '@shared/core-utils'
 | 
					import { buildAbsoluteFixturePath, wait } from '@shared/core-utils'
 | 
				
			||||||
import { VideoDetails, VideoInclude, VideoPrivacy } from '@shared/models'
 | 
					import { VideoDetails, VideoInclude, VideoPrivacy } from '@shared/models'
 | 
				
			||||||
import { PeerTubeServer } from '../server/server'
 | 
					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 })
 | 
					  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 {
 | 
					export {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue