mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
Fix caption in object storage export
This commit is contained in:
@@ -252,3 +252,18 @@ export function getOriginalFileReadStream (options: {
|
||||
rangeHeader
|
||||
})
|
||||
}
|
||||
|
||||
export function getCaptionReadStream (options: {
|
||||
filename: string
|
||||
rangeHeader: string
|
||||
}) {
|
||||
const { filename, rangeHeader } = options
|
||||
|
||||
const key = generateCaptionObjectStorageKey(filename)
|
||||
|
||||
return createObjectReadStream({
|
||||
key,
|
||||
bucketInfo: CONFIG.OBJECT_STORAGE.CAPTIONS,
|
||||
rangeHeader
|
||||
})
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { USER_EXPORT_MAX_ITEMS } from '@server/initializers/constants.js'
|
||||
import { audiencify, getAudience } from '@server/lib/activitypub/audience.js'
|
||||
import { buildCreateActivity } from '@server/lib/activitypub/send/send-create.js'
|
||||
import { buildChaptersAPHasPart } from '@server/lib/activitypub/video-chapters.js'
|
||||
import { getHLSFileReadStream, getOriginalFileReadStream, getWebVideoFileReadStream } from '@server/lib/object-storage/videos.js'
|
||||
import { getCaptionReadStream, getHLSFileReadStream, getOriginalFileReadStream, getWebVideoFileReadStream } from '@server/lib/object-storage/videos.js'
|
||||
import { muxToMergeVideoFiles } from '@server/lib/video-file.js'
|
||||
import { VideoPathManager } from '@server/lib/video-path-manager.js'
|
||||
import { VideoCaptionModel } from '@server/models/video/video-caption.js'
|
||||
@@ -344,7 +344,7 @@ export class VideosExporter extends AbstractUserExporter <VideoExportJSON> {
|
||||
for (const caption of captions) {
|
||||
staticFiles.push({
|
||||
archivePath: this.getArchiveCaptionFilePath(video, caption),
|
||||
readStreamFactory: () => Promise.resolve(createReadStream(caption.getFSPath()))
|
||||
readStreamFactory: () => this.generateCaptionReadStream(caption)
|
||||
})
|
||||
|
||||
relativePathsFromJSON.captions[caption.language] = join(this.relativeStaticDirPath, this.getArchiveCaptionFilePath(video, caption))
|
||||
@@ -400,6 +400,18 @@ export class VideosExporter extends AbstractUserExporter <VideoExportJSON> {
|
||||
return stream
|
||||
}
|
||||
|
||||
private async generateCaptionReadStream (caption: MVideoCaption): Promise<Readable> {
|
||||
if (caption.storage === FileStorage.FILE_SYSTEM) {
|
||||
return createReadStream(caption.getFSPath())
|
||||
}
|
||||
|
||||
const { stream } = await getCaptionReadStream({ filename: caption.filename, rangeHeader: undefined })
|
||||
|
||||
return stream
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
private async getArchiveVideo (video: MVideoFullLight) {
|
||||
const source = await VideoSourceModel.loadLatest(video.id)
|
||||
|
||||
|
||||
@@ -291,8 +291,6 @@ export class UserExporter {
|
||||
stream.once('readable', () => {
|
||||
if (errored) return
|
||||
|
||||
logger.error('Readable stream ' + archivePath)
|
||||
|
||||
this.archive.append(stream, { name: archivePath })
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user