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:
parent
2bab0cccdb
commit
159bee785a
|
@ -3,7 +3,7 @@ ext {
|
|||
extClass = '.ManhwahentaiMe'
|
||||
themePkg = 'madara'
|
||||
baseUrl = 'https://manhwahentai.me'
|
||||
overrideVersionCode = 6
|
||||
overrideVersionCode = 7
|
||||
isNsfw = true
|
||||
}
|
||||
|
||||
|
|
|
@ -54,43 +54,45 @@ class ManhwahentaiMe : Madara("Manhwahentai.me", "https://manhwahentai.me", "en"
|
|||
}
|
||||
|
||||
override fun searchRequest(page: Int, query: String, filters: FilterList): Request {
|
||||
val url = "$baseUrl/${searchPage(page)}".toHttpUrl().newBuilder()
|
||||
var alr = false
|
||||
url.addQueryParameter("s", query)
|
||||
url.addQueryParameter("post_type", "wp-manga")
|
||||
val url = "$baseUrl/${searchPage(page)}".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) {
|
||||
url.addPathSegments("manga-author/${filter.state.replace(" ", "-")}")
|
||||
alr = true
|
||||
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) {
|
||||
url.addQueryParameter("artist", 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) {
|
||||
url.addPathSegments("webtoon-release/${filter.state}")
|
||||
alr = true
|
||||
is YearFilter -> {
|
||||
if (filter.state.isNotBlank() && !alr) {
|
||||
addPathSegments("webtoon-release/${filter.state}")
|
||||
alr = true
|
||||
}
|
||||
}
|
||||
}
|
||||
is OrderByFilter -> {
|
||||
url.addQueryParameter("m_orderby", filter.toUriPart())
|
||||
}
|
||||
is GenreConditionFilter -> {
|
||||
val name = filter.toUriPart()
|
||||
if (name != "all") {
|
||||
url.addPathSegments("webtoon-genre/$name")
|
||||
is OrderByFilter -> {
|
||||
addQueryParameter("m_orderby", filter.toUriPart())
|
||||
}
|
||||
is GenreConditionFilter -> {
|
||||
val name = filter.toUriPart()
|
||||
if (name != "all" && !alr) {
|
||||
addPathSegments("webtoon-genre/$name")
|
||||
}
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
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 popularMangaNextPageSelector() = "a.next"
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ ext {
|
|||
extClass = '.ManyToon'
|
||||
themePkg = 'madara'
|
||||
baseUrl = 'https://manytoon.com'
|
||||
overrideVersionCode = 7
|
||||
overrideVersionCode = 8
|
||||
isNsfw = true
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
package eu.kanade.tachiyomi.extension.en.manytoon
|
||||
|
||||
import eu.kanade.tachiyomi.multisrc.madara.Madara
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
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.HttpUrl.Companion.toHttpUrl
|
||||
import okhttp3.Request
|
||||
import org.jsoup.nodes.Document
|
||||
|
||||
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 sendViewCount = false
|
||||
override val fetchGenres = false
|
||||
|
||||
override fun oldXhrChaptersRequest(mangaId: String): Request {
|
||||
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)
|
||||
}
|
||||
|
||||
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"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue