mirror of
https://github.com/hexated/cloudstream-extensions-hexated.git
synced 2024-08-15 00:03:22 +00:00
stremioX: added custom request
This commit is contained in:
parent
1d420814bd
commit
970186e653
4 changed files with 39 additions and 14 deletions
|
@ -1,5 +1,5 @@
|
||||||
// use an integer for version numbers
|
// use an integer for version numbers
|
||||||
version = 8
|
version = 9
|
||||||
|
|
||||||
|
|
||||||
cloudstream {
|
cloudstream {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.hexated
|
package com.hexated
|
||||||
|
|
||||||
import android.util.Log
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.hexated.SubsExtractors.invokeOpenSubs
|
import com.hexated.SubsExtractors.invokeOpenSubs
|
||||||
import com.hexated.SubsExtractors.invokeWatchsomuch
|
import com.hexated.SubsExtractors.invokeWatchsomuch
|
||||||
|
@ -11,7 +10,6 @@ import com.lagradost.cloudstream3.utils.*
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
|
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
|
||||||
import org.json.JSONObject
|
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
|
|
||||||
private const val TRACKER_LIST_URL =
|
private const val TRACKER_LIST_URL =
|
||||||
|
@ -65,9 +63,9 @@ class StremioC : MainAPI() {
|
||||||
callback: (ExtractorLink) -> Unit
|
callback: (ExtractorLink) -> Unit
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val loadData = parseJson<LoadData>(data)
|
val loadData = parseJson<LoadData>(data)
|
||||||
val request = app.get("${mainUrl}/stream/${loadData.type}/${loadData.id}.json")
|
val request = request("${mainUrl}/stream/${loadData.type}/${loadData.id}.json")
|
||||||
if (request.isSuccessful) {
|
if (request.code.isSuccessful()) {
|
||||||
val res = tryParseJson<StreamsResponse>(request.text) ?: return false
|
val res = tryParseJson<StreamsResponse>(request.body.string()) ?: return false
|
||||||
res.streams.forEach { stream ->
|
res.streams.forEach { stream ->
|
||||||
stream.runCallback(subtitleCallback, callback)
|
stream.runCallback(subtitleCallback, callback)
|
||||||
}
|
}
|
||||||
|
@ -108,8 +106,9 @@ class StremioC : MainAPI() {
|
||||||
AcraApplication.getKey<Array<CustomSite>>(USER_PROVIDER_API)?.toMutableList()
|
AcraApplication.getKey<Array<CustomSite>>(USER_PROVIDER_API)?.toMutableList()
|
||||||
?: mutableListOf()
|
?: mutableListOf()
|
||||||
sites.filter { it.parentJavaClass == "StremioX" }.apmap { site ->
|
sites.filter { it.parentJavaClass == "StremioX" }.apmap { site ->
|
||||||
|
val request = request("${site.url.fixSourceUrl()}/stream/${type}/${id}.json").body.string()
|
||||||
val res =
|
val res =
|
||||||
tryParseJson<StreamsResponse>(app.get("${site.url.fixSourceUrl()}/stream/${type}/${id}.json").text)
|
tryParseJson<StreamsResponse>(request)
|
||||||
?: return@apmap
|
?: return@apmap
|
||||||
res.streams.forEach { stream ->
|
res.streams.forEach { stream ->
|
||||||
stream.runCallback(subtitleCallback, callback)
|
stream.runCallback(subtitleCallback, callback)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.hexated
|
package com.hexated
|
||||||
|
|
||||||
import android.util.Log
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.hexated.SubsExtractors.invokeOpenSubs
|
import com.hexated.SubsExtractors.invokeOpenSubs
|
||||||
import com.hexated.SubsExtractors.invokeWatchsomuch
|
import com.hexated.SubsExtractors.invokeWatchsomuch
|
||||||
|
@ -9,7 +8,6 @@ import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer
|
||||||
import com.lagradost.cloudstream3.utils.*
|
import com.lagradost.cloudstream3.utils.*
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
||||||
import org.json.JSONObject
|
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
@ -26,8 +24,6 @@ open class StremioX : MainAPI() {
|
||||||
companion object {
|
companion object {
|
||||||
const val TRACKER_LIST_URL =
|
const val TRACKER_LIST_URL =
|
||||||
"https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_best.txt"
|
"https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_best.txt"
|
||||||
const val openSubAPI = "https://opensubtitles.strem.io/stremio/v1"
|
|
||||||
const val watchSomuchAPI = "https://watchsomuch.tv"
|
|
||||||
private const val tmdbAPI = "https://api.themoviedb.org/3"
|
private const val tmdbAPI = "https://api.themoviedb.org/3"
|
||||||
private val apiKey =
|
private val apiKey =
|
||||||
base64DecodeAPI("ZTM=NTg=MjM=MjM=ODc=MzI=OGQ=MmE=Nzk=Nzk=ZjI=NTA=NDY=NDA=MzA=YjA=") // PLEASE DON'T STEAL
|
base64DecodeAPI("ZTM=NTg=MjM=MjM=ODc=MzI=OGQ=MmE=Nzk=Nzk=ZjI=NTA=NDY=NDA=MzA=YjA=") // PLEASE DON'T STEAL
|
||||||
|
@ -241,7 +237,7 @@ open class StremioX : MainAPI() {
|
||||||
} else {
|
} else {
|
||||||
"$fixMainUrl/stream/series/$imdbId:$season:$episode.json"
|
"$fixMainUrl/stream/series/$imdbId:$season:$episode.json"
|
||||||
}
|
}
|
||||||
val res = AppUtils.tryParseJson<StreamsResponse>(app.get(url).text) ?: return
|
val res = AppUtils.tryParseJson<StreamsResponse>(request(url).body.string()) ?: return
|
||||||
res.streams.forEach { stream ->
|
res.streams.forEach { stream ->
|
||||||
stream.runCallback(subtitleCallback, callback)
|
stream.runCallback(subtitleCallback, callback)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,40 @@
|
||||||
package com.hexated
|
package com.hexated
|
||||||
|
|
||||||
fun String.fixSourceUrl() : String {
|
import com.lagradost.nicehttp.Requests.Companion.await
|
||||||
|
import okhttp3.OkHttpClient
|
||||||
|
import okhttp3.Request
|
||||||
|
import okhttp3.Response
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
|
const val defaultTimeOut = 30L
|
||||||
|
suspend fun request(
|
||||||
|
url: String,
|
||||||
|
allowRedirects: Boolean = true,
|
||||||
|
timeout: Long = defaultTimeOut
|
||||||
|
): Response {
|
||||||
|
val client = OkHttpClient().newBuilder()
|
||||||
|
.connectTimeout(timeout, TimeUnit.SECONDS)
|
||||||
|
.readTimeout(timeout, TimeUnit.SECONDS)
|
||||||
|
.writeTimeout(timeout, TimeUnit.SECONDS)
|
||||||
|
.followRedirects(allowRedirects)
|
||||||
|
.followSslRedirects(allowRedirects)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
val request: Request = Request.Builder()
|
||||||
|
.url(url)
|
||||||
|
.build()
|
||||||
|
return client.newCall(request).await()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Int.isSuccessful() : Boolean {
|
||||||
|
return this in 200..299
|
||||||
|
}
|
||||||
|
|
||||||
|
fun String.fixSourceUrl(): String {
|
||||||
return this.replace("/manifest.json", "").replace("stremio://", "https://")
|
return this.replace("/manifest.json", "").replace("stremio://", "https://")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun fixRDSourceName(name: String?, title: String?) : String {
|
fun fixRDSourceName(name: String?, title: String?): String {
|
||||||
return when {
|
return when {
|
||||||
name?.contains("[RD+]", true) == true -> "[RD+] $title"
|
name?.contains("[RD+]", true) == true -> "[RD+] $title"
|
||||||
name?.contains("[RD download]", true) == true -> "[RD] $title"
|
name?.contains("[RD download]", true) == true -> "[RD] $title"
|
||||||
|
|
Loading…
Reference in a new issue