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

View File

@ -38,7 +38,7 @@ class ContentCompletionMover(val collection: String, val events: List<Event>) {
val result = encodedFile.moveTo(storeFile) { 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>? { fun moveCover(): Pair<String, String>? {