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