mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-08-07 20:00:06 +00:00
adding behaviour hint parity with bingegroup
This commit is contained in:
parent
f37c37d85d
commit
0476a8e1c1
8 changed files with 103 additions and 2 deletions
|
|
@ -910,6 +910,7 @@ private fun MainAppContent(
|
|||
episodeThumbnail = route.episodeThumbnail,
|
||||
streamTitle = cached.streamName,
|
||||
streamSubtitle = null,
|
||||
bingeGroup = cached.bingeGroup,
|
||||
pauseDescription = pauseDescription,
|
||||
providerName = cached.addonName,
|
||||
providerAddonId = cached.addonId,
|
||||
|
|
@ -948,6 +949,7 @@ private fun MainAppContent(
|
|||
addonId = stream.addonId,
|
||||
filename = stream.behaviorHints.filename,
|
||||
videoSize = stream.behaviorHints.videoSize,
|
||||
bingeGroup = stream.behaviorHints.bingeGroup,
|
||||
)
|
||||
}
|
||||
val launchId = PlayerLaunchStore.put(
|
||||
|
|
@ -1024,6 +1026,7 @@ private fun MainAppContent(
|
|||
addonId = stream.addonId,
|
||||
filename = stream.behaviorHints.filename,
|
||||
videoSize = stream.behaviorHints.videoSize,
|
||||
bingeGroup = stream.behaviorHints.bingeGroup,
|
||||
)
|
||||
}
|
||||
val launchId = PlayerLaunchStore.put(
|
||||
|
|
|
|||
|
|
@ -285,7 +285,7 @@ internal object MetaDetailsParser {
|
|||
addonId = "embedded",
|
||||
behaviorHints = StreamBehaviorHints(
|
||||
bingeGroup = hintsObj?.string("bingeGroup"),
|
||||
notWebReady = hintsObj?.boolean("notWebReady") ?: false,
|
||||
notWebReady = (hintsObj?.boolean("notWebReady") ?: false) || proxyHeaders != null,
|
||||
videoSize = hintsObj?.long("videoSize"),
|
||||
filename = hintsObj?.string("filename"),
|
||||
proxyHeaders = proxyHeaders,
|
||||
|
|
|
|||
|
|
@ -524,6 +524,7 @@ fun PlayerScreen(
|
|||
addonId = stream.addonId,
|
||||
filename = stream.behaviorHints.filename,
|
||||
videoSize = stream.behaviorHints.videoSize,
|
||||
bingeGroup = stream.behaviorHints.bingeGroup,
|
||||
)
|
||||
}
|
||||
activeSourceUrl = url
|
||||
|
|
@ -578,6 +579,7 @@ fun PlayerScreen(
|
|||
addonId = stream.addonId,
|
||||
filename = stream.behaviorHints.filename,
|
||||
videoSize = stream.behaviorHints.videoSize,
|
||||
bingeGroup = stream.behaviorHints.bingeGroup,
|
||||
)
|
||||
}
|
||||
activeSourceUrl = url
|
||||
|
|
|
|||
|
|
@ -319,6 +319,7 @@ private fun PluginRuntimeResult.toStreamItem(scraper: PluginScraper): StreamItem
|
|||
com.nuvio.app.features.streams.StreamBehaviorHints()
|
||||
} else {
|
||||
com.nuvio.app.features.streams.StreamBehaviorHints(
|
||||
notWebReady = true,
|
||||
proxyHeaders = com.nuvio.app.features.streams.StreamProxyHeaders(request = requestHeaders),
|
||||
)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ data class CachedStreamLink(
|
|||
val cachedAtMs: Long,
|
||||
val filename: String? = null,
|
||||
val videoSize: Long? = null,
|
||||
val bingeGroup: String? = null,
|
||||
)
|
||||
|
||||
internal expect fun epochMs(): Long
|
||||
|
|
@ -30,6 +31,7 @@ object StreamLinkCacheRepository {
|
|||
addonId: String,
|
||||
filename: String? = null,
|
||||
videoSize: Long? = null,
|
||||
bingeGroup: String? = null,
|
||||
) {
|
||||
val entry = CachedStreamLink(
|
||||
url = url,
|
||||
|
|
@ -39,6 +41,7 @@ object StreamLinkCacheRepository {
|
|||
cachedAtMs = epochMs(),
|
||||
filename = filename,
|
||||
videoSize = videoSize,
|
||||
bingeGroup = bingeGroup,
|
||||
)
|
||||
val payload = json.encodeToString(CachedStreamLink.serializer(), entry)
|
||||
StreamLinkCacheStorage.saveEntry(hashedKey(contentKey), payload)
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ object StreamParser {
|
|||
addonId = addonId,
|
||||
behaviorHints = StreamBehaviorHints(
|
||||
bingeGroup = hintsObj?.string("bingeGroup"),
|
||||
notWebReady = hintsObj?.boolean("notWebReady") ?: false,
|
||||
notWebReady = (hintsObj?.boolean("notWebReady") ?: false) || proxyHeaders != null,
|
||||
videoSize = hintsObj?.long("videoSize"),
|
||||
filename = hintsObj?.string("filename"),
|
||||
proxyHeaders = proxyHeaders,
|
||||
|
|
|
|||
|
|
@ -521,6 +521,7 @@ private fun PluginRuntimeResult.toStreamItem(
|
|||
StreamBehaviorHints()
|
||||
} else {
|
||||
StreamBehaviorHints(
|
||||
notWebReady = true,
|
||||
proxyHeaders = StreamProxyHeaders(request = requestHeaders),
|
||||
)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -0,0 +1,91 @@
|
|||
package com.nuvio.app.features.streams
|
||||
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFalse
|
||||
import kotlin.test.assertNotNull
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class StreamParserTest {
|
||||
|
||||
@Test
|
||||
fun `parse keeps bingeGroup and explicit notWebReady`() {
|
||||
val streams = StreamParser.parse(
|
||||
payload =
|
||||
"""
|
||||
{
|
||||
"streams": [
|
||||
{
|
||||
"url": "https://example.com/video.mp4",
|
||||
"name": "1080p",
|
||||
"behaviorHints": {
|
||||
"bingeGroup": "addon-1080p",
|
||||
"notWebReady": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
""".trimIndent(),
|
||||
addonName = "Addon",
|
||||
addonId = "addon.id",
|
||||
)
|
||||
|
||||
val stream = streams.single()
|
||||
assertEquals("addon-1080p", stream.behaviorHints.bingeGroup)
|
||||
assertTrue(stream.behaviorHints.notWebReady)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `parse forces notWebReady when proxyHeaders are provided`() {
|
||||
val streams = StreamParser.parse(
|
||||
payload =
|
||||
"""
|
||||
{
|
||||
"streams": [
|
||||
{
|
||||
"url": "https://example.com/video.m3u8",
|
||||
"name": "Proxy stream",
|
||||
"behaviorHints": {
|
||||
"proxyHeaders": {
|
||||
"request": {
|
||||
"User-Agent": "Stremio"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
""".trimIndent(),
|
||||
addonName = "Addon",
|
||||
addonId = "addon.id",
|
||||
)
|
||||
|
||||
val stream = streams.single()
|
||||
assertTrue(stream.behaviorHints.notWebReady)
|
||||
val requestHeaders = stream.behaviorHints.proxyHeaders?.request
|
||||
assertNotNull(requestHeaders)
|
||||
assertEquals("Stremio", requestHeaders["User-Agent"])
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `parse keeps notWebReady false when no proxyHeaders and no hint`() {
|
||||
val streams = StreamParser.parse(
|
||||
payload =
|
||||
"""
|
||||
{
|
||||
"streams": [
|
||||
{
|
||||
"url": "https://example.com/video.mp4",
|
||||
"name": "Direct"
|
||||
}
|
||||
]
|
||||
}
|
||||
""".trimIndent(),
|
||||
addonName = "Addon",
|
||||
addonId = "addon.id",
|
||||
)
|
||||
|
||||
val stream = streams.single()
|
||||
assertFalse(stream.behaviorHints.notWebReady)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue