Small tweaks
This commit is contained in:
parent
abe863f015
commit
1d8928a745
@ -136,42 +136,18 @@ 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 ->
|
||||||
|
|
||||||
getVideo(events)?.let { video ->
|
|
||||||
ContentCatalogStore.storeMedia(
|
|
||||||
title = mediaInfo.title,
|
|
||||||
collection = usableCollection,
|
|
||||||
type = mediaInfo.type,
|
|
||||||
videoDetails = video
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
val storedSubtitles = newSubtitles?.let { subtitles ->
|
|
||||||
subtitles.mapNotNull {
|
|
||||||
ContentSubtitleStore.storeSubtitles(
|
|
||||||
collection = usableCollection,
|
|
||||||
language = it.language,
|
|
||||||
destinationFile = File(it.destination)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
catalogId?.let { cid ->
|
|
||||||
mediaInfo.summaries.forEach {
|
mediaInfo.summaries.forEach {
|
||||||
ContentMetadataStore.storeSummary(cid, it)
|
ContentMetadataStore.storeSummary(cid, it)
|
||||||
}
|
}
|
||||||
@ -179,6 +155,38 @@ class CompletedTaskListener : CoordinatorEventListener() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
val newVideoPath = mover.moveVideo()
|
||||||
|
try {
|
||||||
|
getVideo(events)?.let { video ->
|
||||||
|
ContentCatalogStore.storeMedia(
|
||||||
|
title = mediaInfo.title,
|
||||||
|
collection = usableCollection,
|
||||||
|
type = mediaInfo.type,
|
||||||
|
videoDetails = video
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
|
||||||
|
val newSubtitles = mover.moveSubtitles()
|
||||||
|
|
||||||
|
try {
|
||||||
|
newSubtitles?.let { subtitles ->
|
||||||
|
subtitles.map {
|
||||||
|
ContentSubtitleStore.storeSubtitles(
|
||||||
|
collection = usableCollection,
|
||||||
|
language = it.language,
|
||||||
|
destinationFile = File(it.destination)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!doNotProduceComplete) {
|
if (!doNotProduceComplete) {
|
||||||
onProduceEvent(MediaProcessCompletedEvent(
|
onProduceEvent(MediaProcessCompletedEvent(
|
||||||
metadata = event.makeDerivedEventInfo(EventStatus.Success, getProducerName()),
|
metadata = event.makeDerivedEventInfo(EventStatus.Success, getProducerName()),
|
||||||
|
|||||||
@ -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