Merge pull request #615 from NagaYZ/feature-search-by-number
Feature search by number
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,6 +4,7 @@
|
|||||||
.idea/**/usage.statistics.xml
|
.idea/**/usage.statistics.xml
|
||||||
.idea/**/dictionaries
|
.idea/**/dictionaries
|
||||||
.idea/**/shelf
|
.idea/**/shelf
|
||||||
|
.idea/**/copilot
|
||||||
|
|
||||||
# Generated files
|
# Generated files
|
||||||
.idea/**/contentModel.xml
|
.idea/**/contentModel.xml
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.koitharu.kotatsu.parsers.site.galleryadults.all
|
package org.koitharu.kotatsu.parsers.site.galleryadults.all
|
||||||
|
|
||||||
import org.jsoup.internal.StringUtil
|
import org.jsoup.internal.StringUtil
|
||||||
|
import org.jsoup.nodes.Document
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
import org.koitharu.kotatsu.parsers.MangaLoaderContext
|
import org.koitharu.kotatsu.parsers.MangaLoaderContext
|
||||||
import org.koitharu.kotatsu.parsers.MangaSourceParser
|
import org.koitharu.kotatsu.parsers.MangaSourceParser
|
||||||
@@ -35,9 +36,18 @@ internal class NHentaiParser(context: MangaLoaderContext) :
|
|||||||
when (filter) {
|
when (filter) {
|
||||||
|
|
||||||
is MangaListFilter.Search -> {
|
is MangaListFilter.Search -> {
|
||||||
append("/search/?q=pages:>0 ")
|
// Check if the query is all numbers
|
||||||
append(filter.query.urlEncoded())
|
val numericQuery = filter.query.trim()
|
||||||
append("&")
|
if (numericQuery.matches("\\d+".toRegex())) {
|
||||||
|
val title = fetchMangaTitle("$this/g/$numericQuery/")
|
||||||
|
append("/search/?q=pages:>0 ")
|
||||||
|
append(title)
|
||||||
|
append("&")
|
||||||
|
} else {
|
||||||
|
append("/search/?q=pages:>0 ")
|
||||||
|
append(filter.query.urlEncoded())
|
||||||
|
append("&")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is MangaListFilter.Advanced -> {
|
is MangaListFilter.Advanced -> {
|
||||||
@@ -89,6 +99,31 @@ internal class NHentaiParser(context: MangaLoaderContext) :
|
|||||||
return parseMangaList(webClient.httpGet(url).parseHtml())
|
return parseMangaList(webClient.httpGet(url).parseHtml())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private suspend fun fetchMangaTitle(url: String): String {
|
||||||
|
val doc = webClient.httpGet(url).parseHtml()
|
||||||
|
return doc.selectFirstOrThrow("h1.title").text().trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun parseMangaList(doc: Document): List<Manga> {
|
||||||
|
return doc.select(selectGallery).map { div ->
|
||||||
|
val href = div.selectFirstOrThrow(selectGalleryLink).attrAsRelativeUrl("href")
|
||||||
|
Manga(
|
||||||
|
id = generateUid(href),
|
||||||
|
title = div.select(selectGalleryTitle).text().trim(),
|
||||||
|
altTitle = null,
|
||||||
|
url = href,
|
||||||
|
publicUrl = href.toAbsoluteUrl(domain),
|
||||||
|
rating = RATING_UNKNOWN,
|
||||||
|
isNsfw = isNsfwSource,
|
||||||
|
coverUrl = div.selectFirstOrThrow(selectGalleryImg).src().orEmpty(),
|
||||||
|
tags = emptySet(),
|
||||||
|
state = null,
|
||||||
|
author = null,
|
||||||
|
source = source,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override suspend fun getPageUrl(page: MangaPage): String {
|
override suspend fun getPageUrl(page: MangaPage): String {
|
||||||
val doc = webClient.httpGet(page.url.toAbsoluteUrl(domain)).parseHtml()
|
val doc = webClient.httpGet(page.url.toAbsoluteUrl(domain)).parseHtml()
|
||||||
val root = doc.body()
|
val root = doc.body()
|
||||||
|
|||||||
Reference in New Issue
Block a user