nhentai fixes (#11020)

* fix nhentai images

* increase version

* fix popularmanga for all languages

* dont include popular now in latest

* fix empty query
This commit is contained in:
Basara-Hatake 2022-03-05 18:26:47 +01:00 committed by GitHub
parent d9e6047ce2
commit 1a77eee1aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'NHentai'
pkgNameSuffix = 'all.nhentai'
extClass = '.NHFactory'
extVersionCode = 30
extVersionCode = 31
isNsfw = true
}

View File

@ -85,7 +85,7 @@ open class NHentai(
override fun latestUpdatesRequest(page: Int) = GET(if (nhLang.isBlank()) "$baseUrl/?page=$page" else "$baseUrl/language/$nhLang/?page=$page", headers)
override fun latestUpdatesSelector() = "#content .gallery"
override fun latestUpdatesSelector() = "#content .index-container:not(.index-popular) .gallery"
override fun latestUpdatesFromElement(element: Element) = SManga.create().apply {
setUrlWithoutDomain(element.select("a").attr("href"))
@ -99,7 +99,7 @@ open class NHentai(
override fun latestUpdatesNextPageSelector() = "#content > section.pagination > a.next"
override fun popularMangaRequest(page: Int) = GET(if (nhLang.isBlank()) "$baseUrl/?page=$page" else "$baseUrl/language/$nhLang/popular?page=$page", headers)
override fun popularMangaRequest(page: Int) = GET(if (nhLang.isBlank()) "$baseUrl/search/?q=\"\"&sort=popular&page=$page" else "$baseUrl/language/$nhLang/popular?page=$page", headers)
override fun popularMangaFromElement(element: Element) = latestUpdatesFromElement(element)
@ -131,6 +131,7 @@ open class NHentai(
}
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
val fixedQuery = query.ifEmpty { "\"\"" }
val filterList = if (filters.isEmpty()) getFilterList() else filters
val nhLangSearch = if (nhLang.isBlank()) "" else "+$nhLang "
val advQuery = combineQuery(filterList)
@ -139,13 +140,13 @@ open class NHentai(
if (favoriteFilter?.state == true) {
val url = "$baseUrl/favorites".toHttpUrlOrNull()!!.newBuilder()
.addQueryParameter("q", "$query $advQuery")
.addQueryParameter("q", "$fixedQuery $advQuery")
.addQueryParameter("page", page.toString())
return GET(url.toString(), headers)
} else {
val url = "$baseUrl/search".toHttpUrlOrNull()!!.newBuilder()
.addQueryParameter("q", "$query $nhLangSearch$advQuery")
.addQueryParameter("q", "$fixedQuery $nhLangSearch$advQuery")
.addQueryParameter("page", page.toString())
if (isOkayToSort) {
@ -243,8 +244,11 @@ open class NHentai(
override fun chapterListSelector() = throw UnsupportedOperationException("Not used")
override fun pageListParse(document: Document): List<Page> {
val script = document.select("script:containsData(media_server)").first().data()
val media_server = Regex("""media_server\s*:\s*(\d+)""").find(script)?.groupValues!!.get(1)
return document.select("div.thumbs a > img").mapIndexed { i, img ->
Page(i, "", img.attr("abs:data-src").replace("t.nh", "i.nh").replace("t.", "."))
Page(i, "", img.attr("abs:data-src").replace("t.nh", "i.nh").replace("t\\d+.nh".toRegex(), "i$media_server.nh").replace("t.", "."))
}
}