Multporn: fix popular listing (#154)
Co-authored-by: stevenyomi <95685115+stevenyomi@users.noreply.github.com>
This commit is contained in:
parent
3523acfe90
commit
504342706e
|
@ -6,7 +6,7 @@ ext {
|
||||||
extName = 'Multporn'
|
extName = 'Multporn'
|
||||||
pkgNameSuffix = 'en.multporn'
|
pkgNameSuffix = 'en.multporn'
|
||||||
extClass = '.Multporn'
|
extClass = '.Multporn'
|
||||||
extVersionCode = 3
|
extVersionCode = 4
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package eu.kanade.tachiyomi.extension.en.multporn
|
package eu.kanade.tachiyomi.extension.en.multporn
|
||||||
|
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
import eu.kanade.tachiyomi.network.POST
|
|
||||||
import eu.kanade.tachiyomi.network.asObservable
|
import eu.kanade.tachiyomi.network.asObservable
|
||||||
import eu.kanade.tachiyomi.network.asObservableSuccess
|
import eu.kanade.tachiyomi.network.asObservableSuccess
|
||||||
import eu.kanade.tachiyomi.source.model.Filter
|
import eu.kanade.tachiyomi.source.model.Filter
|
||||||
|
@ -12,18 +11,11 @@ import eu.kanade.tachiyomi.source.model.SChapter
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
||||||
import eu.kanade.tachiyomi.util.asJsoup
|
import eu.kanade.tachiyomi.util.asJsoup
|
||||||
import kotlinx.serialization.decodeFromString
|
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import kotlinx.serialization.json.JsonArray
|
|
||||||
import kotlinx.serialization.json.jsonObject
|
|
||||||
import kotlinx.serialization.json.jsonPrimitive
|
|
||||||
import okhttp3.FormBody
|
|
||||||
import okhttp3.Headers
|
import okhttp3.Headers
|
||||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.ResponseBody.Companion.toResponseBody
|
|
||||||
import org.jsoup.nodes.Document
|
import org.jsoup.nodes.Document
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
|
@ -47,36 +39,22 @@ class Multporn : ParsedHttpSource() {
|
||||||
// Popular
|
// Popular
|
||||||
|
|
||||||
private fun buildPopularMangaRequest(page: Int, filters: FilterList = FilterList()): Request {
|
private fun buildPopularMangaRequest(page: Int, filters: FilterList = FilterList()): Request {
|
||||||
val body = FormBody.Builder()
|
val url = "$baseUrl/best".toHttpUrl().newBuilder()
|
||||||
.addEncoded("page", page.toString())
|
.addQueryParameter("page", page.toString())
|
||||||
.addEncoded("view_name", "top")
|
|
||||||
.addEncoded("view_display_id", "page")
|
|
||||||
|
|
||||||
(if (filters.isEmpty()) getFilterList(POPULAR_DEFAULT_SORT_BY_FILTER_STATE) else filters).forEach {
|
(if (filters.isEmpty()) getFilterList(POPULAR_DEFAULT_SORT_BY_FILTER_STATE) else filters).forEach {
|
||||||
when (it) {
|
when (it) {
|
||||||
is SortBySelectFilter -> body.addEncoded("sort_by", it.selected.uri)
|
is SortBySelectFilter -> url.addQueryParameter("sort_by", it.selected.uri)
|
||||||
is SortOrderSelectFilter -> body.addEncoded("sort_order", it.selected.uri)
|
is SortOrderSelectFilter -> url.addQueryParameter("sort_order", it.selected.uri)
|
||||||
is PopularTypeSelectFilter -> body.addEncoded("type", it.selected.uri)
|
is PopularTypeSelectFilter -> url.addQueryParameter("type", it.selected.uri)
|
||||||
else -> { }
|
else -> { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return POST("$baseUrl/views/ajax", headers, body.build())
|
return GET(url.build(), headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun popularMangaRequest(page: Int) = buildPopularMangaRequest(page - 1)
|
override fun popularMangaRequest(page: Int) = buildPopularMangaRequest(page - 1)
|
||||||
|
|
||||||
override fun popularMangaParse(response: Response): MangasPage {
|
|
||||||
val html = json.decodeFromString<JsonArray>(response.body.string())
|
|
||||||
.last { it.jsonObject["command"]!!.jsonPrimitive.content == "insert" }.jsonObject["data"]!!.jsonPrimitive.content
|
|
||||||
|
|
||||||
return super.popularMangaParse(
|
|
||||||
response.newBuilder()
|
|
||||||
.body(html.toResponseBody("text/html; charset=UTF-8".toMediaTypeOrNull()))
|
|
||||||
.build(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun popularMangaSelector() = ".masonry-item"
|
override fun popularMangaSelector() = ".masonry-item"
|
||||||
override fun popularMangaNextPageSelector() = ".pager-next a"
|
override fun popularMangaNextPageSelector() = ".pager-next a"
|
||||||
override fun popularMangaFromElement(element: Element): SManga = SManga.create().apply {
|
override fun popularMangaFromElement(element: Element): SManga = SManga.create().apply {
|
||||||
|
@ -88,7 +66,7 @@ class Multporn : ParsedHttpSource() {
|
||||||
// Latest
|
// Latest
|
||||||
|
|
||||||
private fun buildLatestMangaRequest(page: Int, filters: FilterList = FilterList()): Request {
|
private fun buildLatestMangaRequest(page: Int, filters: FilterList = FilterList()): Request {
|
||||||
val url = "$baseUrl/new".toHttpUrlOrNull()!!.newBuilder()
|
val url = "$baseUrl/new".toHttpUrl().newBuilder()
|
||||||
.addQueryParameter("page", page.toString())
|
.addQueryParameter("page", page.toString())
|
||||||
|
|
||||||
(if (filters.isEmpty()) getFilterList(LATEST_DEFAULT_SORT_BY_FILTER_STATE) else filters).forEach {
|
(if (filters.isEmpty()) getFilterList(LATEST_DEFAULT_SORT_BY_FILTER_STATE) else filters).forEach {
|
||||||
|
@ -126,7 +104,7 @@ class Multporn : ParsedHttpSource() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buildSearchMangaRequest(page: Int, query: String, filtersArg: FilterList = FilterList()): Request {
|
private fun buildSearchMangaRequest(page: Int, query: String, filtersArg: FilterList = FilterList()): Request {
|
||||||
val url = "$baseUrl/search".toHttpUrlOrNull()!!.newBuilder()
|
val url = "$baseUrl/search".toHttpUrl().newBuilder()
|
||||||
.addQueryParameter("page", page.toString())
|
.addQueryParameter("page", page.toString())
|
||||||
.addQueryParameter("views_fulltext", query)
|
.addQueryParameter("views_fulltext", query)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue