Fix caption in object storage export
This commit is contained in:
parent
b6b6922006
commit
0184aa9be7
|
@ -252,3 +252,18 @@ export function getOriginalFileReadStream (options: {
|
||||||
rangeHeader
|
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 { audiencify, getAudience } from '@server/lib/activitypub/audience.js'
|
||||||
import { buildCreateActivity } from '@server/lib/activitypub/send/send-create.js'
|
import { buildCreateActivity } from '@server/lib/activitypub/send/send-create.js'
|
||||||
import { buildChaptersAPHasPart } from '@server/lib/activitypub/video-chapters.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 { muxToMergeVideoFiles } from '@server/lib/video-file.js'
|
||||||
import { VideoPathManager } from '@server/lib/video-path-manager.js'
|
import { VideoPathManager } from '@server/lib/video-path-manager.js'
|
||||||
import { VideoCaptionModel } from '@server/models/video/video-caption.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) {
|
for (const caption of captions) {
|
||||||
staticFiles.push({
|
staticFiles.push({
|
||||||
archivePath: this.getArchiveCaptionFilePath(video, caption),
|
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))
|
relativePathsFromJSON.captions[caption.language] = join(this.relativeStaticDirPath, this.getArchiveCaptionFilePath(video, caption))
|
||||||
|
@ -400,6 +400,18 @@ export class VideosExporter extends AbstractUserExporter <VideoExportJSON> {
|
||||||
return stream
|
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) {
|
private async getArchiveVideo (video: MVideoFullLight) {
|
||||||
const source = await VideoSourceModel.loadLatest(video.id)
|
const source = await VideoSourceModel.loadLatest(video.id)
|
||||||
|
|
||||||
|
|
|
@ -291,8 +291,6 @@ export class UserExporter {
|
||||||
stream.once('readable', () => {
|
stream.once('readable', () => {
|
||||||
if (errored) return
|
if (errored) return
|
||||||
|
|
||||||
logger.error('Readable stream ' + archivePath)
|
|
||||||
|
|
||||||
this.archive.append(stream, { name: archivePath })
|
this.archive.append(stream, { name: archivePath })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue