From 832656852ab3c7fc5842f06e67119ad79122c707 Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 14 Jan 2024 19:17:36 +0700 Subject: [PATCH] fix NontonAnimeIDProvider --- NontonAnimeIDProvider/build.gradle.kts | 2 +- .../com/hexated/NontonAnimeIDProvider.kt | 103 ++++++++++-------- Samehadaku/build.gradle.kts | 2 +- .../src/main/kotlin/com/hexated/Samehadaku.kt | 17 +-- .../main/kotlin/com/hexated/SoraExtractor.kt | 2 +- 5 files changed, 64 insertions(+), 62 deletions(-) diff --git a/NontonAnimeIDProvider/build.gradle.kts b/NontonAnimeIDProvider/build.gradle.kts index 03222cbe..52dfc64e 100644 --- a/NontonAnimeIDProvider/build.gradle.kts +++ b/NontonAnimeIDProvider/build.gradle.kts @@ -1,5 +1,5 @@ // use an integer for version numbers -version = 20 +version = 21 cloudstream { diff --git a/NontonAnimeIDProvider/src/main/kotlin/com/hexated/NontonAnimeIDProvider.kt b/NontonAnimeIDProvider/src/main/kotlin/com/hexated/NontonAnimeIDProvider.kt index 0f5d6418..773fa560 100644 --- a/NontonAnimeIDProvider/src/main/kotlin/com/hexated/NontonAnimeIDProvider.kt +++ b/NontonAnimeIDProvider/src/main/kotlin/com/hexated/NontonAnimeIDProvider.kt @@ -5,7 +5,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.extractors.Hxfile +import com.lagradost.cloudstream3.utils.AppUtils import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.loadExtractor import org.jsoup.Jsoup @@ -13,7 +13,7 @@ import org.jsoup.nodes.Element import java.net.URI class NontonAnimeIDProvider : MainAPI() { - override var mainUrl = "https://nontonanimeid.mom" + override var mainUrl = "https://nontonanimeid.biz" override var name = "NontonAnimeID" override val hasQuickSearch = false override val hasMainPage = true @@ -21,16 +21,16 @@ class NontonAnimeIDProvider : MainAPI() { override val hasDownloadSupport = true override val supportedTypes = setOf( - TvType.Anime, - TvType.AnimeMovie, - TvType.OVA + TvType.Anime, + TvType.AnimeMovie, + TvType.OVA ) companion object { fun getType(t: String): TvType { return when { - t.contains("TV",true) -> TvType.Anime - t.contains("Movie",true) -> TvType.AnimeMovie + t.contains("TV", true) -> TvType.Anime + t.contains("Movie", true) -> TvType.AnimeMovie else -> TvType.OVA } } @@ -45,12 +45,12 @@ class NontonAnimeIDProvider : MainAPI() { } override val mainPage = mainPageOf( - "" to "Latest Update", - "ongoing-list/" to " Ongoing List", - "popular-series/" to "Popular Series", + "" to "Latest Update", + "ongoing-list/" to " Ongoing List", + "popular-series/" to "Popular Series", ) - override suspend fun getMainPage(page: Int, request : MainPageRequest): HomePageResponse { + override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse { val document = app.get("$mainUrl/${request.data}").document val home = document.select(".animeseries").mapNotNull { it.toSearchResult() @@ -78,7 +78,7 @@ class NontonAnimeIDProvider : MainAPI() { val title = it.selectFirst("h2")!!.text().trim() val poster = it.selectFirst("img")?.getImageAttr() val tvType = getType( - it.selectFirst(".boxinfores > span.typeseries")!!.text().toString() + it.selectFirst(".boxinfores > span.typeseries")!!.text().toString() ) val href = fixUrl(it.selectFirst("a")!!.attr("href")) @@ -100,15 +100,16 @@ class NontonAnimeIDProvider : MainAPI() { mainUrl = getBaseUrl(req.url) val document = req.document - val title = document.selectFirst("h1.entry-title.cs")!!.text().removeSurrounding("Nonton Anime", "Sub Indo").trim() + val title = document.selectFirst("h1.entry-title.cs")!!.text() + .removeSurrounding("Nonton Anime", "Sub Indo").trim() val poster = document.selectFirst(".poster > img")?.getImageAttr() val tags = document.select(".tagline > a").map { it.text() } val year = Regex("\\d, (\\d*)").find( - document.select(".bottomtitle > span:nth-child(5)").text() + document.select(".bottomtitle > span:nth-child(5)").text() )?.groupValues?.get(1)?.toIntOrNull() val status = getStatus( - document.select("span.statusseries").text().trim() + document.select("span.statusseries").text().trim() ) val type = getType(document.select("span.typeseries").text().trim().lowercase()) val rating = document.select("span.nilaiseries").text().trim().toIntOrNull() @@ -118,21 +119,21 @@ class NontonAnimeIDProvider : MainAPI() { val episodes = if (document.select("button.buttfilter").isNotEmpty()) { val id = document.select("input[name=series_id]").attr("value") val numEp = - document.selectFirst(".latestepisode > a")?.text()?.replace(Regex("\\D"), "") - .toString() + document.selectFirst(".latestepisode > a")?.text()?.replace(Regex("\\D"), "") + .toString() Jsoup.parse( - app.post( - url = "$mainUrl/wp-admin/admin-ajax.php", - data = mapOf( - "misha_number_of_results" to numEp, - "misha_order_by" to "date-DESC", - "action" to "mishafilter", - "series_id" to id - ) - ).parsed().content + app.post( + url = "$mainUrl/wp-admin/admin-ajax.php", + data = mapOf( + "misha_number_of_results" to numEp, + "misha_order_by" to "date-DESC", + "action" to "mishafilter", + "series_id" to id + ) + ).parsed().content ).select("li").map { val episode = Regex("Episode\\s?(\\d+)").find( - it.selectFirst("a")?.text().toString() + it.selectFirst("a")?.text().toString() )?.groupValues?.getOrNull(0) ?: it.selectFirst("a")?.text() val link = fixUrl(it.selectFirst("a")!!.attr("href")) Episode(link, episode = episode?.toIntOrNull()) @@ -140,7 +141,7 @@ class NontonAnimeIDProvider : MainAPI() { } else { document.select("ul.misha_posts_wrap2 > li").map { val episode = Regex("Episode\\s?(\\d+)").find( - it.selectFirst("a")?.text().toString() + it.selectFirst("a")?.text().toString() )?.groupValues?.getOrNull(0) ?: it.selectFirst("a")?.text() val link = it.select("a").attr("href") Episode(link, episode = episode?.toIntOrNull()) @@ -157,7 +158,7 @@ class NontonAnimeIDProvider : MainAPI() { } } - val tracker = APIHolder.getTracker(listOf(title),TrackerType.getTypes(type),year,true) + val tracker = APIHolder.getTracker(listOf(title), TrackerType.getTypes(type), year, true) return newAnimeLoadResponse(title, url, type) { engName = title @@ -178,33 +179,39 @@ class NontonAnimeIDProvider : MainAPI() { } 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 nonce = + document.select("script#ajax_video-js-extra").attr("src").substringAfter("base64,") + .let { + AppUtils.parseJson>(base64Decode(it).substringAfter("="))["nonce"] + } + document.select(".container1 > ul > li:not(.boxtab)").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, - "nonce" to "8c5a2e3cb2" - ), - referer = data, - headers = mapOf("X-Requested-With" to "XMLHttpRequest") + url = "$mainUrl/wp-admin/admin-ajax.php", + data = mapOf( + "action" to "player_ajax", + "post" to dataPost, + "nume" to dataNume, + "type" to dataType, + "nonce" to "$nonce" + ), + referer = data, + headers = mapOf("X-Requested-With" to "XMLHttpRequest") ).document.selectFirst("iframe")?.attr("src") - loadExtractor(iframe ?: return@apmap , "$mainUrl/", subtitleCallback, callback) + loadExtractor(iframe ?: return@apmap, "$mainUrl/", subtitleCallback, callback) } return true @@ -226,10 +233,10 @@ class NontonAnimeIDProvider : MainAPI() { } private data class EpResponse( - @JsonProperty("posts") val posts: String?, - @JsonProperty("max_page") val max_page: Int?, - @JsonProperty("found_posts") val found_posts: Int?, - @JsonProperty("content") val content: String + @JsonProperty("posts") val posts: String?, + @JsonProperty("max_page") val max_page: Int?, + @JsonProperty("found_posts") val found_posts: Int?, + @JsonProperty("content") val content: String ) } diff --git a/Samehadaku/build.gradle.kts b/Samehadaku/build.gradle.kts index e816d7c9..f1f9be79 100644 --- a/Samehadaku/build.gradle.kts +++ b/Samehadaku/build.gradle.kts @@ -1,5 +1,5 @@ // use an integer for version numbers -version = 20 +version = 21 cloudstream { diff --git a/Samehadaku/src/main/kotlin/com/hexated/Samehadaku.kt b/Samehadaku/src/main/kotlin/com/hexated/Samehadaku.kt index 144f8fd6..95770cea 100644 --- a/Samehadaku/src/main/kotlin/com/hexated/Samehadaku.kt +++ b/Samehadaku/src/main/kotlin/com/hexated/Samehadaku.kt @@ -4,7 +4,6 @@ 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 @@ -21,7 +20,6 @@ class Samehadaku : MainAPI() { TvType.AnimeMovie, TvType.OVA ) - private val interceptor by lazy { CloudflareKiller() } companion object { const val acefile = "https://acefile.co" @@ -52,7 +50,7 @@ class Samehadaku : MainAPI() { val items = mutableListOf() if (request.name != "Episode Terbaru" && page <= 1) { - val doc = app.get(request.data, interceptor = interceptor).document + val doc = app.get(request.data).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 { @@ -63,7 +61,7 @@ class Samehadaku : MainAPI() { } if (request.name == "Episode Terbaru") { - val home = app.get(request.data + page, interceptor = interceptor).document.selectFirst("div.post-show")?.select("ul li") + val home = app.get(request.data + page).document.selectFirst("div.post-show")?.select("ul li") ?.mapNotNull { it.toSearchResult() } ?: throw ErrorLoadingException("No Media Found") @@ -83,13 +81,12 @@ class Samehadaku : MainAPI() { 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 { - val document = app.get("$mainUrl/?s=$query", interceptor = interceptor).document + val document = app.get("$mainUrl/?s=$query").document return document.select("main#main div.animepost").mapNotNull { it.toSearchResult() } @@ -99,10 +96,10 @@ class Samehadaku : MainAPI() { val fixUrl = if (url.contains("/anime/")) { url } else { - app.get(url, interceptor = interceptor).document.selectFirst("div.nvs.nvsc a")?.attr("href") + app.get(url).document.selectFirst("div.nvs.nvsc a")?.attr("href") } - val document = app.get(fixUrl ?: return null, interceptor = interceptor).document + val document = app.get(fixUrl ?: return null).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() } @@ -147,7 +144,6 @@ class Samehadaku : MainAPI() { this.recommendations = recommendations addMalId(tracker?.malId) addAniListId(tracker?.aniId?.toIntOrNull()) - posterHeaders = interceptor.getCookieHeaders(mainUrl).toMap() } } @@ -159,7 +155,7 @@ class Samehadaku : MainAPI() { callback: (ExtractorLink) -> Unit ): Boolean { - val document = app.get(data, interceptor = interceptor).document + val document = app.get(data).document argamap( { @@ -178,7 +174,6 @@ class Samehadaku : MainAPI() { ), referer = data, headers = mapOf("X-Requested-With" to "XMLHttpRequest"), - interceptor = interceptor ).document.select("iframe").attr("src") loadFixedExtractor(fixedIframe(iframe), it.text(), "$mainUrl/", subtitleCallback, callback) diff --git a/SoraStream/src/main/kotlin/com/hexated/SoraExtractor.kt b/SoraStream/src/main/kotlin/com/hexated/SoraExtractor.kt index f848b653..cde6e82d 100644 --- a/SoraStream/src/main/kotlin/com/hexated/SoraExtractor.kt +++ b/SoraStream/src/main/kotlin/com/hexated/SoraExtractor.kt @@ -126,7 +126,7 @@ object SoraExtractor : SoraStream() { referer = iframedoc ).document.selectFirst("script:containsData(Playerjs)")?.data() val video = script?.substringAfter("file:\"#2")?.substringBefore("\"") - ?.replace(Regex("(//\\S+?=)"), "")?.let { base64Decode(it) } + ?.replace(Regex("/.*?=?="), "")?.let { base64Decode(it) } callback.invoke( ExtractorLink(