From eeb2f25e9d9880cadd7b4a38862a010d1de10cc3 Mon Sep 17 00:00:00 2001 From: scb261 <65343233+scb261@users.noreply.github.com> Date: Sun, 14 Feb 2021 16:22:09 +0200 Subject: [PATCH] NineHentai: fix galleries with broken last page (#5841) --- src/all/ninehentai/build.gradle | 2 +- .../tachiyomi/extension/all/ninehentai/NineHentai.kt | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/all/ninehentai/build.gradle b/src/all/ninehentai/build.gradle index 108680474..6aa6a525a 100644 --- a/src/all/ninehentai/build.gradle +++ b/src/all/ninehentai/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'NineHentai' pkgNameSuffix = 'all.ninehentai' extClass = '.NineHentai' - extVersionCode = 8 + extVersionCode = 9 libVersion = '1.2' containsNsfw = true } diff --git a/src/all/ninehentai/src/eu/kanade/tachiyomi/extension/all/ninehentai/NineHentai.kt b/src/all/ninehentai/src/eu/kanade/tachiyomi/extension/all/ninehentai/NineHentai.kt index d45ecd78d..050f9ffc2 100644 --- a/src/all/ninehentai/src/eu/kanade/tachiyomi/extension/all/ninehentai/NineHentai.kt +++ b/src/all/ninehentai/src/eu/kanade/tachiyomi/extension/all/ninehentai/NineHentai.kt @@ -8,6 +8,7 @@ import com.google.gson.Gson import com.google.gson.JsonElement import com.google.gson.JsonParser import eu.kanade.tachiyomi.annotations.Nsfw +import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.POST import eu.kanade.tachiyomi.network.asObservableSuccess import eu.kanade.tachiyomi.source.model.Filter @@ -162,6 +163,15 @@ class NineHentai : HttpSource() { } val pages = mutableListOf() + client.newCall( + GET( + "$imageUrl/preview/${totalPages}t.jpg", + headersBuilder().build() + ) + ).execute().code().let { code -> + if (code == 404) totalPages-- + } + for (i in 1..totalPages) { pages.add(Page(pages.size, "", "$imageUrl/$i.jpg")) }