diff --git a/src/es/animelatinohd/src/eu/kanade/tachiyomi/animeextension/es/animelatinohd/AnimeLatinoHD.kt b/src/es/animelatinohd/src/eu/kanade/tachiyomi/animeextension/es/animelatinohd/AnimeLatinoHD.kt index 52494c8fc0..b2172674d8 100644 --- a/src/es/animelatinohd/src/eu/kanade/tachiyomi/animeextension/es/animelatinohd/AnimeLatinoHD.kt +++ b/src/es/animelatinohd/src/eu/kanade/tachiyomi/animeextension/es/animelatinohd/AnimeLatinoHD.kt @@ -79,35 +79,21 @@ class AnimeLatinoHD : ConfigurableAnimeSource, AnimeHttpSource() { val animeList = mutableListOf() val url = response.request.url.toString().lowercase() val hasNextPage = document.select("#__next > main > div > div[class*=\"Animes_paginate\"] a:last-child svg").any() - document.select("script").forEach { script -> - if (script.data().contains("{\"props\":{\"pageProps\":")) { - val jObject = json.decodeFromString(script.data()) - val props = jObject["props"]!!.jsonObject - val pageProps = props["pageProps"]!!.jsonObject - val data = pageProps["data"]!!.jsonObject - if (url.contains("status=1")) { - val latestData = data["data"]!!.jsonArray - latestData.forEach { item -> - val animeItem = item!!.jsonObject - val anime = SAnime.create() - anime.setUrlWithoutDomain(externalOrInternalImg("anime/${animeItem["slug"]!!.jsonPrimitive!!.content}")) - anime.thumbnail_url = "https://image.tmdb.org/t/p/w200${animeItem["poster"]!!.jsonPrimitive!!.content}" - anime.title = animeItem["name"]!!.jsonPrimitive!!.content - animeList.add(anime) - } - } else { - val popularToday = data["popular_today"]!!.jsonArray - popularToday.forEach { item -> - val animeItem = item!!.jsonObject - val anime = SAnime.create() - anime.setUrlWithoutDomain(externalOrInternalImg("anime/${animeItem["slug"]!!.jsonPrimitive!!.content}")) - anime.thumbnail_url = "https://image.tmdb.org/t/p/w200${animeItem["poster"]!!.jsonPrimitive!!.content}" - anime.title = animeItem["name"]!!.jsonPrimitive!!.content - animeList.add(anime) - } - } - } + + document.select("div.list-animes > div.animeCard").forEach { animeCard -> + val cover = animeCard.selectFirst("div.cover") + val titleElement = animeCard.selectFirst("div.info h3 a span") + val yearElement = animeCard.selectFirst("div.info p.year") + val scoreElement = animeCard.selectFirst("span.score") + + val anime = SAnime.create() + anime.title = titleElement?.text().orEmpty() + anime.setUrlWithoutDomain(cover?.selectFirst("a")?.attr("href").orEmpty()) + anime.thumbnail_url = cover?.selectFirst("img")?.attr("src").orEmpty() + + animeList.add(anime) } + return AnimesPage(animeList, hasNextPage) } @@ -118,44 +104,56 @@ class AnimeLatinoHD : ConfigurableAnimeSource, AnimeHttpSource() { override fun animeDetailsParse(response: Response): SAnime { val document = response.asJsoup() val newAnime = SAnime.create() - document.select("script").forEach { script -> - if (script.data().contains("{\"props\":{\"pageProps\":")) { - val jObject = json.decodeFromString(script.data()) - val props = jObject["props"]!!.jsonObject - val pageProps = props["pageProps"]!!.jsonObject - val data = pageProps["data"]!!.jsonObject - newAnime.title = data["name"]!!.jsonPrimitive!!.content - newAnime.genre = data["genres"]!!.jsonPrimitive!!.content.split(",").joinToString() - newAnime.description = data["overview"]!!.jsonPrimitive!!.content - newAnime.status = parseStatus(data["status"]!!.jsonPrimitive!!.content) - newAnime.thumbnail_url = "https://image.tmdb.org/t/p/w600_and_h900_bestv2${data["poster"]!!.jsonPrimitive!!.content}" - newAnime.setUrlWithoutDomain(externalOrInternalImg("anime/${data["slug"]!!.jsonPrimitive!!.content}")) + document.select("div.animePage").firstOrNull()?.let { animePage -> + // Extracción de información del banner + val banner = animePage.selectFirst("div.banner") + if (banner != null) { + newAnime.thumbnail_url = banner.attr("style").substringAfter("background-image: url(").substringBeforeLast(")") + } + + // Extracción de información de la columna + val column = animePage.selectFirst("div.column") + if (column != null) { + newAnime.title = column.selectFirst("h1")?.text() ?: "" + } + if (column != null) { + newAnime.genre = column.select("div.genres a.genre").joinToString(",") { it.text() } + } + + // Extracción de información detallada + val detailed = animePage.selectFirst("div.detailed") + if (detailed != null) { + newAnime.status = parseStatus( + detailed.selectFirst("div.item:contains(Estado) span") + ?.text() ?: "", + ) } + newAnime.description = animePage.selectFirst("div.overview p")?.text() } + return newAnime } override fun episodeListParse(response: Response): List { val document = response.asJsoup() val episodeList = mutableListOf() - document.select("script").forEach { script -> - if (script.data().contains("{\"props\":{\"pageProps\":")) { - val jObject = json.decodeFromString(script.data()) - val props = jObject["props"]!!.jsonObject - val pageProps = props["pageProps"]!!.jsonObject - val data = pageProps["data"]!!.jsonObject - val arrEpisode = data["episodes"]!!.jsonArray - arrEpisode.forEach { item -> - val animeItem = item!!.jsonObject - val episode = SEpisode.create() - episode.setUrlWithoutDomain(externalOrInternalImg("ver/${data["slug"]!!.jsonPrimitive!!.content}/${animeItem["number"]!!.jsonPrimitive!!.content!!.toFloat()}")) - episode.episode_number = animeItem["number"]!!.jsonPrimitive!!.content!!.toFloat() - episode.name = "Episodio ${animeItem["number"]!!.jsonPrimitive!!.content!!.toFloat()}" - episodeList.add(episode) - } + + document.select("div.listEpisodes a.episodeContainer").forEach { episodeContainer -> + val episodeNumber = + episodeContainer.selectFirst("div.episodeInfoContainer span.episodeNumber")?.text() + val episodeUrl = episodeContainer.attr("href") + + val episode = SEpisode.create() + if (episodeNumber != null) { + episode.episode_number = episodeNumber.toFloatOrNull() ?: 0f } + episode.setUrlWithoutDomain(externalOrInternalImg(episodeUrl)) + episode.name = "Episodio $episodeNumber" + + episodeList.add(episode) } + return episodeList } @@ -174,68 +172,72 @@ class AnimeLatinoHD : ConfigurableAnimeSource, AnimeHttpSource() { override fun videoListParse(response: Response): List