Reducing noisy logging
This commit is contained in:
parent
be7c742b30
commit
abe863f015
@ -37,7 +37,7 @@ dependencies {
|
||||
implementation("org.json:json:20210307")
|
||||
|
||||
implementation("no.iktdev:exfl:0.0.16-SNAPSHOT")
|
||||
implementation("no.iktdev.streamit.library:streamit-library-db:1.0.0-alpha12")
|
||||
implementation("no.iktdev.streamit.library:streamit-library-db:1.0.0-alpha13")
|
||||
|
||||
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1")
|
||||
|
||||
@ -13,6 +13,7 @@ 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
|
||||
@ -46,7 +47,7 @@ object ContentCatalogStore {
|
||||
}
|
||||
|
||||
fun storeCatalog(title: String, collection: String, type: String, cover: String?, genres: String?): Int? {
|
||||
withTransaction(getStoreDatabase()) {
|
||||
withTransaction(getStoreDatabase().database, block = {
|
||||
val existingRow = catalog.select {
|
||||
(catalog.collection eq collection) and
|
||||
(catalog.type eq type)
|
||||
@ -68,13 +69,15 @@ object ContentCatalogStore {
|
||||
|
||||
catalog.update({
|
||||
(catalog.id eq id) and
|
||||
(catalog.collection eq collection)
|
||||
(catalog.collection eq collection)
|
||||
}) {
|
||||
it[catalog.cover] = useCover
|
||||
it[catalog.genres] = useGenres
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
log.error { "Failed to store catalog $collection: ${it.message}" }
|
||||
})
|
||||
return getId(title, collection, type)
|
||||
}
|
||||
|
||||
@ -83,13 +86,15 @@ object ContentCatalogStore {
|
||||
log.error { "Movie id was not returned!" }
|
||||
return
|
||||
}
|
||||
withTransaction(getStoreDatabase()) {
|
||||
withTransaction(getStoreDatabase().database, block = {
|
||||
catalog.update({
|
||||
(catalog.id eq catalogId)
|
||||
}) {
|
||||
it[catalog.iid] = iid
|
||||
}
|
||||
}
|
||||
}, {
|
||||
log.error { "Failed to store movie ${videoDetails.fileName}: ${it.message}" }
|
||||
})
|
||||
}
|
||||
|
||||
private fun storeSerie(collection: String, videoDetails: VideoDetails) {
|
||||
@ -97,18 +102,20 @@ object ContentCatalogStore {
|
||||
log.error { "serieInfo in videoDetails is null!" }
|
||||
return
|
||||
}
|
||||
val status = insertWithSuccess(getStoreDatabase().database) {
|
||||
serie.insert {
|
||||
it[title] = serieInfo.episodeTitle
|
||||
it[episode] = serieInfo.episodeNumber
|
||||
it[season] = serieInfo.seasonNumber
|
||||
it[video] = videoDetails.fileName
|
||||
it[serie.collection] = collection
|
||||
}
|
||||
}
|
||||
val status = insertWithSuccess(getStoreDatabase().database, block = {
|
||||
serie.insert {
|
||||
it[title] = serieInfo.episodeTitle
|
||||
it[episode] = serieInfo.episodeNumber
|
||||
it[season] = serieInfo.seasonNumber
|
||||
it[video] = videoDetails.fileName
|
||||
it[serie.collection] = collection
|
||||
}
|
||||
}, onError = {
|
||||
log.error { "Failed to store serie ${videoDetails.fileName}: ${it.message}" }
|
||||
})
|
||||
if (!status) {
|
||||
log.error { "Failed to insert ${videoDetails.fileName} with episode: ${serieInfo.episodeNumber} and season ${serieInfo.seasonNumber}" }
|
||||
val finalStatus = insertWithSuccess(getStoreDatabase().database) {
|
||||
val finalStatus = insertWithSuccess(getStoreDatabase().database, block = {
|
||||
serie.insert {
|
||||
it[title] = serieInfo.episodeTitle
|
||||
it[episode] = serieInfo.episodeNumber
|
||||
@ -116,7 +123,7 @@ object ContentCatalogStore {
|
||||
it[video] = videoDetails.fileName
|
||||
it[serie.collection] = collection
|
||||
}
|
||||
}
|
||||
}, { log.error { "Failed to store serie: ${it.message}" } })
|
||||
if (!finalStatus) {
|
||||
log.error { "Failed to insert ${videoDetails.fileName} with fallback season 0" }
|
||||
}
|
||||
@ -132,11 +139,11 @@ object ContentCatalogStore {
|
||||
}
|
||||
|
||||
fun getId(title: String, collection: String, type: String): Int? {
|
||||
return no.iktdev.streamit.library.db.withTransaction {
|
||||
return withTransaction(getStoreDatabase().database, block = {
|
||||
catalog.select { catalog.title eq title }.andWhere {
|
||||
catalog.type eq type
|
||||
}.map { it[catalog.id].value }.firstOrNull()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,20 +1,19 @@
|
||||
package no.iktdev.mediaprocessing.coordinator.tasksV2.mapping.store
|
||||
|
||||
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.SummaryInfo
|
||||
import no.iktdev.streamit.library.db.executeOrException
|
||||
import no.iktdev.streamit.library.db.query.SummaryQuery
|
||||
|
||||
object ContentMetadataStore {
|
||||
|
||||
fun storeSummary(catalogId: Int, summaryInfo: SummaryInfo) {
|
||||
val result = executeOrException(getStoreDatabase().database) {
|
||||
val result = executeOrException(getStoreDatabase().database, block = {
|
||||
SummaryQuery(
|
||||
cid = catalogId,
|
||||
language = summaryInfo.language,
|
||||
description = summaryInfo.summary
|
||||
).insert()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -1,16 +1,18 @@
|
||||
package no.iktdev.mediaprocessing.coordinator.tasksV2.mapping.store
|
||||
|
||||
import no.iktdev.eventi.database.executeWithStatus
|
||||
import mu.KotlinLogging
|
||||
import no.iktdev.mediaprocessing.coordinator.getStoreDatabase
|
||||
import no.iktdev.streamit.library.db.executeWithStatus
|
||||
import no.iktdev.streamit.library.db.query.SubtitleQuery
|
||||
import no.iktdev.streamit.library.db.tables.subtitle
|
||||
import org.jetbrains.exposed.sql.insert
|
||||
import java.io.File
|
||||
|
||||
object ContentSubtitleStore {
|
||||
val log = KotlinLogging.logger {}
|
||||
|
||||
fun storeSubtitles(collection: String, language: String, destinationFile: File): Boolean {
|
||||
return executeWithStatus (getStoreDatabase()) {
|
||||
return executeWithStatus (getStoreDatabase().database, block = {
|
||||
subtitle.insert {
|
||||
it[this.associatedWithVideo] = destinationFile.nameWithoutExtension
|
||||
it[this.language] = language
|
||||
@ -18,7 +20,9 @@ object ContentSubtitleStore {
|
||||
it[this.format] = destinationFile.extension.uppercase()
|
||||
it[this.subtitle] = destinationFile.name
|
||||
}
|
||||
}
|
||||
}, onError = {
|
||||
log.error { "Failed to store subtitle $destinationFile: ${it.message}" }
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,9 +1,9 @@
|
||||
package no.iktdev.mediaprocessing.coordinator.tasksV2.mapping.store
|
||||
|
||||
import no.iktdev.eventi.database.withTransaction
|
||||
import no.iktdev.mediaprocessing.coordinator.getStoreDatabase
|
||||
import no.iktdev.mediaprocessing.shared.common.parsing.NameHelper
|
||||
import no.iktdev.streamit.library.db.tables.titles
|
||||
import no.iktdev.streamit.library.db.withTransaction
|
||||
import org.jetbrains.exposed.sql.insertIgnore
|
||||
import org.jetbrains.exposed.sql.or
|
||||
import org.jetbrains.exposed.sql.select
|
||||
@ -12,7 +12,7 @@ object ContentTitleStore {
|
||||
|
||||
fun store(mainTitle: String, otherTitles: List<String>) {
|
||||
try {
|
||||
withTransaction(getStoreDatabase()) {
|
||||
withTransaction(getStoreDatabase().database, block = {
|
||||
val titlesToUse = otherTitles + listOf(
|
||||
NameHelper.normalize(mainTitle)
|
||||
).filter { it != mainTitle }
|
||||
@ -23,20 +23,24 @@ object ContentTitleStore {
|
||||
it[alternativeTitle] = t
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
|
||||
})
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
fun findMasterTitles(titleList: List<String>): List<String> {
|
||||
return withTransaction(getStoreDatabase()) {
|
||||
return withTransaction(getStoreDatabase().database, block = {
|
||||
titles.select {
|
||||
(titles.alternativeTitle inList titleList) or
|
||||
(titles.masterTitle inList titleList)
|
||||
}.map {
|
||||
it[titles.masterTitle]
|
||||
}.distinctBy { it }
|
||||
} ?: emptyList()
|
||||
}, {
|
||||
|
||||
}) ?: emptyList()
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user