|
|
|
@ -5,6 +5,8 @@ import okhttp3.HttpUrl.Companion.toHttpUrl
|
|
|
|
import okhttp3.Response
|
|
|
|
import okhttp3.Response
|
|
|
|
import org.json.JSONArray
|
|
|
|
import org.json.JSONArray
|
|
|
|
import org.koitharu.kotatsu.parsers.MangaParser
|
|
|
|
import org.koitharu.kotatsu.parsers.MangaParser
|
|
|
|
|
|
|
|
import org.koitharu.kotatsu.parsers.MangaParserAuthProvider
|
|
|
|
|
|
|
|
import org.koitharu.kotatsu.parsers.exception.AuthRequiredException
|
|
|
|
import org.koitharu.kotatsu.parsers.model.*
|
|
|
|
import org.koitharu.kotatsu.parsers.model.*
|
|
|
|
import org.koitharu.kotatsu.parsers.util.*
|
|
|
|
import org.koitharu.kotatsu.parsers.util.*
|
|
|
|
import org.koitharu.kotatsu.parsers.util.json.mapJSON
|
|
|
|
import org.koitharu.kotatsu.parsers.util.json.mapJSON
|
|
|
|
@ -16,7 +18,8 @@ private const val PAGE_SIZE_SEARCH = 50
|
|
|
|
private const val NSFW_ALERT = "сексуальные сцены"
|
|
|
|
private const val NSFW_ALERT = "сексуальные сцены"
|
|
|
|
private const val NOTHING_FOUND = "Ничего не найдено"
|
|
|
|
private const val NOTHING_FOUND = "Ничего не найдено"
|
|
|
|
|
|
|
|
|
|
|
|
internal abstract class GroupleParser(source: MangaSource, userAgent: String) : MangaParser(source) {
|
|
|
|
internal abstract class GroupleParser(source: MangaSource, userAgent: String) : MangaParser(source),
|
|
|
|
|
|
|
|
MangaParserAuthProvider {
|
|
|
|
|
|
|
|
|
|
|
|
private val headers = Headers.Builder()
|
|
|
|
private val headers = Headers.Builder()
|
|
|
|
.add("User-Agent", userAgent)
|
|
|
|
.add("User-Agent", userAgent)
|
|
|
|
@ -29,6 +32,12 @@ internal abstract class GroupleParser(source: MangaSource, userAgent: String) :
|
|
|
|
SortOrder.RATING,
|
|
|
|
SortOrder.RATING,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override val authUrl: String
|
|
|
|
|
|
|
|
get() = "https://grouple.co/internal/auth/login"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override val isAuthorized: Boolean
|
|
|
|
|
|
|
|
get() = context.cookieJar.getCookies(getDomain()).any { it.name == "gwt" }
|
|
|
|
|
|
|
|
|
|
|
|
override suspend fun getList(
|
|
|
|
override suspend fun getList(
|
|
|
|
offset: Int,
|
|
|
|
offset: Int,
|
|
|
|
query: String?,
|
|
|
|
query: String?,
|
|
|
|
@ -45,18 +54,21 @@ internal abstract class GroupleParser(source: MangaSource, userAgent: String) :
|
|
|
|
),
|
|
|
|
),
|
|
|
|
headers,
|
|
|
|
headers,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
tags.isNullOrEmpty() -> context.httpGet(
|
|
|
|
tags.isNullOrEmpty() -> context.httpGet(
|
|
|
|
"https://$domain/list?sortType=${
|
|
|
|
"https://$domain/list?sortType=${
|
|
|
|
getSortKey(sortOrder)
|
|
|
|
getSortKey(sortOrder)
|
|
|
|
}&offset=${offset upBy PAGE_SIZE}",
|
|
|
|
}&offset=${offset upBy PAGE_SIZE}",
|
|
|
|
headers,
|
|
|
|
headers,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
tags.size == 1 -> context.httpGet(
|
|
|
|
tags.size == 1 -> context.httpGet(
|
|
|
|
"https://$domain/list/genre/${tags.first().key}?sortType=${
|
|
|
|
"https://$domain/list/genre/${tags.first().key}?sortType=${
|
|
|
|
getSortKey(sortOrder)
|
|
|
|
getSortKey(sortOrder)
|
|
|
|
}&offset=${offset upBy PAGE_SIZE}",
|
|
|
|
}&offset=${offset upBy PAGE_SIZE}",
|
|
|
|
headers,
|
|
|
|
headers,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
offset > 0 -> return emptyList()
|
|
|
|
offset > 0 -> return emptyList()
|
|
|
|
else -> advancedSearch(domain, tags)
|
|
|
|
else -> advancedSearch(domain, tags)
|
|
|
|
}.parseHtml().body()
|
|
|
|
}.parseHtml().body()
|
|
|
|
@ -230,6 +242,15 @@ internal abstract class GroupleParser(source: MangaSource, userAgent: String) :
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override suspend fun getUsername(): String {
|
|
|
|
|
|
|
|
val root = context.httpGet("https://grouple.co/").parseHtml().body()
|
|
|
|
|
|
|
|
val element = root.selectFirst("img.user-avatar") ?: throw AuthRequiredException(source)
|
|
|
|
|
|
|
|
val res = element.parent()?.text()
|
|
|
|
|
|
|
|
return if (res.isNullOrEmpty()) {
|
|
|
|
|
|
|
|
parseFailed("Cannot find username")
|
|
|
|
|
|
|
|
} else res
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun getSortKey(sortOrder: SortOrder) =
|
|
|
|
private fun getSortKey(sortOrder: SortOrder) =
|
|
|
|
when (sortOrder) {
|
|
|
|
when (sortOrder) {
|
|
|
|
SortOrder.ALPHABETICAL -> "name"
|
|
|
|
SortOrder.ALPHABETICAL -> "name"
|
|
|
|
|