Adding logging
This commit is contained in:
parent
efd4725074
commit
d2c1e8ccb7
@ -7,6 +7,7 @@ import no.iktdev.mediaprocessing.coordinator.getStoreDatabase
|
|||||||
import no.iktdev.mediaprocessing.shared.common.contract.reader.MetadataDto
|
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.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.insertWithSuccess
|
||||||
import no.iktdev.streamit.library.db.query.CatalogQuery
|
import no.iktdev.streamit.library.db.query.CatalogQuery
|
||||||
import no.iktdev.streamit.library.db.query.MovieQuery
|
import no.iktdev.streamit.library.db.query.MovieQuery
|
||||||
@ -47,14 +48,15 @@ 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().database, block = {
|
val status = executeWithStatus(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)
|
||||||
}.firstOrNull()
|
}.firstOrNull()
|
||||||
|
|
||||||
if (existingRow == null) {
|
if (existingRow == null) {
|
||||||
catalog.insertIgnore {
|
log.info { "$collection does not exist, and will be created" }
|
||||||
|
catalog.insert {
|
||||||
it[catalog.title] = title
|
it[catalog.title] = title
|
||||||
it[catalog.cover] = cover
|
it[catalog.cover] = cover
|
||||||
it[catalog.type] = type
|
it[catalog.type] = type
|
||||||
@ -78,6 +80,11 @@ object ContentCatalogStore {
|
|||||||
}, {
|
}, {
|
||||||
log.error { "Failed to store catalog $collection: ${it.message}" }
|
log.error { "Failed to store catalog $collection: ${it.message}" }
|
||||||
})
|
})
|
||||||
|
if (status) {
|
||||||
|
log.info { "$collection was successfully stored!" }
|
||||||
|
} else {
|
||||||
|
log.error { "Unable to store catalog $collection..." }
|
||||||
|
}
|
||||||
return getId(title, collection, type)
|
return getId(title, collection, type)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +93,7 @@ object ContentCatalogStore {
|
|||||||
log.error { "Movie id was not returned!" }
|
log.error { "Movie id was not returned!" }
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
withTransaction(getStoreDatabase().database, block = {
|
val status = executeWithStatus(getStoreDatabase().database, block = {
|
||||||
catalog.update({
|
catalog.update({
|
||||||
(catalog.id eq catalogId)
|
(catalog.id eq catalogId)
|
||||||
}) {
|
}) {
|
||||||
@ -95,6 +102,11 @@ object ContentCatalogStore {
|
|||||||
}, {
|
}, {
|
||||||
log.error { "Failed to store movie ${videoDetails.fileName}: ${it.message}" }
|
log.error { "Failed to store movie ${videoDetails.fileName}: ${it.message}" }
|
||||||
})
|
})
|
||||||
|
if (status) {
|
||||||
|
log.info { "${videoDetails.fileName} was successfully stored in movies!" }
|
||||||
|
} else {
|
||||||
|
log.error { "Unable to store catalog ${videoDetails.fileName} in movies..." }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun storeSerie(collection: String, videoDetails: VideoDetails) {
|
private fun storeSerie(collection: String, videoDetails: VideoDetails) {
|
||||||
@ -126,7 +138,11 @@ object ContentCatalogStore {
|
|||||||
}, { log.error { "Failed to store serie: ${it.message}" } })
|
}, { 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" }
|
||||||
|
} else {
|
||||||
|
log.info { "${videoDetails.fileName} was successfully stored in movies with fallback season 0!" }
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
log.info { "${videoDetails.fileName} was successfully stored in series!" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,6 +151,10 @@ object ContentCatalogStore {
|
|||||||
when (type) {
|
when (type) {
|
||||||
"movie" -> storeMovie(catalogId, videoDetails)
|
"movie" -> storeMovie(catalogId, videoDetails)
|
||||||
"serie" -> storeSerie(collection, videoDetails)
|
"serie" -> storeSerie(collection, videoDetails)
|
||||||
|
else -> {
|
||||||
|
log.error { "$type was provided for the function storeMedia, thus failing" }
|
||||||
|
throw RuntimeException("Illegal type provided")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -36,9 +36,11 @@ class ContentCompletionMover(val collection: String, val events: List<Event>) {
|
|||||||
}
|
}
|
||||||
val storeFile = storeFolder.using(encodedFile.name)
|
val storeFile = storeFolder.using(encodedFile.name)
|
||||||
val result = encodedFile.moveTo(storeFile) {
|
val result = encodedFile.moveTo(storeFile) {
|
||||||
|
|
||||||
}
|
}
|
||||||
return if (result) Pair(encodedFile.absolutePath, storeFile.absolutePath) else throw RuntimeException("Unable to movie file ${encodedFile.absolutePath} to ${storeFile.absolutePath}")
|
return if (result) run {
|
||||||
|
log.info { "Moved ${encodedFile.absolutePath} to ${storeFile.absolutePath} for permanent storage and usage" }
|
||||||
|
Pair(encodedFile.absolutePath, storeFile.absolutePath)
|
||||||
|
} else throw RuntimeException("Unable to movie file ${encodedFile.absolutePath} to ${storeFile.absolutePath}")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun moveCover(): Pair<String, String>? {
|
fun moveCover(): Pair<String, String>? {
|
||||||
@ -56,7 +58,10 @@ class ContentCompletionMover(val collection: String, val events: List<Event>) {
|
|||||||
return Pair(coverFile.absolutePath, storeFile.absolutePath)
|
return Pair(coverFile.absolutePath, storeFile.absolutePath)
|
||||||
}
|
}
|
||||||
val result = coverFile.moveTo(storeFile)
|
val result = coverFile.moveTo(storeFile)
|
||||||
return if (result) Pair(coverFile.absolutePath, storeFile.absolutePath) else null
|
return if (result) {
|
||||||
|
log.info { "Moved ${coverFile.absolutePath} to ${storeFile.absolutePath} for permanent storage and usage" }
|
||||||
|
Pair(coverFile.absolutePath, storeFile.absolutePath)
|
||||||
|
} else null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -115,6 +120,7 @@ class ContentCompletionMover(val collection: String, val events: List<Event>) {
|
|||||||
val storeFile = languageFolder.using("${movable.storeFileName}.${movable.cachedFile.extension}")
|
val storeFile = languageFolder.using("${movable.storeFileName}.${movable.cachedFile.extension}")
|
||||||
val success = movable.cachedFile.moveTo(storeFile)
|
val success = movable.cachedFile.moveTo(storeFile)
|
||||||
if (success) {
|
if (success) {
|
||||||
|
log.info { "Moved ${movable.cachedFile.absolutePath} to ${storeFile.absolutePath} for permanent storage and usage" }
|
||||||
moved.add(MovedSubtitle(movable.language, movable.cachedFile.absolutePath, storeFile.absolutePath))
|
moved.add(MovedSubtitle(movable.language, movable.cachedFile.absolutePath, storeFile.absolutePath))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user