mirror of
https://github.com/hexated/cloudstream-extensions-hexated.git
synced 2024-08-15 00:03:22 +00:00
Fix Headers
This commit is contained in:
parent
031df9124f
commit
39706adee3
1 changed files with 2 additions and 10 deletions
|
@ -25,7 +25,6 @@ class ElOstoraTV : MainAPI() {
|
||||||
)
|
)
|
||||||
private val apiUrl = "https://z420572.radwan.shop/api/v4_8.php"
|
private val apiUrl = "https://z420572.radwan.shop/api/v4_8.php"
|
||||||
|
|
||||||
//override val mainPage = generateHomePage()
|
|
||||||
override val mainPage = generateServersHomePage()
|
override val mainPage = generateServersHomePage()
|
||||||
private fun generateServersHomePage() : List<MainPageData> {
|
private fun generateServersHomePage() : List<MainPageData> {
|
||||||
val homepage = mutableListOf<MainPageData>()
|
val homepage = mutableListOf<MainPageData>()
|
||||||
|
@ -34,31 +33,26 @@ class ElOstoraTV : MainAPI() {
|
||||||
"id" to "",
|
"id" to "",
|
||||||
)
|
)
|
||||||
val decodedBody = getDecoded(data)
|
val decodedBody = getDecoded(data)
|
||||||
//Log.d("King", "decodedBody:decodedBody")
|
|
||||||
|
|
||||||
parseJson<Categories>(decodedBody).results?.map { element ->
|
parseJson<Categories>(decodedBody).results?.map { element ->
|
||||||
homepage.add(mainPage(name = element.category_name, url = element.cid))
|
homepage.add(mainPage(name = element.category_name, url = element.cid))
|
||||||
} ?: throw ErrorLoadingException("Invalid Json response")
|
} ?: throw ErrorLoadingException("Invalid Json response")
|
||||||
//Log.d("King", "homepage:$homepage")
|
|
||||||
return homepage
|
return homepage
|
||||||
}
|
}
|
||||||
override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse {
|
override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse {
|
||||||
val items = mutableListOf<HomePageList>()
|
val items = mutableListOf<HomePageList>()
|
||||||
if (page <= 1) {
|
if (page <= 1) {
|
||||||
//Log.d("King", "getMainPage:$request")
|
|
||||||
val data = mapOf(
|
val data = mapOf(
|
||||||
"main_id" to request.data,
|
"main_id" to request.data,
|
||||||
"id" to "",
|
"id" to "",
|
||||||
"sub_id" to "0"
|
"sub_id" to "0"
|
||||||
)
|
)
|
||||||
val decodedBody = getDecoded(data)
|
val decodedBody = getDecoded(data)
|
||||||
//Log.d("King", "getMainDecodedBody:decodedBody")
|
|
||||||
val list = parseJson<Categories>(decodedBody).results?.map { element ->
|
val list = parseJson<Categories>(decodedBody).results?.map { element ->
|
||||||
element.toSearchResponse(request)
|
element.toSearchResponse(request)
|
||||||
} ?: throw ErrorLoadingException("Invalid Json response")
|
} ?: throw ErrorLoadingException("Invalid Json response")
|
||||||
if (list.isNotEmpty()) items.add(HomePageList(request.name, list, false))
|
if (list.isNotEmpty()) items.add(HomePageList(request.name, list, false))
|
||||||
}
|
}
|
||||||
//Log.d("King", "items:$items")
|
|
||||||
return newHomePageResponse(items)
|
return newHomePageResponse(items)
|
||||||
}
|
}
|
||||||
private fun Category.toSearchResponse(request: MainPageRequest): SearchResponse {
|
private fun Category.toSearchResponse(request: MainPageRequest): SearchResponse {
|
||||||
|
@ -174,7 +168,7 @@ class ElOstoraTV : MainAPI() {
|
||||||
}
|
}
|
||||||
private fun getDecoded(payload: Map<String, String>): String {
|
private fun getDecoded(payload: Map<String, String>): String {
|
||||||
|
|
||||||
val t = Calendar.getInstance().timeInMillis.toString()
|
val t = (Calendar.getInstance().timeInMillis / 1000).toString()
|
||||||
|
|
||||||
val client = app.baseClient.newBuilder()
|
val client = app.baseClient.newBuilder()
|
||||||
.build()
|
.build()
|
||||||
|
@ -183,16 +177,14 @@ class ElOstoraTV : MainAPI() {
|
||||||
method = "POST",
|
method = "POST",
|
||||||
url = apiUrl,
|
url = apiUrl,
|
||||||
headers = mapOf(
|
headers = mapOf(
|
||||||
"user-agent" to USER_AGENT,
|
"User-Agent" to "Mozilla/5.0 (Linux; U; Android 10; en; YAL-L41 Api/HUAWEIYAL-L41) AppleWebKit/534.30 (KHTML, like Gecko) Version/5.0 Mobile Safari/534.30",
|
||||||
"Time" to t,
|
"Time" to t,
|
||||||
),
|
),
|
||||||
data = payload,
|
data = payload,
|
||||||
)
|
)
|
||||||
val req = client.newCall(request).execute()
|
val req = client.newCall(request).execute()
|
||||||
|
|
||||||
return decrypt(req.body.string(), t.toCharArray())
|
return decrypt(req.body.string(), t.toCharArray())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun decrypt(str: String, key: CharArray): String {
|
private fun decrypt(str: String, key: CharArray): String {
|
||||||
val sb = java.lang.StringBuilder()
|
val sb = java.lang.StringBuilder()
|
||||||
for (i in str.indices) {
|
for (i in str.indices) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue