mirror of
https://github.com/hexated/cloudstream-extensions-hexated.git
synced 2024-08-15 00:03:22 +00:00
loklok: fix search
This commit is contained in:
parent
39df95bf96
commit
fa8fc96ab6
3 changed files with 34 additions and 30 deletions
|
@ -1,5 +1,5 @@
|
||||||
// use an integer for version numbers
|
// use an integer for version numbers
|
||||||
version = 20
|
version = 21
|
||||||
|
|
||||||
|
|
||||||
cloudstream {
|
cloudstream {
|
||||||
|
|
|
@ -96,34 +96,36 @@ class Loklok : MainAPI() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun search(query: String): List<SearchResponse> {
|
override suspend fun search(query: String): List<SearchResponse>? = quickSearch(query)
|
||||||
val res = app.get(
|
|
||||||
"$searchApi/search?keyword=$query",
|
|
||||||
).document
|
|
||||||
|
|
||||||
val script = res.select("script").find { it.data().contains("function(a,b,c,d,e") }?.data()
|
// override suspend fun search(query: String): List<SearchResponse> {
|
||||||
?.substringAfter("searchResults:[")?.substringBefore("]}],fetch")
|
// val res = app.get(
|
||||||
|
// "$searchApi/search?keyword=$query",
|
||||||
return res.select("div.search-list div.search-video-card").mapIndexed { num, block ->
|
// ).document
|
||||||
val name = block.selectFirst("h2.title")?.text()
|
//
|
||||||
val data = block.selectFirst("a")?.attr("href")?.split("/")
|
// val script = res.select("script").find { it.data().contains("function(a,b,c,d,e") }?.data()
|
||||||
val id = data?.last()
|
// ?.substringAfter("searchResults:[")?.substringBefore("]}],fetch")
|
||||||
val type = data?.get(2)?.toInt()
|
//
|
||||||
val image = Regex("coverVerticalUrl:\"(.*?)\",").findAll(script.toString())
|
// return res.select("div.search-list div.search-video-card").mapIndexed { num, block ->
|
||||||
.map { it.groupValues[1] }.toList().getOrNull(num)?.replace("\\u002F", "/")
|
// val name = block.selectFirst("h2.title")?.text()
|
||||||
|
// val data = block.selectFirst("a")?.attr("href")?.split("/")
|
||||||
|
// val id = data?.last()
|
||||||
newMovieSearchResponse(
|
// val type = data?.get(2)?.toInt()
|
||||||
"$name",
|
// val image = Regex("coverVerticalUrl:\"(.*?)\",").findAll(script.toString())
|
||||||
UrlData(id, type).toJson(),
|
// .map { it.groupValues[1] }.toList().getOrNull(num)?.replace("\\u002F", "/")
|
||||||
TvType.Movie,
|
//
|
||||||
) {
|
//
|
||||||
this.posterUrl = image
|
// newMovieSearchResponse(
|
||||||
}
|
// "$name",
|
||||||
|
// UrlData(id, type).toJson(),
|
||||||
}
|
// TvType.Movie,
|
||||||
|
// ) {
|
||||||
}
|
// this.posterUrl = image
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
override suspend fun load(url: String): LoadResponse? {
|
override suspend fun load(url: String): LoadResponse? {
|
||||||
val data = parseJson<UrlData>(url)
|
val data = parseJson<UrlData>(url)
|
||||||
|
|
|
@ -490,8 +490,10 @@ suspend fun getSoraIdAndType(title: String?, year: Int?, season: Int?) : Pair<St
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val id = script?.third?.last() ?: return null
|
val id = script?.third?.last()?.substringBefore("-") ?: return null
|
||||||
val type = script.third?.get(2) ?: return null
|
val type = script.third?.get(2)?.let {
|
||||||
|
if (it == "drama") "1" else "0"
|
||||||
|
} ?: return null
|
||||||
|
|
||||||
return id to type
|
return id to type
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue