diff --git a/src/pt/animexnovel/build.gradle b/src/pt/animexnovel/build.gradle index 80468f29a..198727d1e 100644 --- a/src/pt/animexnovel/build.gradle +++ b/src/pt/animexnovel/build.gradle @@ -3,7 +3,7 @@ ext { extClass = '.AnimeXNovel' themePkg = 'zeistmanga' baseUrl = 'https://www.animexnovel.com' - overrideVersionCode = 0 + overrideVersionCode = 1 } apply from: "$rootDir/common.gradle" diff --git a/src/pt/animexnovel/src/eu/kanade/tachiyomi/extension/pt/animexnovel/AnimeXNovel.kt b/src/pt/animexnovel/src/eu/kanade/tachiyomi/extension/pt/animexnovel/AnimeXNovel.kt index 2968737b2..d83234cb7 100644 --- a/src/pt/animexnovel/src/eu/kanade/tachiyomi/extension/pt/animexnovel/AnimeXNovel.kt +++ b/src/pt/animexnovel/src/eu/kanade/tachiyomi/extension/pt/animexnovel/AnimeXNovel.kt @@ -1,41 +1,87 @@ package eu.kanade.tachiyomi.extension.pt.animexnovel import eu.kanade.tachiyomi.multisrc.zeistmanga.ZeistManga +import eu.kanade.tachiyomi.multisrc.zeistmanga.ZeistMangaDto +import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.source.model.MangasPage import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.util.asJsoup +import kotlinx.serialization.decodeFromString +import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.Response -class AnimeXNovel : ZeistManga("AnimeXNovel", "https://www.animexnovel.com", "pt-BR") { +class AnimeXNovel : ZeistManga( + "AnimeXNovel", + "https://www.animexnovel.com", + "pt-BR", +) { - override val mangaCategory: String = "Manga" + // ============================== Popular =============================== + + override val popularMangaSelector = "#PopularPosts2 article" + override val popularMangaSelectorTitle = "h3 > a" + override val popularMangaSelectorUrl = popularMangaSelectorTitle override fun popularMangaParse(response: Response): MangasPage { - val document = response.asJsoup() - val mangas = document.select("div.PopularPosts div.grid > figure").map { element -> - SManga.create().apply { - thumbnail_url = element.selectFirst("img")!!.attr("abs:src") - title = element.selectFirst("figcaption > a")!!.text() - setUrlWithoutDomain(element.selectFirst("figcaption > a")!!.attr("href")) - } - }.filter { it.title.contains("[Mangá]") } - - return MangasPage(mangas, false) - } - - override val mangaDetailsSelectorDescription = "div.bc-fff.s1 > h3:contains(Sinopse) ~ div[style=text-align: justify;]" - - private val chapterListSelector = "div:has(> .list-judul:contains(Lista de Capítulos)) div#latest ul > li, div.tab:has(> label:contains(Lista de Capítulos)) div.tab-content ul > li" - - override fun chapterListParse(response: Response): List { - val document = response.asJsoup() - val chapters = document.select(chapterListSelector) - return chapters.map { - SChapter.create().apply { - name = it.select("a").text() - setUrlWithoutDomain(it.select("a").attr("href")) + return super.popularMangaParse(response).let { mangaPage -> + mangaPage.mangas.filter { it.title.contains("[Mangá]") }.let { + mangaPage.copy(it) } } } + + // ============================== Latest =============================== + + override fun latestUpdatesParse(response: Response): MangasPage { + return super.latestUpdatesParse(response).let { + it.copy(it.mangas.filter { it.title.contains("[Mangá]") }) + } + } + + // ============================== Details =============================== + + override fun mangaDetailsParse(response: Response) = SManga.create().apply { + val document = response.asJsoup() + title = document.selectFirst("h1")!!.text() + thumbnail_url = document.selectFirst(".thumb")?.absUrl("src") + description = document.selectFirst("#synopsis")?.text() + document.selectFirst("span[data-status]")?.let { + status = parseStatus(it.text()) + } + genre = document.select("dl:has(dt:contains(Gênero)) dd a") + .joinToString { it.text() } + + setUrlWithoutDomain(document.location()) + } + + // ============================== Chapters =============================== + + override val chapterCategory = "Capítulo" + + override fun chapterListParse(response: Response): List { + val document = response.asJsoup() + + val url = getChapterFeedUrl(document).toHttpUrl().newBuilder() + .setQueryParameter("start-index", "1") + + val chapters = mutableListOf() + do { + val res = client.newCall(GET(url.build(), headers)).execute() + + val page = json.decodeFromString(res.body.string()).feed?.entry + ?.filter { it.category.orEmpty().any { category -> category.term == chapterCategory } } + ?.map { it.toSChapter(baseUrl) } + ?: emptyList() + + chapters += page + url.setQueryParameter("start-index", "${chapters.size + 1}") + } while (page.isNotEmpty()) + + return chapters + } + + // ============================== Pages =============================== + + override val pageListSelector = "#reader .separator" }