fix NontonAnimeID

This commit is contained in:
alex 2024-01-06 20:56:27 +07:00
parent b779e596ae
commit cc423aa098
4 changed files with 140 additions and 67 deletions

View file

@ -1,5 +1,5 @@
// use an integer for version numbers
version = 19
version = 20
cloudstream {
@ -23,5 +23,5 @@ cloudstream {
"OVA",
)
iconUrl = "https://www.google.com/s2/favicons?domain=nontonanimeid.site&sz=%size%"
iconUrl = "https://www.google.com/s2/favicons?domain=nontonanimeid.mom&sz=%size%"
}

View file

@ -0,0 +1,80 @@
package com.hexated
import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.APIHolder
import com.lagradost.cloudstream3.SubtitleFile
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.extractors.Hxfile
import com.lagradost.cloudstream3.utils.ExtractorApi
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.Qualities
open class Gdplayer : ExtractorApi() {
override val name = "Gdplayer"
override val mainUrl = "https://gdplayer.to"
override val requiresReferer = true
override suspend fun getUrl(
url: String,
referer: String?,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
) {
val res = app.get(url, referer = referer).document
val script = res.selectFirst("script:containsData(player = \"\")")?.data()
val kaken = script?.substringAfter("kaken = \"")?.substringBefore("\"")
val json = app.get(
"$mainUrl/api/?${kaken ?: return}=&_=${APIHolder.unixTimeMS}",
headers = mapOf(
"X-Requested-With" to "XMLHttpRequest"
)
).parsedSafe<Response>()
json?.sources?.map {
callback.invoke(
ExtractorLink(
this.name,
this.name,
it.file ?: return@map,
"",
getQuality(json.title)
)
)
}
}
private fun getQuality(str: String?): Int {
return Regex("(\\d{3,4})[pP]").find(str ?: "")?.groupValues?.getOrNull(1)?.toIntOrNull()
?: Qualities.Unknown.value
}
data class Response(
@JsonProperty("title") val title: String? = null,
@JsonProperty("sources") val sources: ArrayList<Sources>? = null,
) {
data class Sources(
@JsonProperty("file") val file: String? = null,
@JsonProperty("type") val type: String? = null,
)
}
}
class Nontonanimeid : Hxfile() {
override val name = "Nontonanimeid"
override val mainUrl = "https://nontonanimeid.com"
override val requiresReferer = true
}
class EmbedKotakAnimeid : Hxfile() {
override val name = "EmbedKotakAnimeid"
override val mainUrl = "https://embed2.kotakanimeid.com"
override val requiresReferer = true
}
class KotakAnimeidCom : Hxfile() {
override val name = "KotakAnimeid"
override val mainUrl = "https://kotakanimeid.com"
override val requiresReferer = true
}

View file

@ -13,7 +13,7 @@ import org.jsoup.nodes.Element
import java.net.URI
class NontonAnimeIDProvider : MainAPI() {
override var mainUrl = "https://nontonanimeid.top"
override var mainUrl = "https://nontonanimeid.mom"
override var name = "NontonAnimeID"
override val hasQuickSearch = false
override val hasMainPage = true
@ -61,7 +61,7 @@ class NontonAnimeIDProvider : MainAPI() {
private fun Element.toSearchResult(): AnimeSearchResponse {
val href = fixUrl(this.selectFirst("a")!!.attr("href"))
val title = this.selectFirst(".title")?.text() ?: ""
val posterUrl = fixUrlNull(this.selectFirst("img")?.attr("data-src"))
val posterUrl = fixUrlNull(this.selectFirst("img")?.getImageAttr())
return newAnimeSearchResponse(title, href, TvType.Anime) {
this.posterUrl = posterUrl
@ -76,7 +76,7 @@ class NontonAnimeIDProvider : MainAPI() {
return document.select(".result > ul > li").mapNotNull {
val title = it.selectFirst("h2")!!.text().trim()
val poster = it.selectFirst("img")!!.attr("src")
val poster = it.selectFirst("img")?.getImageAttr()
val tvType = getType(
it.selectFirst(".boxinfores > span.typeseries")!!.text().toString()
)
@ -101,7 +101,7 @@ class NontonAnimeIDProvider : MainAPI() {
val document = req.document
val title = document.selectFirst("h1.entry-title.cs")!!.text().removeSurrounding("Nonton Anime", "Sub Indo").trim()
val poster = document.selectFirst(".poster > img")?.attr("data-src")
val poster = document.selectFirst(".poster > img")?.getImageAttr()
val tags = document.select(".tagline > a").map { it.text() }
val year = Regex("\\d, (\\d*)").find(
@ -150,7 +150,7 @@ class NontonAnimeIDProvider : MainAPI() {
val recommendations = document.select(".result > li").mapNotNull {
val epHref = it.selectFirst("a")!!.attr("href")
val epTitle = it.selectFirst("h3")!!.text()
val epPoster = it.select(".top > img").attr("data-src")
val epPoster = it.selectFirst(".top > img")?.getImageAttr()
newAnimeSearchResponse(epTitle, epHref, TvType.Anime) {
this.posterUrl = epPoster
addDubStatus(dubExist = false, subExist = true)
@ -198,7 +198,7 @@ class NontonAnimeIDProvider : MainAPI() {
"post" to dataPost,
"nume" to dataNume,
"type" to dataType,
"nonce" to "e4dd8e45c2"
"nonce" to "8c5a2e3cb2"
),
referer = data,
headers = mapOf("X-Requested-With" to "XMLHttpRequest")
@ -215,6 +215,16 @@ class NontonAnimeIDProvider : MainAPI() {
"${it.scheme}://${it.host}"
}
}
private fun Element.getImageAttr(): String? {
return when {
this.hasAttr("data-src") -> this.attr("abs:data-src")
this.hasAttr("data-lazy-src") -> this.attr("abs:data-lazy-src")
this.hasAttr("srcset") -> this.attr("abs:srcset").substringBefore(" ")
else -> this.attr("abs:src")
}
}
private data class EpResponse(
@JsonProperty("posts") val posts: String?,
@JsonProperty("max_page") val max_page: Int?,
@ -223,21 +233,3 @@ class NontonAnimeIDProvider : MainAPI() {
)
}
class KotakAnimeid2 : Hxfile() {
override val name = "KotakAnimeid2"
override val mainUrl = "https://embed2.kotakanimeid.com"
override val requiresReferer = true
}
class KotakAnimeidCom : Hxfile() {
override val name = "KotakAnimeid"
override val mainUrl = "https://nontonanimeid.com"
override val requiresReferer = true
}
class EmbedKotakAnimeid : Hxfile() {
override val name = "EmbedKotakAnimeid"
override val mainUrl = "https://embed2.kotakanimeid.com"
override val requiresReferer = true
}

View file

@ -10,8 +10,9 @@ class NontonAnimeIDProviderPlugin: Plugin() {
override fun load(context: Context) {
// All providers should be added in this manner. Please don't edit the providers list directly.
registerMainAPI(NontonAnimeIDProvider())
registerExtractorAPI(KotakAnimeid2())
registerExtractorAPI(KotakAnimeidCom())
registerExtractorAPI(Nontonanimeid())
registerExtractorAPI(EmbedKotakAnimeid())
registerExtractorAPI(KotakAnimeidCom())
registerExtractorAPI(Gdplayer())
}
}