[RU]LibGroup optimize-clean (#16719)
* LibGroup more merge multisrc * LibGroup increase rateLimit for checkImage * url chapter no static * only delays access * sutoclean
This commit is contained in:
parent
32d7c88bd8
commit
a599f54b8c
|
@ -8,8 +8,6 @@ import eu.kanade.tachiyomi.multisrc.libgroup.LibGroup
|
||||||
import eu.kanade.tachiyomi.network.POST
|
import eu.kanade.tachiyomi.network.POST
|
||||||
import eu.kanade.tachiyomi.source.model.Filter
|
import eu.kanade.tachiyomi.source.model.Filter
|
||||||
import eu.kanade.tachiyomi.source.model.FilterList
|
import eu.kanade.tachiyomi.source.model.FilterList
|
||||||
import okhttp3.Headers
|
|
||||||
import okhttp3.OkHttpClient
|
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
@ -25,20 +23,6 @@ class HentaiLib : LibGroup("HentaiLib", "https://v1.hentailib.org", "ru") {
|
||||||
private var domain: String = preferences.getString(DOMAIN_TITLE, DOMAIN_DEFAULT)!!
|
private var domain: String = preferences.getString(DOMAIN_TITLE, DOMAIN_DEFAULT)!!
|
||||||
override val baseUrl: String = domain
|
override val baseUrl: String = domain
|
||||||
|
|
||||||
override val client: OkHttpClient = super.client.newBuilder()
|
|
||||||
.addInterceptor(::imageContentTypeIntercept)
|
|
||||||
.build()
|
|
||||||
|
|
||||||
private var csrfToken: String = ""
|
|
||||||
|
|
||||||
private fun catalogHeaders() = Headers.Builder()
|
|
||||||
.apply {
|
|
||||||
add("Accept", "application/json, text/plain, */*")
|
|
||||||
add("X-Requested-With", "XMLHttpRequest")
|
|
||||||
add("x-csrf-token", csrfToken)
|
|
||||||
}
|
|
||||||
.build()
|
|
||||||
|
|
||||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||||
if (csrfToken.isEmpty()) {
|
if (csrfToken.isEmpty()) {
|
||||||
val tokenResponse = client.newCall(popularMangaRequest(page)).execute()
|
val tokenResponse = client.newCall(popularMangaRequest(page)).execute()
|
||||||
|
|
|
@ -9,8 +9,6 @@ import eu.kanade.tachiyomi.multisrc.libgroup.LibGroup
|
||||||
import eu.kanade.tachiyomi.network.POST
|
import eu.kanade.tachiyomi.network.POST
|
||||||
import eu.kanade.tachiyomi.source.model.Filter
|
import eu.kanade.tachiyomi.source.model.Filter
|
||||||
import eu.kanade.tachiyomi.source.model.FilterList
|
import eu.kanade.tachiyomi.source.model.FilterList
|
||||||
import okhttp3.Headers
|
|
||||||
import okhttp3.OkHttpClient
|
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
@ -28,20 +26,6 @@ class MangaLib : LibGroup("MangaLib", "https://mangalib.me", "ru") {
|
||||||
private var domain: String? = preferences.getString(DOMAIN_PREF, baseOrig)
|
private var domain: String? = preferences.getString(DOMAIN_PREF, baseOrig)
|
||||||
override val baseUrl: String = domain.toString()
|
override val baseUrl: String = domain.toString()
|
||||||
|
|
||||||
override val client: OkHttpClient = super.client.newBuilder()
|
|
||||||
.addInterceptor(::imageContentTypeIntercept)
|
|
||||||
.build()
|
|
||||||
|
|
||||||
private var csrfToken: String = ""
|
|
||||||
|
|
||||||
private fun catalogHeaders() = Headers.Builder()
|
|
||||||
.apply {
|
|
||||||
add("Accept", "application/json, text/plain, */*")
|
|
||||||
add("X-Requested-With", "XMLHttpRequest")
|
|
||||||
add("x-csrf-token", csrfToken)
|
|
||||||
}
|
|
||||||
.build()
|
|
||||||
|
|
||||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||||
if (csrfToken.isEmpty()) {
|
if (csrfToken.isEmpty()) {
|
||||||
val tokenResponse = client.newCall(popularMangaRequest(page)).execute()
|
val tokenResponse = client.newCall(popularMangaRequest(page)).execute()
|
||||||
|
|
|
@ -8,8 +8,6 @@ import eu.kanade.tachiyomi.multisrc.libgroup.LibGroup
|
||||||
import eu.kanade.tachiyomi.network.POST
|
import eu.kanade.tachiyomi.network.POST
|
||||||
import eu.kanade.tachiyomi.source.model.Filter
|
import eu.kanade.tachiyomi.source.model.Filter
|
||||||
import eu.kanade.tachiyomi.source.model.FilterList
|
import eu.kanade.tachiyomi.source.model.FilterList
|
||||||
import okhttp3.Headers
|
|
||||||
import okhttp3.OkHttpClient
|
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
@ -23,20 +21,6 @@ class YaoiLib : LibGroup("YaoiLib", "https://v1.slashlib.me", "ru") {
|
||||||
private var domain: String = preferences.getString(DOMAIN_TITLE, DOMAIN_DEFAULT)!!
|
private var domain: String = preferences.getString(DOMAIN_TITLE, DOMAIN_DEFAULT)!!
|
||||||
override val baseUrl: String = domain
|
override val baseUrl: String = domain
|
||||||
|
|
||||||
override val client: OkHttpClient = super.client.newBuilder()
|
|
||||||
.addInterceptor(::imageContentTypeIntercept)
|
|
||||||
.build()
|
|
||||||
|
|
||||||
private var csrfToken: String = ""
|
|
||||||
|
|
||||||
private fun catalogHeaders() = Headers.Builder()
|
|
||||||
.apply {
|
|
||||||
add("Accept", "application/json, text/plain, */*")
|
|
||||||
add("X-Requested-With", "XMLHttpRequest")
|
|
||||||
add("x-csrf-token", csrfToken)
|
|
||||||
}
|
|
||||||
.build()
|
|
||||||
|
|
||||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||||
if (csrfToken.isEmpty()) {
|
if (csrfToken.isEmpty()) {
|
||||||
val tokenResponse = client.newCall(popularMangaRequest(page)).execute()
|
val tokenResponse = client.newCall(popularMangaRequest(page)).execute()
|
||||||
|
|
|
@ -9,7 +9,7 @@ class LibGenerator : ThemeSourceGenerator {
|
||||||
|
|
||||||
override val themeClass = "LibGroup"
|
override val themeClass = "LibGroup"
|
||||||
|
|
||||||
override val baseVersionCode: Int = 19
|
override val baseVersionCode: Int = 20
|
||||||
|
|
||||||
override val sources = listOf(
|
override val sources = listOf(
|
||||||
SingleLang("MangaLib", "https://mangalib.me", "ru", overrideVersionCode = 74),
|
SingleLang("MangaLib", "https://mangalib.me", "ru", overrideVersionCode = 74),
|
||||||
|
|
|
@ -45,7 +45,6 @@ import uy.kohesive.injekt.injectLazy
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import java.util.concurrent.TimeUnit
|
|
||||||
import kotlin.math.absoluteValue
|
import kotlin.math.absoluteValue
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
|
|
||||||
|
@ -63,7 +62,7 @@ abstract class LibGroup(
|
||||||
|
|
||||||
override val supportsLatest = true
|
override val supportsLatest = true
|
||||||
|
|
||||||
protected fun imageContentTypeIntercept(chain: Interceptor.Chain): Response {
|
private fun imageContentTypeIntercept(chain: Interceptor.Chain): Response {
|
||||||
val originalRequest = chain.request()
|
val originalRequest = chain.request()
|
||||||
val response = chain.proceed(originalRequest)
|
val response = chain.proceed(originalRequest)
|
||||||
val urlRequest = originalRequest.url.toString()
|
val urlRequest = originalRequest.url.toString()
|
||||||
|
@ -77,9 +76,8 @@ abstract class LibGroup(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
override val client: OkHttpClient = network.cloudflareClient.newBuilder()
|
override val client: OkHttpClient = network.cloudflareClient.newBuilder()
|
||||||
.connectTimeout(20, TimeUnit.SECONDS)
|
.rateLimit(3)
|
||||||
.readTimeout(30, TimeUnit.SECONDS)
|
.addNetworkInterceptor { imageContentTypeIntercept(it) }
|
||||||
.rateLimit(2)
|
|
||||||
.addInterceptor { chain ->
|
.addInterceptor { chain ->
|
||||||
val response = chain.proceed(chain.request())
|
val response = chain.proceed(chain.request())
|
||||||
if (response.code == 419) {
|
if (response.code == 419) {
|
||||||
|
@ -101,9 +99,9 @@ abstract class LibGroup(
|
||||||
|
|
||||||
private val userAgentRandomizer = "${Random.nextInt().absoluteValue}"
|
private val userAgentRandomizer = "${Random.nextInt().absoluteValue}"
|
||||||
|
|
||||||
private var csrfToken: String = ""
|
protected var csrfToken: String = ""
|
||||||
|
|
||||||
private fun catalogHeaders() = Headers.Builder()
|
protected fun catalogHeaders() = Headers.Builder()
|
||||||
.apply {
|
.apply {
|
||||||
add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 Edg/100.0.$userAgentRandomizer")
|
add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 Edg/100.0.$userAgentRandomizer")
|
||||||
add("Accept", "application/json, text/plain, */*")
|
add("Accept", "application/json, text/plain, */*")
|
||||||
|
@ -395,7 +393,7 @@ abstract class LibGroup(
|
||||||
|
|
||||||
val teamId = if (teamIdParam != null) "&bid=$teamIdParam" else ""
|
val teamId = if (teamIdParam != null) "&bid=$teamIdParam" else ""
|
||||||
|
|
||||||
val url = "$baseUrl/$slug/v$volume/c$number?ui=$userId$teamId"
|
val url = "/$slug/v$volume/c$number?ui=$userId$teamId"
|
||||||
|
|
||||||
chapter.setUrlWithoutDomain(url)
|
chapter.setUrlWithoutDomain(url)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue