Minor update

This commit is contained in:
bskjon 2024-04-18 00:51:47 +02:00
parent 528d07f645
commit e6550bcfb0
3 changed files with 9 additions and 5 deletions

View File

@ -10,6 +10,10 @@ import java.io.File
class MetadataMapping(val events: List<PersistentMessage>) { class MetadataMapping(val events: List<PersistentMessage>) {
var collection: String?
init {
collection = getCollection()
}
fun map(): MetadataDto? { fun map(): MetadataDto? {
@ -25,7 +29,6 @@ class MetadataMapping(val events: List<PersistentMessage>) {
} }
val videoInfo = mediaReadOut?.toValueObject() val videoInfo = mediaReadOut?.toValueObject()
val collection = mediaReadOut?.outDirectory?.let { File(it).name } ?: baseInfo?.title
val mediaCover = if (coverDownloadTask != null || cover != null) { val mediaCover = if (coverDownloadTask != null || cover != null) {
@ -51,12 +54,13 @@ class MetadataMapping(val events: List<PersistentMessage>) {
} else null } else null
} }
fun getCollection(): String? { private fun getCollection(): String? {
val mediaReadOut = events.find { it.data is VideoInfoPerformed }?.data as VideoInfoPerformed?
val baseInfo = events.find { it.data is BaseInfoPerformed }?.data as BaseInfoPerformed? val baseInfo = events.find { it.data is BaseInfoPerformed }?.data as BaseInfoPerformed?
if (!baseInfo.isSuccess()) { if (!baseInfo.isSuccess()) {
return null return null
} }
return baseInfo?.title return mediaReadOut?.outDirectory?.let { File(it).name } ?: baseInfo?.title
} }
} }

View File

@ -18,7 +18,7 @@ class ProcessMapping(val events: List<PersistentMessage>) {
referenceId = referenceId, referenceId = referenceId,
process = processStarted?.type, process = processStarted?.type,
inputFile = processStarted?.file, inputFile = processStarted?.file,
collection = meta.getCollection(), collection = meta.collection,
metadata = meta.map(), metadata = meta.map(),
videoDetails = VideoDetailsMapper(events).mapTo(), videoDetails = VideoDetailsMapper(events).mapTo(),
outputFiles = OutputFilesMapping(events).mapTo() outputFiles = OutputFilesMapping(events).mapTo()

View File

@ -53,7 +53,7 @@ class CollectAndStoreTask(@Autowired override var coordinator: Coordinator) : Ta
return null return null
} }
val mapped = ProcessMapping(events).map() ?: return null val mapped = ProcessMapping(events).map() ?: return null
val collection = mapped.collection ?: return null val collection = mapped.metadata?.collection ?: mapped.collection ?: return null
val subtitlesStored = mapped.outputFiles?.subtitles?.let { val subtitlesStored = mapped.outputFiles?.subtitles?.let {
storeSubtitles(collection = collection, subtitles = it) storeSubtitles(collection = collection, subtitles = it)