Logging + adjustments
This commit is contained in:
parent
3216212c43
commit
db333920a1
@ -82,8 +82,7 @@ class CompletedTaskListener : CoordinatorEventListener() {
|
||||
}
|
||||
|
||||
fun getVideo(events: List<Event>): VideoDetails? {
|
||||
val mediaInfo = events.find { it.eventType == Events.ReadOutNameAndType }
|
||||
?.az<MediaOutInformationConstructedEvent>()
|
||||
val mediaInfo = events.find { it.eventType == Events.ReadOutNameAndType }?.az<MediaOutInformationConstructedEvent>()
|
||||
val encoded = events.find { it.eventType == Events.WorkEncodePerformed }?.dataAs<EncodedData>()?.outputFile
|
||||
if (encoded == null) {
|
||||
log.warn { "No encode no video details!" }
|
||||
@ -95,7 +94,7 @@ class CompletedTaskListener : CoordinatorEventListener() {
|
||||
return null
|
||||
}
|
||||
|
||||
val details = VideoDetails(
|
||||
return VideoDetails(
|
||||
type = proper.type,
|
||||
fileName = File(encoded).name,
|
||||
serieInfo = if (proper !is EpisodeInfo) null else SerieInfo(
|
||||
@ -105,7 +104,6 @@ class CompletedTaskListener : CoordinatorEventListener() {
|
||||
title = proper.title
|
||||
)
|
||||
)
|
||||
return details
|
||||
}
|
||||
|
||||
override fun shouldIProcessAndHandleEvent(incomingEvent: Event, events: List<Event>): Boolean {
|
||||
@ -172,13 +170,14 @@ class CompletedTaskListener : CoordinatorEventListener() {
|
||||
|
||||
val videoInfo = getVideo(events)
|
||||
if (videoInfo != null) {
|
||||
assert(persistedContent.video == null)
|
||||
ContentCatalogStore.storeMedia(
|
||||
title = completedData.metadataStored.title,
|
||||
collection = completedData.metadataStored.collection,
|
||||
type = completedData.metadataStored.type,
|
||||
videoDetails = videoInfo
|
||||
)
|
||||
} else {
|
||||
log.info { "VideoInfo is null" }
|
||||
}
|
||||
|
||||
|
||||
@ -269,7 +268,7 @@ class CompletedTaskListener : CoordinatorEventListener() {
|
||||
.setPrettyPrinting()
|
||||
.create()
|
||||
|
||||
log.info { "Events in complete:\n${gson.toJson(events)}" }
|
||||
//log.info { "Events in complete:\n${gson.toJson(events)}" }
|
||||
|
||||
val metadataFound = events.find { it.eventType == Events.MetadataSearchPerformed }
|
||||
if (metadataFound == null) {
|
||||
|
||||
@ -1,23 +1,15 @@
|
||||
package no.iktdev.mediaprocessing.coordinator.tasksV2.mapping.store
|
||||
|
||||
import mu.KotlinLogging
|
||||
import no.iktdev.eventi.database.executeOrException
|
||||
import no.iktdev.eventi.database.withTransaction
|
||||
import no.iktdev.mediaprocessing.coordinator.getStoreDatabase
|
||||
import no.iktdev.mediaprocessing.shared.common.contract.reader.MetadataDto
|
||||
import no.iktdev.mediaprocessing.shared.common.contract.reader.VideoDetails
|
||||
import no.iktdev.mediaprocessing.shared.common.parsing.NameHelper
|
||||
import no.iktdev.streamit.library.db.executeWithStatus
|
||||
import no.iktdev.streamit.library.db.insertWithSuccess
|
||||
import no.iktdev.streamit.library.db.query.CatalogQuery
|
||||
import no.iktdev.streamit.library.db.query.MovieQuery
|
||||
import no.iktdev.streamit.library.db.query.SerieQuery
|
||||
import no.iktdev.streamit.library.db.tables.catalog
|
||||
import no.iktdev.streamit.library.db.tables.serie
|
||||
import no.iktdev.streamit.library.db.withTransaction
|
||||
import org.jetbrains.exposed.exceptions.ExposedSQLException
|
||||
import org.jetbrains.exposed.sql.*
|
||||
import java.sql.SQLIntegrityConstraintViolationException
|
||||
|
||||
object ContentCatalogStore {
|
||||
val log = KotlinLogging.logger {}
|
||||
@ -85,7 +77,7 @@ object ContentCatalogStore {
|
||||
} else {
|
||||
log.error { "Unable to store catalog $collection..." }
|
||||
}
|
||||
return getId(title, collection, type)
|
||||
return getId(title, type)
|
||||
}
|
||||
|
||||
private fun storeMovie(catalogId: Int, videoDetails: VideoDetails) {
|
||||
@ -148,7 +140,10 @@ object ContentCatalogStore {
|
||||
}
|
||||
|
||||
fun storeMedia(title: String, collection: String, type: String, videoDetails: VideoDetails) {
|
||||
val catalogId = getId(title, collection, type) ?: return
|
||||
val catalogId = getId(title, type) ?: run {
|
||||
log.warn { "Could not find id for $title with type $type" }
|
||||
return
|
||||
}
|
||||
log.info { "$title is identified as $type" }
|
||||
when (type) {
|
||||
"movie" -> storeMovie(catalogId, videoDetails)
|
||||
@ -160,12 +155,20 @@ object ContentCatalogStore {
|
||||
}
|
||||
}
|
||||
|
||||
fun getId(title: String, collection: String, type: String): Int? {
|
||||
return withTransaction(getStoreDatabase().database, block = {
|
||||
catalog.select { catalog.title eq title }.andWhere {
|
||||
catalog.type eq type
|
||||
}.map { it[catalog.id].value }.firstOrNull()
|
||||
})
|
||||
private fun getId(title: String, type: String): Int? {
|
||||
val ids = withTransaction(getStoreDatabase().database) {
|
||||
catalog.select {
|
||||
(catalog.title eq title)
|
||||
.and(catalog.type eq type)
|
||||
}.map { it[catalog.id].value }
|
||||
} ?: run {
|
||||
log.warn { "No values found on $title with type $type" }
|
||||
return null
|
||||
}
|
||||
if (ids.size > 1) {
|
||||
log.info { "Found ids: ${ids.joinToString(",")}" }
|
||||
}
|
||||
return ids.firstOrNull()
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user