Updated reader

This commit is contained in:
Brage 2023-07-18 14:46:08 +02:00
parent d99b3f65f0
commit 6c5b3b88bc

View File

@ -1,5 +1,6 @@
package no.iktdev.streamit.content.reader.streams package no.iktdev.streamit.content.reader.streams
import com.google.gson.Gson
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import mu.KotlinLogging import mu.KotlinLogging
import no.iktdev.streamit.content.common.CommonConfig import no.iktdev.streamit.content.common.CommonConfig
@ -33,11 +34,16 @@ class StreamsReader {
if (data.value().status.statusType != StatusType.SUCCESS) { if (data.value().status.statusType != StatusType.SUCCESS) {
logger.info { "Ignoring event: ${data.key()} as status is not Success!" } logger.info { "Ignoring event: ${data.key()} as status is not Success!" }
return return
} else if (data.value().data !is FileWatcher.FileResult) { } else if (data.value().data !is String) {
logger.info { "Ignoring event: ${data.key()} as values is not of expected type!" } logger.info { "Ignoring event: ${data.key()} as values is not of expected type!, ${data.value().data}" }
return
}
val dataValue = try {
Gson().fromJson(data.value().data as String, FileWatcher.FileResult::class.java)
} catch (e: Exception) {
logger.info { "Ignoring event: ${data.key()} as value failed to be converted" }
return return
} }
val dataValue = data.value().data as FileWatcher.FileResult
logger.info { "Preparing Probe for ${dataValue.file}" } logger.info { "Preparing Probe for ${dataValue.file}" }
val output = mutableListOf<String>() val output = mutableListOf<String>()
val d = Daemon(executable = ReaderEnv.ffprobe, parameters = listOf("-v", "quiet", "-print_format", "json", "-show_streams", dataValue.file), daemonInterface = object: val d = Daemon(executable = ReaderEnv.ffprobe, parameters = listOf("-v", "quiet", "-print_format", "json", "-show_streams", dataValue.file), daemonInterface = object: