From 764c65563bc80ab7c662f95ba82def5d66e99e50 Mon Sep 17 00:00:00 2001 From: Koitharu Date: Mon, 23 Dec 2024 11:02:41 +0200 Subject: [PATCH] [Grouple] Fixes --- .../parsers/site/ru/grouple/AllHentaiParser.kt | 8 ++++---- .../kotatsu/parsers/site/ru/grouple/GroupleParser.kt | 12 ++++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ru/grouple/AllHentaiParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ru/grouple/AllHentaiParser.kt index 68e1a196..f11783bb 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ru/grouple/AllHentaiParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ru/grouple/AllHentaiParser.kt @@ -6,10 +6,7 @@ import org.koitharu.kotatsu.parsers.config.ConfigKey import org.koitharu.kotatsu.parsers.exception.AuthRequiredException import org.koitharu.kotatsu.parsers.model.ContentType import org.koitharu.kotatsu.parsers.model.MangaParserSource -import org.koitharu.kotatsu.parsers.util.domain -import org.koitharu.kotatsu.parsers.util.parseFailed -import org.koitharu.kotatsu.parsers.util.parseHtml -import org.koitharu.kotatsu.parsers.util.urlEncoded +import org.koitharu.kotatsu.parsers.util.* @MangaSourceParser("ALLHENTAI", "AllHentai", "ru", type = ContentType.HENTAI) internal class AllHentaiParser( @@ -25,6 +22,9 @@ internal class AllHentaiParser( ) override val defaultIsNsfw = true + override val isAuthorized: Boolean + get() = super.isAuthorized || context.cookieJar.getCookies(domain).any { it.name == "remember_me" } + override val authUrl: String get() { val targetUri = "https://$domain/".urlEncoded() diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ru/grouple/GroupleParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ru/grouple/GroupleParser.kt index 483f0682..6d5767bc 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ru/grouple/GroupleParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/ru/grouple/GroupleParser.kt @@ -525,15 +525,19 @@ internal abstract class GroupleParser( @Throws(IOException::class) private fun Response.checkIfAuthRequired(): Response { - if (code == HttpURLConnection.HTTP_NOT_FOUND && !isAuthorized) { - closeQuietly() - throw AuthRequiredException(source) - } val lastPathSegment = request.url.pathSegments.lastOrNull() if (lastPathSegment == "login") { closeQuietly() throw AuthRequiredException(source) } + if (code == HttpURLConnection.HTTP_NOT_FOUND) { + if (!isAuthorized) { + closeQuietly() + throw AuthRequiredException(source) + } else { + return newBuilder().code(HttpURLConnection.HTTP_OK).build() + } + } return this } }