added Cfk into Samehadaku

This commit is contained in:
hexated 2022-11-30 05:18:22 +07:00
parent 0b75e28068
commit 6f1e671b7d
2 changed files with 31 additions and 9 deletions

View file

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

View file

@ -6,8 +6,10 @@ import com.lagradost.cloudstream3.LoadResponse.Companion.addAniListId
import com.lagradost.cloudstream3.LoadResponse.Companion.addMalId import com.lagradost.cloudstream3.LoadResponse.Companion.addMalId
import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer
import com.lagradost.cloudstream3.extractors.XStreamCdn import com.lagradost.cloudstream3.extractors.XStreamCdn
import com.lagradost.cloudstream3.network.CloudflareKiller
import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.loadExtractor import com.lagradost.cloudstream3.utils.loadExtractor
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
class Samehadaku : MainAPI() { class Samehadaku : MainAPI() {
@ -46,6 +48,16 @@ class Samehadaku : MainAPI() {
"$mainUrl/" to "HomePage", "$mainUrl/" to "HomePage",
) )
private val interceptor = CloudflareKiller()
private suspend fun request(url: String, document: Document): Document {
return if(document.select("title").text() == "Just a moment...") {
app.get(url, interceptor = interceptor).document
} else {
document
}
}
override suspend fun getMainPage( override suspend fun getMainPage(
page: Int, page: Int,
request: MainPageRequest request: MainPageRequest
@ -53,8 +65,9 @@ class Samehadaku : MainAPI() {
val items = mutableListOf<HomePageList>() val items = mutableListOf<HomePageList>()
if (request.name != "Episode Terbaru" && page <= 1) { if (request.name != "Episode Terbaru" && page <= 1) {
val doc = app.get(request.data).document var document = app.get(request.data).document
doc.select("div.widget_senction").forEach { block -> document = request(request.data, document)
document.select("div.widget_senction").forEach { block ->
val header = block.selectFirst("div.widget-title h3")?.ownText() ?: return@forEach val header = block.selectFirst("div.widget-title h3")?.ownText() ?: return@forEach
val home = block.select("div.animepost").mapNotNull { val home = block.select("div.animepost").mapNotNull {
it.toSearchResult() it.toSearchResult()
@ -64,8 +77,9 @@ class Samehadaku : MainAPI() {
} }
if (request.name == "Episode Terbaru") { if (request.name == "Episode Terbaru") {
val home = var document = app.get(request.data + page).document
app.get(request.data + page).document.selectFirst("div.post-show")?.select("ul li") document = request(request.data + page, document)
val home = document.selectFirst("div.post-show")?.select("ul li")
?.mapNotNull { ?.mapNotNull {
it.toSearchResult() it.toSearchResult()
} ?: throw ErrorLoadingException("No Media Found") } ?: throw ErrorLoadingException("No Media Found")
@ -84,12 +98,15 @@ class Samehadaku : MainAPI() {
return newAnimeSearchResponse(title, href ?: return null, TvType.Anime) { return newAnimeSearchResponse(title, href ?: return null, TvType.Anime) {
this.posterUrl = posterUrl this.posterUrl = posterUrl
addSub(epNum) addSub(epNum)
posterHeaders = interceptor.getCookieHeaders(url).toMap()
} }
} }
override suspend fun search(query: String): List<SearchResponse> { override suspend fun search(query: String): List<SearchResponse> {
val document = app.get("$mainUrl/?s=$query").document val link = "$mainUrl/?s=$query"
var document = app.get(link).document
document = request(link, document)
return document.select("main#main div.animepost").mapNotNull { return document.select("main#main div.animepost").mapNotNull {
it.toSearchResult() it.toSearchResult()
} }
@ -99,10 +116,13 @@ class Samehadaku : MainAPI() {
val fixUrl = if (url.contains("/anime/")) { val fixUrl = if (url.contains("/anime/")) {
url url
} else { } else {
app.get(url).document.selectFirst("div.nvs.nvsc a")?.attr("href") var document = app.get(url).document
document = request(url, document)
document.selectFirst("div.nvs.nvsc a")?.attr("href")
} }
val document = app.get(fixUrl ?: return null).document var document = app.get(fixUrl ?: return null).document
document = request(fixUrl, document)
val title = document.selectFirst("h1.entry-title")?.text()?.removeSurrounding("Nonton", "Subtitle Indonesia")?.trim() ?: return null val title = document.selectFirst("h1.entry-title")?.text()?.removeSurrounding("Nonton", "Subtitle Indonesia")?.trim() ?: return null
val poster = document.selectFirst("div.thumb > img")?.attr("src") val poster = document.selectFirst("div.thumb > img")?.attr("src")
val tags = document.select("div.genre-info > a").map { it.text() } val tags = document.select("div.genre-info > a").map { it.text() }
@ -148,6 +168,7 @@ class Samehadaku : MainAPI() {
addTrailer(trailer) addTrailer(trailer)
this.tags = tags this.tags = tags
this.recommendations = recommendations this.recommendations = recommendations
posterHeaders = interceptor.getCookieHeaders(url).toMap()
} }
} }
@ -159,7 +180,8 @@ class Samehadaku : MainAPI() {
callback: (ExtractorLink) -> Unit callback: (ExtractorLink) -> Unit
): Boolean { ): Boolean {
val document = app.get(data).document var document = app.get(data).document
document = request(data, document)
val sources = ArrayList<String>() val sources = ArrayList<String>()
document.select("div#server ul li div").apmap { document.select("div#server ul li div").apmap {