[Grouple] Fixes

master
Koitharu 1 year ago
parent 2550b9cac1
commit 764c65563b
Signed by: Koitharu
GPG Key ID: 676DEE768C17A9D7

@ -6,10 +6,7 @@ import org.koitharu.kotatsu.parsers.config.ConfigKey
import org.koitharu.kotatsu.parsers.exception.AuthRequiredException import org.koitharu.kotatsu.parsers.exception.AuthRequiredException
import org.koitharu.kotatsu.parsers.model.ContentType import org.koitharu.kotatsu.parsers.model.ContentType
import org.koitharu.kotatsu.parsers.model.MangaParserSource import org.koitharu.kotatsu.parsers.model.MangaParserSource
import org.koitharu.kotatsu.parsers.util.domain import org.koitharu.kotatsu.parsers.util.*
import org.koitharu.kotatsu.parsers.util.parseFailed
import org.koitharu.kotatsu.parsers.util.parseHtml
import org.koitharu.kotatsu.parsers.util.urlEncoded
@MangaSourceParser("ALLHENTAI", "AllHentai", "ru", type = ContentType.HENTAI) @MangaSourceParser("ALLHENTAI", "AllHentai", "ru", type = ContentType.HENTAI)
internal class AllHentaiParser( internal class AllHentaiParser(
@ -25,6 +22,9 @@ internal class AllHentaiParser(
) )
override val defaultIsNsfw = true override val defaultIsNsfw = true
override val isAuthorized: Boolean
get() = super.isAuthorized || context.cookieJar.getCookies(domain).any { it.name == "remember_me" }
override val authUrl: String override val authUrl: String
get() { get() {
val targetUri = "https://$domain/".urlEncoded() val targetUri = "https://$domain/".urlEncoded()

@ -525,15 +525,19 @@ internal abstract class GroupleParser(
@Throws(IOException::class) @Throws(IOException::class)
private fun Response.checkIfAuthRequired(): Response { private fun Response.checkIfAuthRequired(): Response {
if (code == HttpURLConnection.HTTP_NOT_FOUND && !isAuthorized) {
closeQuietly()
throw AuthRequiredException(source)
}
val lastPathSegment = request.url.pathSegments.lastOrNull() val lastPathSegment = request.url.pathSegments.lastOrNull()
if (lastPathSegment == "login") { if (lastPathSegment == "login") {
closeQuietly() closeQuietly()
throw AuthRequiredException(source) 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 return this
} }
} }

Loading…
Cancel
Save