From 3e38ebe49eb004f1c8633d0633e40060393ca06c Mon Sep 17 00:00:00 2001 From: lakshaygujjar273-cys Date: Sun, 7 Jun 2026 23:33:53 +0530 Subject: [PATCH] fix(watchhub): show platform name and block unplayable external URLs - getSourceName() now derives platform label (Amazon Prime Video, Netflix, etc.) from externalUrl host when title/name is blank - Fixes sources list showing no platform name for WatchHub entries Fixes #266 --- .../com/arflix/tv/data/api/StreamApi.kt | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/arflix/tv/data/api/StreamApi.kt b/app/src/main/kotlin/com/arflix/tv/data/api/StreamApi.kt index f10b4034..8c5eaeae 100644 --- a/app/src/main/kotlin/com/arflix/tv/data/api/StreamApi.kt +++ b/app/src/main/kotlin/com/arflix/tv/data/api/StreamApi.kt @@ -209,7 +209,27 @@ data class StremioStream( fun getSourceName(): String { val titleParts = (title ?: name ?: "").split("\n") - return titleParts.getOrNull(0)?.trim() ?: "Unknown" + val baseName = titleParts.getOrNull(0)?.trim() ?: "" + if (baseName.isNotBlank()) return baseName + val ext = externalUrl?.trim().orEmpty() + if (ext.isNotBlank()) { + return try { + val host = java.net.URI(ext).host?.removePrefix("www.") ?: "" + when { + host.contains("amazon") || host.contains("primevideo") -> "Amazon Prime Video" + host.contains("netflix") -> "Netflix" + host.contains("disneyplus") || host.contains("disney") -> "Disney+" + host.contains("hbomax") || host.contains("max.com") -> "Max" + host.contains("hulu") -> "Hulu" + host.contains("appletv") || host.contains("apple.com") -> "Apple TV+" + host.contains("paramountplus") -> "Paramount+" + host.contains("peacocktv") -> "Peacock" + host.isNotBlank() -> host.replaceFirstChar { it.uppercase() } + else -> "External Link" + } + } catch (e: Exception) { "External Link" } + } + return "Unknown" } fun getTorrentName(): String {