[Grouple] Fixes
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user