stremioX: fix source name

This commit is contained in:
hexated 2023-04-15 21:15:39 +07:00
parent f5612b146b
commit 99f2d9d67d
3 changed files with 25 additions and 28 deletions

View file

@ -1,5 +1,5 @@
// use an integer for version numbers // use an integer for version numbers
version = 7 version = 8
cloudstream { cloudstream {

View file

@ -69,7 +69,7 @@ class StremioC : MainAPI() {
if (request.isSuccessful) { if (request.isSuccessful) {
val res = tryParseJson<StreamsResponse>(request.text) ?: return false val res = tryParseJson<StreamsResponse>(request.text) ?: return false
res.streams.forEach { stream -> res.streams.forEach { stream ->
stream.runCallback(this, subtitleCallback, callback) stream.runCallback(subtitleCallback, callback)
} }
} else { } else {
argamap( argamap(
@ -112,7 +112,7 @@ class StremioC : MainAPI() {
tryParseJson<StreamsResponse>(app.get("${site.url.fixSourceUrl()}/stream/${type}/${id}.json").text) tryParseJson<StreamsResponse>(app.get("${site.url.fixSourceUrl()}/stream/${type}/${id}.json").text)
?: return@apmap ?: return@apmap
res.streams.forEach { stream -> res.streams.forEach { stream ->
stream.runCallback(this, subtitleCallback, callback) stream.runCallback(subtitleCallback, callback)
} }
} }
} }
@ -283,6 +283,13 @@ class StremioC : MainAPI() {
val id: String?, val id: String?,
) )
private data class ProxyHeaders(
val request: Map<String,String>?,
)
private data class BehaviorHints(
val proxyHeaders: ProxyHeaders?,
)
private data class Stream( private data class Stream(
val name: String?, val name: String?,
val title: String?, val title: String?,
@ -290,34 +297,24 @@ class StremioC : MainAPI() {
val description: String?, val description: String?,
val ytId: String?, val ytId: String?,
val externalUrl: String?, val externalUrl: String?,
val behaviorHints: JSONObject?, val behaviorHints: BehaviorHints?,
val infoHash: String?, val infoHash: String?,
val sources: List<String> = emptyList(), val sources: List<String> = emptyList(),
val subtitles: List<Subtitle> = emptyList() val subtitles: List<Subtitle> = emptyList()
) { ) {
suspend fun runCallback( suspend fun runCallback(
provider: StremioC,
subtitleCallback: (SubtitleFile) -> Unit, subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit callback: (ExtractorLink) -> Unit
) { ) {
if (url != null) { if (url != null) {
var referer: String? = null
try {
val headers = ((behaviorHints?.get("proxyHeaders") as? JSONObject)
?.get("request") as? JSONObject)
referer =
headers?.get("referer") as? String ?: headers?.get("origin") as? String
} catch (ex: Throwable) {
Log.e("Stremio", Log.getStackTraceString(ex))
}
callback.invoke( callback.invoke(
ExtractorLink( ExtractorLink(
name ?: "", name ?: "",
title ?: name ?: "", fixRDSourceName(name, title),
url, url,
if (provider.mainUrl.contains("kisskh")) "https://kisskh.me/" else referer "",
?: "",
getQualityFromName(description), getQualityFromName(description),
headers = behaviorHints?.proxyHeaders?.request ?: mapOf(),
isM3u8 = URI(url).path.endsWith(".m3u8") isM3u8 = URI(url).path.endsWith(".m3u8")
) )
) )

View file

@ -254,6 +254,14 @@ open class StremioX : MainAPI() {
val id: String?, val id: String?,
) )
private data class ProxyHeaders(
val request: Map<String,String>?,
)
private data class BehaviorHints(
val proxyHeaders: ProxyHeaders?,
)
private data class Stream( private data class Stream(
val name: String?, val name: String?,
val title: String?, val title: String?,
@ -261,7 +269,7 @@ open class StremioX : MainAPI() {
val description: String?, val description: String?,
val ytId: String?, val ytId: String?,
val externalUrl: String?, val externalUrl: String?,
val behaviorHints: JSONObject?, val behaviorHints: BehaviorHints?,
val infoHash: String?, val infoHash: String?,
val sources: List<String> = emptyList(), val sources: List<String> = emptyList(),
val subtitles: List<Subtitle> = emptyList() val subtitles: List<Subtitle> = emptyList()
@ -271,22 +279,14 @@ open class StremioX : MainAPI() {
callback: (ExtractorLink) -> Unit callback: (ExtractorLink) -> Unit
) { ) {
if (url != null) { if (url != null) {
var referer: String? = null
try {
val headers = ((behaviorHints?.get("proxyHeaders") as? JSONObject)
?.get("request") as? JSONObject)
referer =
headers?.get("referer") as? String ?: headers?.get("origin") as? String
} catch (ex: Throwable) {
Log.e("Stremio", Log.getStackTraceString(ex))
}
callback.invoke( callback.invoke(
ExtractorLink( ExtractorLink(
name ?: "", name ?: "",
fixRDSourceName(name, title), fixRDSourceName(name, title),
url, url,
referer ?: "", "",
getQualityFromName(description), getQualityFromName(description),
headers = behaviorHints?.proxyHeaders?.request ?: mapOf(),
isM3u8 = URI(url).path.endsWith(".m3u8") isM3u8 = URI(url).path.endsWith(".m3u8")
) )
) )