ManyToon & ManhwaHentaiMe | Fix Next Page Selector (#4500)

Fix Next Page Selector

- ManyToon: Fix Next Page Selector and Filters
- ManwhaHentaiMe: Fix Next Page Selector
This commit is contained in:
KenjieDec 2024-08-09 12:28:27 +07:00 committed by Draff
parent 2bab0cccdb
commit 159bee785a
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
4 changed files with 168 additions and 32 deletions

View File

@ -3,7 +3,7 @@ ext {
extClass = '.ManhwahentaiMe' extClass = '.ManhwahentaiMe'
themePkg = 'madara' themePkg = 'madara'
baseUrl = 'https://manhwahentai.me' baseUrl = 'https://manhwahentai.me'
overrideVersionCode = 6 overrideVersionCode = 7
isNsfw = true isNsfw = true
} }

View File

@ -54,43 +54,45 @@ class ManhwahentaiMe : Madara("Manhwahentai.me", "https://manhwahentai.me", "en"
} }
override fun searchRequest(page: Int, query: String, filters: FilterList): Request { override fun searchRequest(page: Int, query: String, filters: FilterList): Request {
val url = "$baseUrl/${searchPage(page)}".toHttpUrl().newBuilder() val url = "$baseUrl/${searchPage(page)}".toHttpUrl().newBuilder().apply {
var alr = false var alr = false
url.addQueryParameter("s", query) addQueryParameter("s", query)
url.addQueryParameter("post_type", "wp-manga") addQueryParameter("post_type", "wp-manga")
filters.forEach { filter -> filters.forEach { filter ->
when (filter) { when (filter) {
is AuthorFilter -> { is AuthorFilter -> {
if (filter.state.isNotBlank() && !alr) { if (filter.state.isNotBlank() && !alr) {
url.addPathSegments("manga-author/${filter.state.replace(" ", "-")}") addPathSegments("manga-author/${filter.state.replace(" ", "-")}")
alr = true alr = true
} }
} }
is ArtistFilter -> { is ArtistFilter -> {
if (filter.state.isNotBlank() && !alr) { if (filter.state.isNotBlank() && !alr) {
url.addQueryParameter("artist", filter.state.replace(" ", "-")) addQueryParameter("artist", filter.state.replace(" ", "-"))
alr = true alr = true
} }
} }
is YearFilter -> { is YearFilter -> {
if (filter.state.isNotBlank() && !alr) { if (filter.state.isNotBlank() && !alr) {
url.addPathSegments("webtoon-release/${filter.state}") addPathSegments("webtoon-release/${filter.state}")
alr = true alr = true
} }
} }
is OrderByFilter -> { is OrderByFilter -> {
url.addQueryParameter("m_orderby", filter.toUriPart()) addQueryParameter("m_orderby", filter.toUriPart())
} }
is GenreConditionFilter -> { is GenreConditionFilter -> {
val name = filter.toUriPart() val name = filter.toUriPart()
if (name != "all") { if (name != "all" && !alr) {
url.addPathSegments("webtoon-genre/$name") addPathSegments("webtoon-genre/$name")
} }
} }
else -> {} else -> {}
} }
} }
}
return GET(url.build(), headers) return GET(url.build(), headers)
} }
@ -163,4 +165,5 @@ class ManhwahentaiMe : Madara("Manhwahentai.me", "https://manhwahentai.me", "en"
} }
override fun searchMangaSelector() = "div.page-item-detail" override fun searchMangaSelector() = "div.page-item-detail"
override fun popularMangaNextPageSelector() = "a.next"
} }

View File

@ -3,7 +3,7 @@ ext {
extClass = '.ManyToon' extClass = '.ManyToon'
themePkg = 'madara' themePkg = 'madara'
baseUrl = 'https://manytoon.com' baseUrl = 'https://manytoon.com'
overrideVersionCode = 7 overrideVersionCode = 8
isNsfw = true isNsfw = true
} }

View File

@ -1,9 +1,15 @@
package eu.kanade.tachiyomi.extension.en.manytoon package eu.kanade.tachiyomi.extension.en.manytoon
import eu.kanade.tachiyomi.multisrc.madara.Madara import eu.kanade.tachiyomi.multisrc.madara.Madara
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.POST import eu.kanade.tachiyomi.network.POST
import eu.kanade.tachiyomi.source.model.Filter
import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.FormBody import okhttp3.FormBody
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.Request import okhttp3.Request
import org.jsoup.nodes.Document
class ManyToon : Madara("ManyToon", "https://manytoon.com", "en") { class ManyToon : Madara("ManyToon", "https://manytoon.com", "en") {
@ -11,7 +17,6 @@ class ManyToon : Madara("ManyToon", "https://manytoon.com", "en") {
override val useNewChapterEndpoint = false override val useNewChapterEndpoint = false
override val sendViewCount = false override val sendViewCount = false
override val fetchGenres = false
override fun oldXhrChaptersRequest(mangaId: String): Request { override fun oldXhrChaptersRequest(mangaId: String): Request {
val form = FormBody.Builder() val form = FormBody.Builder()
@ -22,5 +27,133 @@ class ManyToon : Madara("ManyToon", "https://manytoon.com", "en") {
return POST("$baseUrl/wp-admin/admin-ajax.php", xhrHeaders, form) return POST("$baseUrl/wp-admin/admin-ajax.php", xhrHeaders, form)
} }
override fun searchMangaSelector() = "div.page-item-detail" override fun popularMangaRequest(page: Int): Request =
if (useLoadMoreRequest()) {
loadMoreRequest(page, popular = true)
} else {
GET("$baseUrl/$mangaSubString/${searchPage(page)}?m_orderby=trending", headers)
}
override fun latestUpdatesRequest(page: Int): Request =
if (useLoadMoreRequest()) {
loadMoreRequest(page, popular = false)
} else {
GET("$baseUrl/home/${searchPage(page)}", headers)
}
override fun searchRequest(page: Int, query: String, filters: FilterList): Request {
val url = baseUrl.toHttpUrl().newBuilder().apply {
var alr = false
addQueryParameter("s", query)
addQueryParameter("post_type", "wp-manga")
filters.forEach { filter ->
when (filter) {
is AuthorFilter -> {
if (filter.state.isNotBlank() && !alr) {
addPathSegments("manga-author/${filter.state.replace(" ", "-")}")
alr = true
}
}
is ArtistFilter -> {
if (filter.state.isNotBlank() && !alr) {
addQueryParameter("artist", filter.state.replace(" ", "-"))
alr = true
}
}
is YearFilter -> {
if (filter.state.isNotBlank() && !alr) {
addPathSegments("comic-release/${filter.state}")
alr = true
}
}
is OrderByFilter -> {
addQueryParameter("m_orderby", filter.toUriPart())
}
is GenreConditionFilter -> {
val name = filter.toUriPart()
if (name != "all" && !alr) {
addPathSegments("manga-genre/$name")
alr = true
}
}
else -> {}
}
}
addPathSegments(searchPage(page))
}
return GET(url.build(), headers)
}
override val orderByFilterOptions: Map<String, String> = mapOf(
intl["order_by_filter_az"] to "alphabet",
intl["order_by_filter_rating"] to "rating",
intl["order_by_filter_trending"] to "trending",
intl["order_by_filter_views"] to "views",
intl["order_by_filter_new"] to "new-manga",
)
private var genresList: List<Pair<String, String>> = emptyList()
private var fetchGenresAttempts: Int = 0
private fun fetchGenresMe() {
if (fetchGenres && fetchGenresAttempts < 3 && genresList.isEmpty()) {
try {
genresList = client.newCall(genresRequest()).execute()
.use { parseGenresMe(it.asJsoup()) }
} catch (_: Exception) {
} finally {
fetchGenresAttempts++
}
}
}
private fun parseGenresMe(document: Document): List<Pair<String, String>> {
return document.selectFirst("div.genres")
?.select("a")
.orEmpty()
.map { a ->
a.ownText() to
a.attr("href").substringBeforeLast("/").substringAfterLast("/")
}.let {
listOf(("All" to "all")) + it
}
}
override fun getFilterList(): FilterList {
launchIO { fetchGenresMe() }
val filters = mutableListOf(
Filter.Header("All filters except the orderby filter are incompatible with each other"),
AuthorFilter(intl["author_filter_title"]),
ArtistFilter(intl["artist_filter_title"]),
YearFilter(intl["year_filter_title"]),
OrderByFilter(
title = intl["order_by_filter_title"],
options = orderByFilterOptions.toList(),
),
)
if (genresList.isNotEmpty()) {
filters += listOf(
Filter.Separator(),
Filter.Header(intl["genre_filter_header"]),
GenreConditionFilter(
title = intl["genre_filter_title"],
options = genresList,
),
)
} else if (fetchGenres) {
filters += listOf(
Filter.Separator(),
Filter.Header(intl["genre_missing_warning"]),
)
}
return FilterList(filters)
}
override fun searchMangaSelector() = "div.page-item-detail"
override fun popularMangaNextPageSelector() = "a.next"
} }