diff --git a/composeApp/src/commonMain/composeResources/values-cs/strings.xml b/composeApp/src/commonMain/composeResources/values-cs/strings.xml index d1c9be28..ca8498e3 100644 --- a/composeApp/src/commonMain/composeResources/values-cs/strings.xml +++ b/composeApp/src/commonMain/composeResources/values-cs/strings.xml @@ -1068,7 +1068,7 @@ Pokračovat od %1$d%% Pokračovat od %1$s VELIKOST %1$s - Torrent streamy nejsou podporovány + Tento typ streamu není podporován Zavřít trailer Trailer nelze přehrát Nepodařilo se načíst seznamy Trakt diff --git a/composeApp/src/commonMain/composeResources/values-id/strings.xml b/composeApp/src/commonMain/composeResources/values-id/strings.xml index 6f21bf11..80539baa 100644 --- a/composeApp/src/commonMain/composeResources/values-id/strings.xml +++ b/composeApp/src/commonMain/composeResources/values-id/strings.xml @@ -1100,7 +1100,7 @@ Lanjutkan dari %1$d% Lanjutkan dari %1$s UKURAN %1$s - Stream torrent tidak didukung + Jenis stream ini tidak didukung Tutup trailer Tidak dapat memutar trailer Gagal memuat daftar Trakt diff --git a/composeApp/src/commonMain/composeResources/values/strings.xml b/composeApp/src/commonMain/composeResources/values/strings.xml index d7e44118..e24d703f 100644 --- a/composeApp/src/commonMain/composeResources/values/strings.xml +++ b/composeApp/src/commonMain/composeResources/values/strings.xml @@ -575,24 +575,24 @@ Integrations Metadata enrichment controls External ratings providers - Instant cached Debrid streams - Direct Debrid - Enable Debrid streams - Show instant cached Debrid streams. - Add an API key before enabling Debrid streams. + Cloud account sources + Debrid + Enable sources + Show playable results from connected accounts. + Add an API key first. Account - Use Torbox for instant cached streams. + Connect your Torbox account. Instant Playback - Prepare instant playback - Get Torbox streams ready before you press play. - Streams to prepare - 1 stream - %d streams - Stream Formatting + Prepare links + Resolve the first sources before playback starts. + Sources to prepare + 1 source + %1$d sources + Formatting Name template - Controls how Debrid stream names appear in source lists. + Controls how source names appear. Description template - Controls the metadata lines shown under each Debrid stream. + Controls the metadata shown under each source. API key validated. Could not validate this API key. Add your MDBList API key below before turning ratings on. @@ -1129,7 +1129,7 @@ Resume from %1$d% Resume from %1$s SIZE %1$s - Torrent streams are not supported + This stream type is not supported Add a Debrid API key in Settings. This Debrid result expired. Refreshing streams. Could not resolve this Debrid stream. diff --git a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/debrid/DebridStreamFormatter.kt b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/debrid/DebridStreamFormatter.kt index 99057f3b..dd73d303 100644 --- a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/debrid/DebridStreamFormatter.kt +++ b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/debrid/DebridStreamFormatter.kt @@ -60,8 +60,8 @@ class DebridStreamFormatter( "stream.audioChannels" to parsed?.channels.orEmpty(), "stream.languages" to parsed?.languages.orEmpty(), "stream.languageEmojis" to parsed?.languages.orEmpty().map { languageEmoji(it) }, - "stream.size" to (raw?.size ?: stream.behaviorHints.videoSize), - "stream.folderSize" to raw?.folderSize, + "stream.size" to (raw?.size ?: stream.behaviorHints.videoSize)?.let(::DebridTemplateBytes), + "stream.folderSize" to raw?.folderSize?.let(::DebridTemplateBytes), "stream.encode" to parsed?.codec?.uppercase(), "stream.indexer" to (raw?.indexer ?: raw?.tracker), "stream.network" to (parsed?.network ?: raw?.network), diff --git a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/debrid/DebridStreamTemplateEngine.kt b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/debrid/DebridStreamTemplateEngine.kt index 0e3ad2c1..23e635e9 100644 --- a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/debrid/DebridStreamTemplateEngine.kt +++ b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/debrid/DebridStreamTemplateEngine.kt @@ -3,6 +3,8 @@ package com.nuvio.app.features.debrid import kotlin.math.abs import kotlin.math.roundToLong +internal data class DebridTemplateBytes(val value: Long) + class DebridStreamTemplateEngine { fun render(template: String, values: Map): String { if (template.isEmpty()) return "" @@ -299,6 +301,7 @@ class DebridStreamTemplateEngine { private fun isTruthy(value: Any?): Boolean = when (value) { is Boolean -> value + is DebridTemplateBytes -> value.value != 0L is Number -> value.toDouble() != 0.0 else -> exists(value) } @@ -313,6 +316,7 @@ class DebridStreamTemplateEngine { private fun asNumber(value: Any?): Double? = when (value) { is Number -> value.toDouble() + is DebridTemplateBytes -> value.value.toDouble() is String -> value.toDoubleOrNull() else -> null } @@ -339,6 +343,7 @@ class DebridStreamTemplateEngine { when (value) { null -> "" is Iterable<*> -> value.mapNotNull { valueToText(it).takeIf { text -> text.isNotBlank() } }.joinToString(", ") + is DebridTemplateBytes -> formatBytes(value.value.toDouble()) is Double -> if (value % 1.0 == 0.0) value.toLong().toString() else value.toString() is Float -> if (value % 1f == 0f) value.toLong().toString() else value.toString() else -> value.toString() @@ -387,4 +392,3 @@ class DebridStreamTemplateEngine { } } } - diff --git a/composeApp/src/commonTest/kotlin/com/nuvio/app/features/debrid/DebridStreamTemplateEngineTest.kt b/composeApp/src/commonTest/kotlin/com/nuvio/app/features/debrid/DebridStreamTemplateEngineTest.kt index b9fd86f9..7a670339 100644 --- a/composeApp/src/commonTest/kotlin/com/nuvio/app/features/debrid/DebridStreamTemplateEngineTest.kt +++ b/composeApp/src/commonTest/kotlin/com/nuvio/app/features/debrid/DebridStreamTemplateEngineTest.kt @@ -32,5 +32,14 @@ class DebridStreamTemplateEngineTest { assertEquals("1.5 GB DTS | Atmos", rendered) } -} + @Test + fun `renders Debrid size values as readable text while keeping numeric comparisons`() { + val rendered = engine.render( + "{stream.size::>0[\"{stream.size}\"||\"\"]}", + mapOf("stream.size" to DebridTemplateBytes(7_361_184_308L)), + ) + + assertEquals("6.9 GB", rendered) + } +}