diff --git a/src/all/danbooru/build.gradle b/src/all/danbooru/build.gradle index 55ab57c12..8eb9ad936 100644 --- a/src/all/danbooru/build.gradle +++ b/src/all/danbooru/build.gradle @@ -1,7 +1,7 @@ ext { extName = 'Danbooru' extClass = '.Danbooru' - extVersionCode = 1 + extVersionCode = 2 isNsfw = true } diff --git a/src/all/danbooru/src/eu/kanade/tachiyomi/extension/all/danbooru/Danbooru.kt b/src/all/danbooru/src/eu/kanade/tachiyomi/extension/all/danbooru/Danbooru.kt index 5ae5b9009..1e7591f20 100644 --- a/src/all/danbooru/src/eu/kanade/tachiyomi/extension/all/danbooru/Danbooru.kt +++ b/src/all/danbooru/src/eu/kanade/tachiyomi/extension/all/danbooru/Danbooru.kt @@ -47,54 +47,52 @@ class Danbooru : ParsedHttpSource() { override fun popularMangaSelector(): String = searchMangaSelector() - override fun searchMangaRequest(page: Int, query: String, filters: FilterList) = Request( - url = "$baseUrl/pools/gallery".toHttpUrl().newBuilder().run { - setEncodedQueryParameter("search[category]", "series") + override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { + val url = "$baseUrl/pools/gallery".toHttpUrl().newBuilder() - filters.forEach { - when (it) { - is FilterTags -> if (it.state.isNotBlank()) { - addQueryParameter("search[post_tags_match]", it.state) - } + url.setEncodedQueryParameter("search[category]", "series") - is FilterDescription -> if (it.state.isNotBlank()) { - addQueryParameter("search[description_matches]", it.state) - } - - is FilterIsDeleted -> if (it.state) { - addEncodedQueryParameter("search[is_deleted]", "true") - } - - is FilterCategory -> { - setEncodedQueryParameter("search[category]", it.selected) - } - - is FilterOrder -> if (it.selected != null) { - addEncodedQueryParameter("search[order]", it.selected) - } - - else -> throw IllegalStateException("Unrecognized filter") + filters.forEach { + when (it) { + is FilterTags -> if (it.state.isNotBlank()) { + url.addQueryParameter("search[post_tags_match]", it.state) } + + is FilterDescription -> if (it.state.isNotBlank()) { + url.addQueryParameter("search[description_matches]", it.state) + } + + is FilterIsDeleted -> if (it.state) { + url.addEncodedQueryParameter("search[is_deleted]", "true") + } + + is FilterCategory -> { + url.setEncodedQueryParameter("search[category]", it.selected) + } + + is FilterOrder -> if (it.selected != null) { + url.addEncodedQueryParameter("search[order]", it.selected) + } + + else -> throw IllegalStateException("Unrecognized filter") } + } - addEncodedQueryParameter("page", page.toString()) + url.addEncodedQueryParameter("page", page.toString()) - if (query.isNotBlank()) { - addQueryParameter("search[name_contains]", query) - } + if (query.isNotBlank()) { + url.addQueryParameter("search[name_contains]", query) + } - build() - }, - - headers = headers, - ) + return GET(url.build(), headers) + } override fun searchMangaSelector(): String = - ".post-preview" + "article.post-preview" override fun searchMangaFromElement(element: Element) = SManga.create().apply { url = element.selectFirst(".post-preview-link")?.attr("href")!! - title = element.selectFirst(".desc")?.text() ?: "" + title = element.selectFirst("div.text-center")?.text() ?: "" thumbnail_url = element.selectFirst("source")?.attr("srcset") ?.substringAfterLast(',')?.trim()