mirror of
https://github.com/hexated/cloudstream-extensions-hexated.git
synced 2024-08-15 00:03:22 +00:00
fix Samehadaku
This commit is contained in:
parent
0740da3b1a
commit
fd5d4afc22
2 changed files with 67 additions and 63 deletions
|
@ -1,5 +1,5 @@
|
|||
// use an integer for version numbers
|
||||
version = 19
|
||||
version = 20
|
||||
|
||||
|
||||
cloudstream {
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.lagradost.cloudstream3.*
|
|||
import com.lagradost.cloudstream3.LoadResponse.Companion.addAniListId
|
||||
import com.lagradost.cloudstream3.LoadResponse.Companion.addMalId
|
||||
import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer
|
||||
import com.lagradost.cloudstream3.network.CloudflareKiller
|
||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||
import com.lagradost.cloudstream3.utils.Qualities
|
||||
import com.lagradost.cloudstream3.utils.loadExtractor
|
||||
|
@ -16,11 +17,11 @@ class Samehadaku : MainAPI() {
|
|||
override var lang = "id"
|
||||
override val hasDownloadSupport = true
|
||||
override val supportedTypes = setOf(
|
||||
TvType.Anime,
|
||||
TvType.AnimeMovie,
|
||||
TvType.OVA
|
||||
TvType.Anime,
|
||||
TvType.AnimeMovie,
|
||||
TvType.OVA
|
||||
)
|
||||
|
||||
private val interceptor = CloudflareKiller()
|
||||
companion object {
|
||||
const val acefile = "https://acefile.co"
|
||||
|
||||
|
@ -40,18 +41,18 @@ class Samehadaku : MainAPI() {
|
|||
}
|
||||
|
||||
override val mainPage = mainPageOf(
|
||||
"$mainUrl/page/" to "Episode Terbaru",
|
||||
"$mainUrl/" to "HomePage",
|
||||
"$mainUrl/page/" to "Episode Terbaru",
|
||||
"$mainUrl/" to "HomePage",
|
||||
)
|
||||
|
||||
override suspend fun getMainPage(
|
||||
page: Int,
|
||||
request: MainPageRequest
|
||||
page: Int,
|
||||
request: MainPageRequest
|
||||
): HomePageResponse {
|
||||
val items = mutableListOf<HomePageList>()
|
||||
|
||||
if (request.name != "Episode Terbaru" && page <= 1) {
|
||||
val doc = app.get(request.data).document
|
||||
val doc = app.get(request.data, interceptor = interceptor).document
|
||||
doc.select("div.widget_senction:not(:contains(Baca Komik))").forEach { block ->
|
||||
val header = block.selectFirst("div.widget-title h3")?.ownText() ?: return@forEach
|
||||
val home = block.select("div.animepost").mapNotNull {
|
||||
|
@ -62,7 +63,7 @@ class Samehadaku : MainAPI() {
|
|||
}
|
||||
|
||||
if (request.name == "Episode Terbaru") {
|
||||
val home = app.get(request.data + page).document.selectFirst("div.post-show")?.select("ul li")
|
||||
val home = app.get(request.data + page, interceptor = interceptor).document.selectFirst("div.post-show")?.select("ul li")
|
||||
?.mapNotNull {
|
||||
it.toSearchResult()
|
||||
} ?: throw ErrorLoadingException("No Media Found")
|
||||
|
@ -75,19 +76,20 @@ class Samehadaku : MainAPI() {
|
|||
|
||||
private fun Element.toSearchResult(): AnimeSearchResponse? {
|
||||
val title = this.selectFirst("div.title, h2.entry-title a, div.lftinfo h2")?.text()?.trim()
|
||||
?: return null
|
||||
?: return null
|
||||
val href = fixUrlNull(this.selectFirst("a")?.attr("href") ?: return null)
|
||||
val posterUrl = fixUrlNull(this.select("img").attr("src"))
|
||||
val epNum = this.selectFirst("div.dtla author")?.text()?.toIntOrNull()
|
||||
return newAnimeSearchResponse(title, href ?: return null, TvType.Anime) {
|
||||
this.posterUrl = posterUrl
|
||||
addSub(epNum)
|
||||
posterHeaders = interceptor.getCookieHeaders(mainUrl).toMap()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override suspend fun search(query: String): List<SearchResponse> {
|
||||
val document = app.get("$mainUrl/?s=$query").document
|
||||
val document = app.get("$mainUrl/?s=$query", interceptor = interceptor).document
|
||||
return document.select("main#main div.animepost").mapNotNull {
|
||||
it.toSearchResult()
|
||||
}
|
||||
|
@ -97,10 +99,10 @@ class Samehadaku : MainAPI() {
|
|||
val fixUrl = if (url.contains("/anime/")) {
|
||||
url
|
||||
} else {
|
||||
app.get(url).document.selectFirst("div.nvs.nvsc a")?.attr("href")
|
||||
app.get(url, interceptor = interceptor).document.selectFirst("div.nvs.nvsc a")?.attr("href")
|
||||
}
|
||||
|
||||
val document = app.get(fixUrl ?: return null).document
|
||||
val document = app.get(fixUrl ?: return null, interceptor = interceptor).document
|
||||
val title = document.selectFirst("h1.entry-title")?.text()?.removeBloat() ?: return null
|
||||
val poster = document.selectFirst("div.thumb > img")?.attr("src")
|
||||
val tags = document.select("div.genre-info > a").map { it.text() }
|
||||
|
@ -108,11 +110,11 @@ class Samehadaku : MainAPI() {
|
|||
Regex("\\d,\\s(\\d*)").find(it)?.groupValues?.getOrNull(1)?.toIntOrNull()
|
||||
}
|
||||
val status = getStatus(
|
||||
document.selectFirst("div.spe > span:contains(Status)")?.ownText() ?: return null
|
||||
document.selectFirst("div.spe > span:contains(Status)")?.ownText() ?: return null
|
||||
)
|
||||
val type =
|
||||
getType(document.selectFirst("div.spe > span:contains(Type)")?.ownText()?.trim()?.lowercase()
|
||||
?: "tv")
|
||||
getType(document.selectFirst("div.spe > span:contains(Type)")?.ownText()?.trim()?.lowercase()
|
||||
?: "tv")
|
||||
val rating = document.selectFirst("span.ratingValue")?.text()?.trim()?.toRatingInt()
|
||||
val description = document.select("div.desc p").text().trim()
|
||||
val trailer = document.selectFirst("div.trailer-anime iframe")?.attr("src")
|
||||
|
@ -120,7 +122,7 @@ class Samehadaku : MainAPI() {
|
|||
val episodes = document.select("div.lstepsiode.listeps ul li").mapNotNull {
|
||||
val header = it.selectFirst("span.lchx > a") ?: return@mapNotNull null
|
||||
val episode = Regex("Episode\\s?(\\d+)").find(header.text())?.groupValues?.getOrNull(1)
|
||||
?.toIntOrNull()
|
||||
?.toIntOrNull()
|
||||
val link = fixUrl(header.attr("href"))
|
||||
Episode(link, episode = episode)
|
||||
}.reversed()
|
||||
|
@ -145,73 +147,75 @@ class Samehadaku : MainAPI() {
|
|||
this.recommendations = recommendations
|
||||
addMalId(tracker?.malId)
|
||||
addAniListId(tracker?.aniId?.toIntOrNull())
|
||||
posterHeaders = interceptor.getCookieHeaders(mainUrl).toMap()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override suspend fun loadLinks(
|
||||
data: String,
|
||||
isCasting: Boolean,
|
||||
subtitleCallback: (SubtitleFile) -> Unit,
|
||||
callback: (ExtractorLink) -> Unit
|
||||
data: String,
|
||||
isCasting: Boolean,
|
||||
subtitleCallback: (SubtitleFile) -> Unit,
|
||||
callback: (ExtractorLink) -> Unit
|
||||
): Boolean {
|
||||
|
||||
val document = app.get(data).document
|
||||
val document = app.get(data, interceptor = interceptor).document
|
||||
|
||||
argamap(
|
||||
{
|
||||
document.select("div#server ul li div").apmap {
|
||||
val dataPost = it.attr("data-post")
|
||||
val dataNume = it.attr("data-nume")
|
||||
val dataType = it.attr("data-type")
|
||||
{
|
||||
document.select("div#server ul li div").apmap {
|
||||
val dataPost = it.attr("data-post")
|
||||
val dataNume = it.attr("data-nume")
|
||||
val dataType = it.attr("data-type")
|
||||
|
||||
val iframe = app.post(
|
||||
url = "$mainUrl/wp-admin/admin-ajax.php",
|
||||
data = mapOf(
|
||||
"action" to "player_ajax",
|
||||
"post" to dataPost,
|
||||
"nume" to dataNume,
|
||||
"type" to dataType
|
||||
),
|
||||
referer = data,
|
||||
headers = mapOf("X-Requested-With" to "XMLHttpRequest"),
|
||||
).document.select("iframe").attr("src")
|
||||
val iframe = app.post(
|
||||
url = "$mainUrl/wp-admin/admin-ajax.php",
|
||||
data = mapOf(
|
||||
"action" to "player_ajax",
|
||||
"post" to dataPost,
|
||||
"nume" to dataNume,
|
||||
"type" to dataType
|
||||
),
|
||||
referer = data,
|
||||
headers = mapOf("X-Requested-With" to "XMLHttpRequest"),
|
||||
interceptor = interceptor
|
||||
).document.select("iframe").attr("src")
|
||||
|
||||
loadFixedExtractor(fixedIframe(iframe), it.text(), "$mainUrl/", subtitleCallback, callback)
|
||||
loadFixedExtractor(fixedIframe(iframe), it.text(), "$mainUrl/", subtitleCallback, callback)
|
||||
|
||||
}
|
||||
},
|
||||
{
|
||||
document.select("div#downloadb li").map { el ->
|
||||
el.select("a").apmap {
|
||||
loadFixedExtractor(fixedIframe(it.attr("href")), el.select("strong").text(), "$mainUrl/", subtitleCallback, callback)
|
||||
}
|
||||
},
|
||||
{
|
||||
document.select("div#downloadb li").map { el ->
|
||||
el.select("a").apmap {
|
||||
loadFixedExtractor(fixedIframe(it.attr("href")), el.select("strong").text(), "$mainUrl/", subtitleCallback, callback)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
private suspend fun loadFixedExtractor(
|
||||
url: String,
|
||||
name: String,
|
||||
referer: String? = null,
|
||||
subtitleCallback: (SubtitleFile) -> Unit,
|
||||
callback: (ExtractorLink) -> Unit
|
||||
url: String,
|
||||
name: String,
|
||||
referer: String? = null,
|
||||
subtitleCallback: (SubtitleFile) -> Unit,
|
||||
callback: (ExtractorLink) -> Unit
|
||||
) {
|
||||
loadExtractor(url, referer, subtitleCallback) { link ->
|
||||
callback.invoke(
|
||||
ExtractorLink(
|
||||
link.name,
|
||||
link.name,
|
||||
link.url,
|
||||
link.referer,
|
||||
name.fixQuality(),
|
||||
link.type,
|
||||
link.headers,
|
||||
link.extractorData
|
||||
)
|
||||
ExtractorLink(
|
||||
link.name,
|
||||
link.name,
|
||||
link.url,
|
||||
link.referer,
|
||||
name.fixQuality(),
|
||||
link.type,
|
||||
link.headers,
|
||||
link.extractorData
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue