Small tweaks

This commit is contained in:
bskjon 2025-01-06 01:17:49 +01:00
parent abe863f015
commit 1d8928a745
2 changed files with 37 additions and 29 deletions

View File

@ -136,21 +136,28 @@ class CompletedTaskListener : CoordinatorEventListener() {
} else mediaInfo.fallbackCollection
val mover = ContentCompletionMover(usableCollection, events)
val newVideoPath = mover.moveVideo()
val newCoverPath = mover.moveCover()
val newSubtitles = mover.moveSubtitles()
val genreIdsForCatalog = ContentGenresStore.storeAndGetIds(mediaInfo.genres)
val newCoverPath = mover.moveCover()
val catalogId = ContentCatalogStore.storeCatalog(
ContentCatalogStore.storeCatalog(
title = mediaInfo.title,
collection = usableCollection,
type = mediaInfo.type,
cover = newCoverPath?.second?.let { dp -> File(dp).name },
genres = genreIdsForCatalog,
)
)?.also { cid ->
mediaInfo.summaries.forEach {
ContentMetadataStore.storeSummary(cid, it)
}
ContentTitleStore.store(mediaInfo.title, mediaInfo.titles)
}
val newVideoPath = mover.moveVideo()
try {
getVideo(events)?.let { video ->
ContentCatalogStore.storeMedia(
title = mediaInfo.title,
@ -159,10 +166,15 @@ class CompletedTaskListener : CoordinatorEventListener() {
videoDetails = video
)
}
} catch (e: Exception) {
e.printStackTrace()
}
val newSubtitles = mover.moveSubtitles()
val storedSubtitles = newSubtitles?.let { subtitles ->
subtitles.mapNotNull {
try {
newSubtitles?.let { subtitles ->
subtitles.map {
ContentSubtitleStore.storeSubtitles(
collection = usableCollection,
language = it.language,
@ -170,12 +182,8 @@ class CompletedTaskListener : CoordinatorEventListener() {
)
}
}
catalogId?.let { cid ->
mediaInfo.summaries.forEach {
ContentMetadataStore.storeSummary(cid, it)
}
ContentTitleStore.store(mediaInfo.title, mediaInfo.titles)
} catch (e: Exception) {
e.printStackTrace()
}

View File

@ -38,7 +38,7 @@ class ContentCompletionMover(val collection: String, val events: List<Event>) {
val result = encodedFile.moveTo(storeFile) {
}
return if (result) Pair(encodedFile.absolutePath, storeFile.absolutePath) else null
return if (result) Pair(encodedFile.absolutePath, storeFile.absolutePath) else throw RuntimeException("Unable to movie file ${encodedFile.absolutePath} to ${storeFile.absolutePath}")
}
fun moveCover(): Pair<String, String>? {