-
Notifications
You must be signed in to change notification settings - Fork 548
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix
- Loading branch information
Showing
2 changed files
with
66 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 65 additions & 19 deletions
84
src/pt/animexnovel/src/eu/kanade/tachiyomi/extension/pt/animexnovel/AnimeXNovel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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")) | ||
return super.popularMangaParse(response).let { mangaPage -> | ||
mangaPage.mangas.filter { it.title.contains("[Mangá]") }.let { | ||
mangaPage.copy(it) | ||
} | ||
}.filter { it.title.contains("[Mangá]") } | ||
} | ||
} | ||
|
||
// ============================== Latest =============================== | ||
|
||
return MangasPage(mangas, false) | ||
override fun latestUpdatesParse(response: Response): MangasPage { | ||
return super.latestUpdatesParse(response).let { | ||
it.copy(it.mangas.filter { it.title.contains("[Mangá]") }) | ||
} | ||
} | ||
|
||
override val mangaDetailsSelectorDescription = "div.bc-fff.s1 > h3:contains(Sinopse) ~ div[style=text-align: justify;]" | ||
// ============================== 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()) | ||
} | ||
|
||
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" | ||
// ============================== Chapters =============================== | ||
|
||
override val chapterCategory = "Capítulo" | ||
|
||
override fun chapterListParse(response: Response): List<SChapter> { | ||
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")) | ||
} | ||
} | ||
|
||
val url = getChapterFeedUrl(document).toHttpUrl().newBuilder() | ||
.setQueryParameter("start-index", "1") | ||
|
||
val chapters = mutableListOf<SChapter>() | ||
do { | ||
val res = client.newCall(GET(url.build(), headers)).execute() | ||
|
||
val page = json.decodeFromString<ZeistMangaDto>(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" | ||
} |