Replacement

This commit is contained in:
bskjon 2024-04-16 01:01:45 +02:00
parent 385b18e097
commit d25b736aa0
5 changed files with 15 additions and 14 deletions

View File

@ -37,7 +37,7 @@ dependencies {
implementation("org.json:json:20210307") implementation("org.json:json:20210307")
implementation("no.iktdev:exfl:0.0.13-SNAPSHOT") implementation("no.iktdev:exfl:0.0.13-SNAPSHOT")
implementation("no.iktdev.streamit.library:streamit-library-db:0.0.6-alpha25") implementation("no.iktdev.streamit.library:streamit-library-db:0.0.6-alpha26")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1")

View File

@ -40,13 +40,13 @@ class MetadataMapping(val events: List<PersistentMessage>) {
return if (meta != null || videoInfo != null) { return if (meta != null || videoInfo != null) {
MetadataDto( MetadataDto(
title = videoInfo?.title ?: meta?.data?.title ?: baseInfo?.title ?: return null, title = videoInfo?.title ?: baseInfo?.title ?: meta?.data?.title ?: return null,
collection = collection ?: return null, collection = collection ?: return null,
cover = mediaCover, cover = mediaCover,
type = meta?.data?.type ?: videoInfo?.type ?: return null, type = meta?.data?.type ?: videoInfo?.type ?: return null,
summary = meta?.data?.summary?.filter {it.summary != null }?.map { SummaryInfo(language = it.language, summary = it.summary!! ) } ?: emptyList(), summary = meta?.data?.summary?.filter {it.summary != null }?.map { SummaryInfo(language = it.language, summary = it.summary!! ) } ?: emptyList(),
genres = meta?.data?.genres ?: emptyList(), genres = meta?.data?.genres ?: emptyList(),
titles = meta?.data?.altTitle ?: emptyList() titles = (meta?.data?.altTitle ?: emptyList()) + listOfNotNull(videoInfo?.title, baseInfo?.title)
) )
} else null } else null
} }

View File

@ -9,6 +9,7 @@ import no.iktdev.mediaprocessing.shared.common.datasource.executeOrException
import no.iktdev.mediaprocessing.shared.common.datasource.executeWithStatus import no.iktdev.mediaprocessing.shared.common.datasource.executeWithStatus
import no.iktdev.mediaprocessing.shared.common.datasource.withTransaction import no.iktdev.mediaprocessing.shared.common.datasource.withTransaction
import no.iktdev.mediaprocessing.shared.common.lastOrSuccessOf import no.iktdev.mediaprocessing.shared.common.lastOrSuccessOf
import no.iktdev.mediaprocessing.shared.common.parsing.NameHelper
import no.iktdev.mediaprocessing.shared.common.persistance.PersistentMessage import no.iktdev.mediaprocessing.shared.common.persistance.PersistentMessage
import no.iktdev.mediaprocessing.shared.contract.reader.MetadataDto import no.iktdev.mediaprocessing.shared.contract.reader.MetadataDto
import no.iktdev.mediaprocessing.shared.contract.reader.VideoDetails import no.iktdev.mediaprocessing.shared.contract.reader.VideoDetails
@ -26,6 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service import org.springframework.stereotype.Service
import java.io.File import java.io.File
import java.sql.SQLIntegrityConstraintViolationException import java.sql.SQLIntegrityConstraintViolationException
import java.text.Normalizer
@Service @Service
class CollectAndStoreTask(@Autowired override var coordinator: Coordinator) : TaskCreator(coordinator) { class CollectAndStoreTask(@Autowired override var coordinator: Coordinator) : TaskCreator(coordinator) {
@ -72,7 +74,7 @@ class CollectAndStoreTask(@Autowired override var coordinator: Coordinator) : Ta
mapped.metadata?.let { mapped.metadata?.let {
storeMetadata(catalogId = catalogId, metadata = it) storeMetadata(catalogId = catalogId, metadata = it)
storeTitles(collection = it.collection, it.title, contentTitles = it.titles) storeTitles(it.title, contentTitles = it.titles)
} }
return SimpleMessageData(Status.COMPLETED, derivedFromEventId = event.eventId) return SimpleMessageData(Status.COMPLETED, derivedFromEventId = event.eventId)
@ -107,15 +109,16 @@ class CollectAndStoreTask(@Autowired override var coordinator: Coordinator) : Ta
} }
} }
private fun storeTitles(collection: String, usedTitle: String, contentTitles: List<String>) { private fun storeTitles(usedTitle: String, contentTitles: List<String>) {
withTransaction(getStoreDatabase()) { withTransaction(getStoreDatabase()) {
titles.insertIgnore { titles.insertIgnore {
it[titles.collection] = collection it[titles.masterTitle] = usedTitle
it[titles.title] = usedTitle it[titles.title] = NameHelper.normalize(usedTitle)
it[titles.type] = 1
} }
contentTitles.forEach { title -> contentTitles.forEach { title ->
titles.insertIgnore { titles.insertIgnore {
it[titles.collection] = collection it[titles.masterTitle] = usedTitle
it[titles.title] = title it[titles.title] = title
} }
} }
@ -132,7 +135,7 @@ class CollectAndStoreTask(@Autowired override var coordinator: Coordinator) : Ta
private fun storeCatalog(metadata: MetadataDto, videoDetails: VideoDetails, videoFile: String, genres: String?): Int? { private fun storeCatalog(metadata: MetadataDto, videoDetails: VideoDetails, videoFile: String, genres: String?): Int? {
val precreatedCatalogQuery = CatalogQuery( val precreatedCatalogQuery = CatalogQuery(
title = metadata.title, title = NameHelper.normalize(metadata.title),
cover = metadata.cover?.cover, cover = metadata.cover?.cover,
type = metadata.type, type = metadata.type,
collection = metadata.collection, collection = metadata.collection,

View File

@ -43,7 +43,7 @@ class MetadataAndBaseInfoToCoverTask(@Autowired override var coordinator: Coordi
val fileOut = events.findLast { it.data is VideoInfoPerformed }?.data as VideoInfoPerformed? ?: return null val fileOut = events.findLast { it.data is VideoInfoPerformed }?.data as VideoInfoPerformed? ?: return null
val videoInfo = fileOut.toValueObject() val videoInfo = fileOut.toValueObject()
val coverTitle = videoInfo?.title ?: meta.data?.title ?: baseInfo.title val coverTitle = meta.data?.title ?: videoInfo?.title ?: baseInfo.title
val coverUrl = meta.data?.cover val coverUrl = meta.data?.cover
return if (coverUrl.isNullOrBlank()) { return if (coverUrl.isNullOrBlank()) {
log.warn { "No cover available for ${baseInfo.title}" } log.warn { "No cover available for ${baseInfo.title}" }

View File

@ -102,10 +102,8 @@ class MetadataAndBaseInfoToFileOut(@Autowired override var coordinator: Coordina
fun getTitlesFromMetadata(): List<String> { fun getTitlesFromMetadata(): List<String> {
val titles: MutableList<String> = mutableListOf() val titles: MutableList<String> = mutableListOf()
metadata?.data?.let { md -> { metadata?.data?.title?.let { titles.add(it) }
titles.add(md.title) metadata?.data?.altTitle?.let { titles.addAll(it) }
titles.addAll(md.altTitle)
} }
return titles return titles
} }
fun getExistingCollections() = fun getExistingCollections() =