[Grouple] Migrate to the new getList

pull/397/head
Koitharu 2 years ago
parent e7ac1c1feb
commit c3613f3ba4
Signed by: Koitharu
GPG Key ID: 676DEE768C17A9D7

@ -62,37 +62,40 @@ internal abstract class GroupleParser(
override val isAuthorized: Boolean override val isAuthorized: Boolean
get() = context.cookieJar.getCookies(domain).any { it.name == "gwt" } get() = context.cookieJar.getCookies(domain).any { it.name == "gwt" }
override suspend fun getList( override suspend fun getList(offset: Int, filter: MangaListFilter?): List<Manga> {
offset: Int,
query: String?,
tags: Set<MangaTag>?,
sortOrder: SortOrder,
): List<Manga> {
val domain = domain val domain = domain
val doc = when { val doc = when (filter) {
!query.isNullOrEmpty() -> webClient.httpPost( is MangaListFilter.Search -> webClient.httpPost(
"https://$domain/search", "https://$domain/search",
mapOf( mapOf(
"q" to query.urlEncoded(), "q" to filter.query.urlEncoded(),
"offset" to (offset upBy PAGE_SIZE_SEARCH).toString(), "offset" to (offset upBy PAGE_SIZE_SEARCH).toString(),
"fast-filter" to "CREATION", "fast-filter" to "CREATION",
), ),
) )
tags.isNullOrEmpty() -> webClient.httpGet( null -> webClient.httpGet(
"https://$domain/list?sortType=${ "https://$domain/list?sortType=${
getSortKey(sortOrder) getSortKey(defaultSortOrder)
}&offset=${offset upBy PAGE_SIZE}", }&offset=${offset upBy PAGE_SIZE}",
) )
tags.size == 1 -> webClient.httpGet( is MangaListFilter.Advanced -> when {
"https://$domain/list/genre/${tags.first().key}?sortType=${ filter.tags.isEmpty() -> webClient.httpGet(
getSortKey(sortOrder) "https://$domain/list?sortType=${
}&offset=${offset upBy PAGE_SIZE}", getSortKey(filter.sortOrder)
) }&offset=${offset upBy PAGE_SIZE}",
)
offset > 0 -> return emptyList() filter.tags.size == 1 -> webClient.httpGet(
else -> advancedSearch(domain, tags) "https://$domain/list/genre/${filter.tags.first().key}?sortType=${
getSortKey(filter.sortOrder)
}&offset=${offset upBy PAGE_SIZE}",
)
offset > 0 -> return emptyList()
else -> advancedSearch(domain, filter.tags)
}
}.parseHtml().body() }.parseHtml().body()
val root = (doc.getElementById("mangaBox") ?: doc.getElementById("mangaResults")) val root = (doc.getElementById("mangaBox") ?: doc.getElementById("mangaResults"))
?: doc.parseFailed("Cannot find root") ?: doc.parseFailed("Cannot find root")

Loading…
Cancel
Save