Replacement
This commit is contained in:
parent
385b18e097
commit
d25b736aa0
@ -37,7 +37,7 @@ dependencies {
|
||||
implementation("org.json:json:20210307")
|
||||
|
||||
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")
|
||||
|
||||
@ -40,13 +40,13 @@ class MetadataMapping(val events: List<PersistentMessage>) {
|
||||
return if (meta != null || videoInfo != null) {
|
||||
|
||||
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,
|
||||
cover = mediaCover,
|
||||
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(),
|
||||
genres = meta?.data?.genres ?: emptyList(),
|
||||
titles = meta?.data?.altTitle ?: emptyList()
|
||||
titles = (meta?.data?.altTitle ?: emptyList()) + listOfNotNull(videoInfo?.title, baseInfo?.title)
|
||||
)
|
||||
} else null
|
||||
}
|
||||
|
||||
@ -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.withTransaction
|
||||
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.contract.reader.MetadataDto
|
||||
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 java.io.File
|
||||
import java.sql.SQLIntegrityConstraintViolationException
|
||||
import java.text.Normalizer
|
||||
|
||||
@Service
|
||||
class CollectAndStoreTask(@Autowired override var coordinator: Coordinator) : TaskCreator(coordinator) {
|
||||
@ -72,7 +74,7 @@ class CollectAndStoreTask(@Autowired override var coordinator: Coordinator) : Ta
|
||||
|
||||
mapped.metadata?.let {
|
||||
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)
|
||||
@ -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()) {
|
||||
titles.insertIgnore {
|
||||
it[titles.collection] = collection
|
||||
it[titles.title] = usedTitle
|
||||
it[titles.masterTitle] = usedTitle
|
||||
it[titles.title] = NameHelper.normalize(usedTitle)
|
||||
it[titles.type] = 1
|
||||
}
|
||||
contentTitles.forEach { title ->
|
||||
titles.insertIgnore {
|
||||
it[titles.collection] = collection
|
||||
it[titles.masterTitle] = usedTitle
|
||||
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? {
|
||||
val precreatedCatalogQuery = CatalogQuery(
|
||||
title = metadata.title,
|
||||
title = NameHelper.normalize(metadata.title),
|
||||
cover = metadata.cover?.cover,
|
||||
type = metadata.type,
|
||||
collection = metadata.collection,
|
||||
|
||||
@ -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 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
|
||||
return if (coverUrl.isNullOrBlank()) {
|
||||
log.warn { "No cover available for ${baseInfo.title}" }
|
||||
|
||||
@ -102,10 +102,8 @@ class MetadataAndBaseInfoToFileOut(@Autowired override var coordinator: Coordina
|
||||
|
||||
fun getTitlesFromMetadata(): List<String> {
|
||||
val titles: MutableList<String> = mutableListOf()
|
||||
metadata?.data?.let { md -> {
|
||||
titles.add(md.title)
|
||||
titles.addAll(md.altTitle)
|
||||
} }
|
||||
metadata?.data?.title?.let { titles.add(it) }
|
||||
metadata?.data?.altTitle?.let { titles.addAll(it) }
|
||||
return titles
|
||||
}
|
||||
fun getExistingCollections() =
|
||||
|
||||
Loading…
Reference in New Issue
Block a user