Small tweaks
This commit is contained in:
parent
abe863f015
commit
1d8928a745
@ -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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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>? {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user