Handle addons that can return both infoHash and url
This commit is contained in:
parent
73260730e5
commit
9d1c5858e7
2 changed files with 15 additions and 6 deletions
|
|
@ -28,9 +28,11 @@ data class Stream(
|
|||
fun getStreamUrl(): String? = url ?: externalUrl
|
||||
|
||||
/**
|
||||
* Returns true if this is a torrent stream
|
||||
* Returns true if this is a torrent-only stream (no HTTP URL available).
|
||||
* When both infoHash and url are present (e.g. debrid cached torrents),
|
||||
* the HTTP url is preferred and this returns false.
|
||||
*/
|
||||
fun isTorrent(): Boolean = infoHash != null
|
||||
fun isTorrent(): Boolean = infoHash != null && url.isNullOrBlank()
|
||||
|
||||
/**
|
||||
* Returns true if this is a YouTube stream
|
||||
|
|
|
|||
|
|
@ -461,6 +461,11 @@ fun NuvioNavHost(
|
|||
onStreamSelected = { playbackInfo ->
|
||||
val streamUrl = playbackInfo.url
|
||||
?: if (playbackInfo.isTorrent) "torrent://${playbackInfo.infoHash}" else null
|
||||
// When both url and infoHash are present (debrid cached torrent),
|
||||
// prefer the HTTP url and don't pass infoHash — avoids starting
|
||||
// TorrServer for a stream that's already available via HTTP.
|
||||
val effectiveInfoHash = if (playbackInfo.url != null) null else playbackInfo.infoHash
|
||||
val effectiveFileIdx = if (playbackInfo.url != null) null else playbackInfo.fileIdx
|
||||
streamUrl?.let { url ->
|
||||
navController.navigate(
|
||||
Screen.Player.createRoute(
|
||||
|
|
@ -490,8 +495,8 @@ fun NuvioNavHost(
|
|||
addonName = playbackInfo.addonName,
|
||||
addonLogo = playbackInfo.addonLogo,
|
||||
streamDescription = playbackInfo.streamDescription,
|
||||
infoHash = playbackInfo.infoHash,
|
||||
fileIdx = playbackInfo.fileIdx,
|
||||
infoHash = effectiveInfoHash,
|
||||
fileIdx = effectiveFileIdx,
|
||||
sources = playbackInfo.sources,
|
||||
contentLanguage = playbackInfo.contentLanguage
|
||||
)
|
||||
|
|
@ -501,6 +506,8 @@ fun NuvioNavHost(
|
|||
onAutoPlayResolved = { playbackInfo ->
|
||||
val autoPlayUrl = playbackInfo.url
|
||||
?: if (playbackInfo.isTorrent) "torrent://${playbackInfo.infoHash}" else null
|
||||
val effectiveInfoHash = if (playbackInfo.url != null) null else playbackInfo.infoHash
|
||||
val effectiveFileIdx = if (playbackInfo.url != null) null else playbackInfo.fileIdx
|
||||
autoPlayUrl?.let { url ->
|
||||
navController.navigate(
|
||||
Screen.Player.createRoute(
|
||||
|
|
@ -530,8 +537,8 @@ fun NuvioNavHost(
|
|||
addonName = playbackInfo.addonName,
|
||||
addonLogo = playbackInfo.addonLogo,
|
||||
streamDescription = playbackInfo.streamDescription,
|
||||
infoHash = playbackInfo.infoHash,
|
||||
fileIdx = playbackInfo.fileIdx,
|
||||
infoHash = effectiveInfoHash,
|
||||
fileIdx = effectiveFileIdx,
|
||||
sources = playbackInfo.sources,
|
||||
contentLanguage = playbackInfo.contentLanguage
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue