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