From 80800dc8ba2b0be7f247db51687093a7a16e261e Mon Sep 17 00:00:00 2001 From: CakesTwix Date: Sun, 19 Feb 2023 10:26:26 +0200 Subject: [PATCH] Anitubeinua: Parse main and impl. load --- .../com/lagradost/AnitubeinuaProvider.kt | 105 +++++++----------- 1 file changed, 39 insertions(+), 66 deletions(-) diff --git a/AnitubeinuaProvider/src/main/kotlin/com/lagradost/AnitubeinuaProvider.kt b/AnitubeinuaProvider/src/main/kotlin/com/lagradost/AnitubeinuaProvider.kt index 22f64ef..33b0057 100644 --- a/AnitubeinuaProvider/src/main/kotlin/com/lagradost/AnitubeinuaProvider.kt +++ b/AnitubeinuaProvider/src/main/kotlin/com/lagradost/AnitubeinuaProvider.kt @@ -1,9 +1,11 @@ package com.lagradost +import android.util.Log import com.lagradost.models.PlayerJson import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.LoadResponse.Companion.addActors import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer +import com.lagradost.cloudstream3.utils.AppUtils.toJson import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.M3u8Helper @@ -12,24 +14,20 @@ import org.jsoup.nodes.Element class AnitubeinuaProvider : MainAPI() { // Basic Info - override var mainUrl = "https://eneyida.tv" + override var mainUrl = "https://anitube.in.ua" override var name = "Anitubeinua" override val hasMainPage = true override var lang = "uk" override val hasDownloadSupport = true override val supportedTypes = setOf( - TvType.Movie, - TvType.TvSeries, + TvType.AnimeMovie, TvType.Anime, ) // Sections override val mainPage = mainPageOf( - "$mainUrl/films/page/" to "Фільми", - "$mainUrl/series/page/" to "Серіали", - "$mainUrl/anime/page/" to "Аніме", - "$mainUrl/cartoon/page/" to "Мультфільми", - "$mainUrl/cartoon-series/page/" to "Мультсеріали", + "$mainUrl/anime/page/" to "Нові", + "$mainUrl/f/sort=rating/order=desc/page/" to "Популярне", ) override suspend fun getMainPage( @@ -38,16 +36,16 @@ class AnitubeinuaProvider : MainAPI() { ): HomePageResponse { var document = app.get(request.data + page).document - val home = document.select("article.short").map { + val home = document.select(".story").map { it.toSearchResponse() } return newHomePageResponse(request.name, home) } private fun Element.toSearchResponse(): SearchResponse { - val title = this.selectFirst("a.short_title")?.text()?.trim().toString() - val href = this.selectFirst("a.short_title")?.attr("href").toString() - val posterUrl = mainUrl + this.selectFirst("a.short_img img")?.attr("data-src") + val title = this.selectFirst(".story_c h2 a")?.text()?.trim().toString() + val href = this.selectFirst(".story_c h2 a")?.attr("href").toString() + val posterUrl = mainUrl + this.selectFirst(".story_c_l span.story_post img")?.attr("src") return newMovieSearchResponse(title, href, TvType.Movie) { this.posterUrl = posterUrl @@ -73,71 +71,46 @@ class AnitubeinuaProvider : MainAPI() { // Detailed information override suspend fun load(url: String): LoadResponse { val document = app.get(url).document + + var someInfo = document.select("div.story_c_r")[1] + // Parse info - val full_info = document.select(".full_info li") - val title = document.selectFirst("div.full_header-title h1")?.text()?.trim().toString() - val poster = mainUrl + document.selectFirst(".full_content-poster img")?.attr("src") - val tags = full_info[1].select("a").map { it.text() } - val year = full_info[0].select("a").text().toIntOrNull() - val playerUrl = document.select(".tabs_b.visible iframe").attr("src") + val title = document.selectFirst(".story_c h2")?.text()?.trim().toString() + val poster = mainUrl + document.selectFirst(".story_c_left span.story_post img")?.attr("src") + val tags = someInfo.select("noindex a").html().split("\n").map { it } + val year = someInfo.select("strong:contains(Рік випуску аніме:)").next().html().toIntOrNull() - val tvType = if (tags.contains("фільм") or playerUrl.contains("/vod/")) TvType.Movie else TvType.TvSeries - val description = document.selectFirst(".full_content-desc p")?.text()?.trim() - val trailer = document.selectFirst("div#trailer_place iframe")?.attr("src").toString() - val rating = document.selectFirst(".r_kp span, .r_imdb span")?.text().toRatingInt() - val actors = full_info[4].select("a").map { it.text() } + val tvType = TvType.Anime + val description = document.selectFirst("div.my-text")?.text()?.trim() + // val author = someInfo.select("strong:contains(Студія:)").next().html() + val rating = document.selectFirst(".lexington-box > div:last-child span")?.text().toRatingInt() - val recommendations = document.select(".short.related_item").map { + val recommendations = document.select(".horizontal ul").map { it.toSearchResponse() } // Return to app - // Parse Episodes as Series - return if (tvType == TvType.TvSeries) { - var episodes: List = emptyList() - val playerRawJson = app.get(playerUrl).document.select("script").html() - .substringAfterLast("file:\'") - .substringBefore("\',") + // 12 - json with episodes + // Players, Episodes, Number of episodes + // TODO: Parse Episodes + val playerScriptJson = document.select("script")[12].html().substringAfterLast(".init(").substringBefore(");") + val playerNames = playerScriptJson.substringAfterLast("],") + val numberOfEpisodes = playerScriptJson.substringAfterLast(",") + Log.d("load-debug", playerScriptJson.substringAfterLast(",")) - tryParseJson>(playerRawJson)?.map { dubs -> // Dubs - for(season in dubs.folder){ // Seasons - for(episode in season.folder){ // Episodes - episodes = episodes.plus( - Episode( - "${season.title}, ${episode.title}, $playerUrl", - episode.title, - season.title.replace(" Сезон ","").toIntOrNull(), - episode.title.replace("Серія ","").toIntOrNull(), - episode.poster - ) - ) - } - } - } - newTvSeriesLoadResponse(title, url, TvType.TvSeries, episodes) { - this.posterUrl = poster - this.year = year - this.plot = description - this.tags = tags - this.rating = rating - addActors(actors) - this.recommendations = recommendations - addTrailer(trailer) - } - } else { // Parse as Movie. - newMovieLoadResponse(title, url, TvType.Movie, "$title, $playerUrl") { - this.posterUrl = poster - this.year = year - this.plot = description - this.tags = tags - this.rating = rating - addActors(actors) - this.recommendations = recommendations - addTrailer(trailer) - } + var episodes: List = emptyList() + + return newTvSeriesLoadResponse(title, url, tvType, episodes) { + this.posterUrl = poster + this.year = year + this.plot = description + this.tags = tags + this.rating = rating + this.recommendations = recommendations } } + // It works when I click to view the series override suspend fun loadLinks( data: String, // (Serisl) [Season, Episode, Player Url] | (Film) [Title, Player Url]