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
|
||||
version = 8
|
||||
version = 9
|
||||
|
||||
|
||||
cloudstream {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.hexated
|
||||
|
||||
import android.util.Log
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import com.hexated.SubsExtractors.invokeOpenSubs
|
||||
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.toJson
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
|
||||
import org.json.JSONObject
|
||||
import java.net.URI
|
||||
|
||||
private const val TRACKER_LIST_URL =
|
||||
|
@ -65,9 +63,9 @@ class StremioC : MainAPI() {
|
|||
callback: (ExtractorLink) -> Unit
|
||||
): Boolean {
|
||||
val loadData = parseJson<LoadData>(data)
|
||||
val request = app.get("${mainUrl}/stream/${loadData.type}/${loadData.id}.json")
|
||||
if (request.isSuccessful) {
|
||||
val res = tryParseJson<StreamsResponse>(request.text) ?: return false
|
||||
val request = request("${mainUrl}/stream/${loadData.type}/${loadData.id}.json")
|
||||
if (request.code.isSuccessful()) {
|
||||
val res = tryParseJson<StreamsResponse>(request.body.string()) ?: return false
|
||||
res.streams.forEach { stream ->
|
||||
stream.runCallback(subtitleCallback, callback)
|
||||
}
|
||||
|
@ -108,8 +106,9 @@ class StremioC : MainAPI() {
|
|||
AcraApplication.getKey<Array<CustomSite>>(USER_PROVIDER_API)?.toMutableList()
|
||||
?: mutableListOf()
|
||||
sites.filter { it.parentJavaClass == "StremioX" }.apmap { site ->
|
||||
val request = request("${site.url.fixSourceUrl()}/stream/${type}/${id}.json").body.string()
|
||||
val res =
|
||||
tryParseJson<StreamsResponse>(app.get("${site.url.fixSourceUrl()}/stream/${type}/${id}.json").text)
|
||||
tryParseJson<StreamsResponse>(request)
|
||||
?: return@apmap
|
||||
res.streams.forEach { stream ->
|
||||
stream.runCallback(subtitleCallback, callback)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.hexated
|
||||
|
||||
import android.util.Log
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import com.hexated.SubsExtractors.invokeOpenSubs
|
||||
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.AppUtils.parseJson
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
||||
import org.json.JSONObject
|
||||
import java.net.URI
|
||||
import java.util.ArrayList
|
||||
import kotlin.math.roundToInt
|
||||
|
@ -26,8 +24,6 @@ open class StremioX : MainAPI() {
|
|||
companion object {
|
||||
const val TRACKER_LIST_URL =
|
||||
"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 val apiKey =
|
||||
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 {
|
||||
"$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 ->
|
||||
stream.runCallback(subtitleCallback, callback)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,35 @@
|
|||
package com.hexated
|
||||
|
||||
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://")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue