From c2b79b55f87795b7abee68d5b2cdff25a3b5be27 Mon Sep 17 00:00:00 2001 From: Koitharu Date: Thu, 22 Jun 2023 14:28:47 +0300 Subject: [PATCH] Update dependencies --- .idea/kotlinc.xml | 2 +- build.gradle | 34 +++++------ settings.gradle | 4 +- .../kotatsu/parsers/site/BatoToParser.kt | 1 + .../kotatsu/parsers/AuthCheckExtension.kt | 42 +++++++------- .../parsers/CommonHeadersInterceptor.kt | 58 +++++++++---------- 6 files changed, 71 insertions(+), 70 deletions(-) diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml index 7e340a77..9a55c2de 100644 --- a/.idea/kotlinc.xml +++ b/.idea/kotlinc.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/build.gradle b/build.gradle index cbf87048..ecebca93 100644 --- a/build.gradle +++ b/build.gradle @@ -18,10 +18,10 @@ compileKotlin { kotlinOptions { jvmTarget = '1.8' freeCompilerArgs += [ - '-opt-in=kotlin.RequiresOptIn', - '-opt-in=kotlin.contracts.ExperimentalContracts', - '-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi', - '-opt-in=org.koitharu.kotatsu.parsers.InternalParsersApi', + '-opt-in=kotlin.RequiresOptIn', + '-opt-in=kotlin.contracts.ExperimentalContracts', + '-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi', + '-opt-in=org.koitharu.kotatsu.parsers.InternalParsersApi', ] } } @@ -30,9 +30,9 @@ compileTestKotlin { kotlinOptions { jvmTarget = '1.8' freeCompilerArgs += [ - '-opt-in=kotlin.RequiresOptIn', - '-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi', - '-opt-in=org.koitharu.kotatsu.parsers.InternalParsersApi', + '-opt-in=kotlin.RequiresOptIn', + '-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi', + '-opt-in=org.koitharu.kotatsu.parsers.InternalParsersApi', ] } } @@ -54,21 +54,21 @@ afterEvaluate { } dependencies { - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4' - implementation 'com.squareup.okhttp3:okhttp:4.10.0' - implementation 'com.squareup.okio:okio:3.2.0' - api 'org.jsoup:jsoup:1.15.3' - implementation 'org.json:json:20220320' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1' + implementation 'com.squareup.okhttp3:okhttp:4.11.0' + implementation 'com.squareup.okio:okio:3.3.0' + api 'org.jsoup:jsoup:1.16.1' + implementation 'org.json:json:20230618' implementation 'androidx.collection:collection-ktx:1.2.0' ksp project(':kotatsu-parsers-ksp') - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0' - testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.9.0' - testImplementation 'org.junit.jupiter:junit-jupiter-params:5.9.0' - testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4' + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.3' + testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.9.3' + testImplementation 'org.junit.jupiter:junit-jupiter-params:5.9.3' + testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.1' testImplementation 'io.webfolder:quickjs:1.1.0' } //noinspection ConfigurationAvoidance -task generateTestsReport(type: ReportGenerateTask) \ No newline at end of file +task generateTestsReport(type: ReportGenerateTask) diff --git a/settings.gradle b/settings.gradle index 2d2465a8..95cda867 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,7 +1,7 @@ pluginManagement { plugins { - id 'com.google.devtools.ksp' version '1.6.21-1.0.5' - id 'org.jetbrains.kotlin.jvm' version '1.6.21' + id 'com.google.devtools.ksp' version '1.8.22-1.0.11' + id 'org.jetbrains.kotlin.jvm' version '1.8.22' } repositories { gradlePluginPortal() diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/BatoToParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/BatoToParser.kt index 43b0df9e..49c3b4c1 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/BatoToParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/BatoToParser.kt @@ -65,6 +65,7 @@ internal class BatoToParser(context: MangaLoaderContext) : PagedMangaParser( SortOrder.POPULARITY -> append("views_a.za") SortOrder.NEWEST -> append("create.za") SortOrder.ALPHABETICAL -> append("title.az") + SortOrder.RATING -> Unit } if (!tags.isNullOrEmpty()) { append("&genres=") diff --git a/src/test/kotlin/org/koitharu/kotatsu/parsers/AuthCheckExtension.kt b/src/test/kotlin/org/koitharu/kotatsu/parsers/AuthCheckExtension.kt index 05ab3c6f..3003a07c 100644 --- a/src/test/kotlin/org/koitharu/kotatsu/parsers/AuthCheckExtension.kt +++ b/src/test/kotlin/org/koitharu/kotatsu/parsers/AuthCheckExtension.kt @@ -8,27 +8,27 @@ import org.koitharu.kotatsu.parsers.util.runCatchingCancellable class AuthCheckExtension : BeforeAllCallback { - private val loaderContext: MangaLoaderContext = MangaLoaderContextMock + private val loaderContext: MangaLoaderContext = MangaLoaderContextMock - override fun beforeAll(context: ExtensionContext) { - for (source in MangaSource.values()) { - if (source == MangaSource.LOCAL || source == MangaSource.DUMMY) { - continue - } - val parser = source.newParser(loaderContext) - if (parser is MangaParserAuthProvider) { - checkAuthorization(source, parser) - } - } - } + override fun beforeAll(context: ExtensionContext) { + for (source in MangaSource.values()) { + if (source == MangaSource.LOCAL || source == MangaSource.DUMMY) { + continue + } + val parser = loaderContext.newParserInstance(source) + if (parser is MangaParserAuthProvider) { + checkAuthorization(source, parser) + } + } + } - private fun checkAuthorization(source: MangaSource, parser: MangaParserAuthProvider) = runTest { - runCatchingCancellable { - parser.getUsername() - }.onSuccess { username -> - println("Signed in to ${source.name} as $username") - }.onFailure { error -> - System.err.println("Auth failed for ${source.name}: ${error.javaClass.name}(${error.message})") - } - } + private fun checkAuthorization(source: MangaSource, parser: MangaParserAuthProvider) = runTest { + runCatchingCancellable { + parser.getUsername() + }.onSuccess { username -> + println("Signed in to ${source.name} as $username") + }.onFailure { error -> + System.err.println("Auth failed for ${source.name}: ${error.javaClass.name}(${error.message})") + } + } } diff --git a/src/test/kotlin/org/koitharu/kotatsu/parsers/CommonHeadersInterceptor.kt b/src/test/kotlin/org/koitharu/kotatsu/parsers/CommonHeadersInterceptor.kt index 73236481..48d31bc5 100644 --- a/src/test/kotlin/org/koitharu/kotatsu/parsers/CommonHeadersInterceptor.kt +++ b/src/test/kotlin/org/koitharu/kotatsu/parsers/CommonHeadersInterceptor.kt @@ -11,37 +11,37 @@ private const val HEADER_USER_AGENT = "User-Agent" private const val HEADER_REFERER = "Referer" internal class CommonHeadersInterceptor( - private val userAgent: String, + private val userAgent: String, ) : Interceptor { - override fun intercept(chain: Interceptor.Chain): Response { - val request = chain.request() - val source = request.tag(MangaSource::class.java) - val parser = source?.newParser(MangaLoaderContextMock) - val sourceHeaders = parser?.headers - val headersBuilder = request.headers.newBuilder() - if (sourceHeaders != null) { - headersBuilder.mergeWith(sourceHeaders, replaceExisting = false) - } - if (headersBuilder[HEADER_USER_AGENT] == null) { - headersBuilder[HEADER_USER_AGENT] = userAgent - } - if (headersBuilder[HEADER_REFERER] == null && parser != null) { - headersBuilder[HEADER_REFERER] = "https://${parser.domain}/" - } - val newRequest = request.newBuilder().headers(headersBuilder.build()).build() - return if (parser is Interceptor) { - parser.intercept(ProxyChain(chain, newRequest)) - } else { - return chain.proceed(newRequest) - } - } + override fun intercept(chain: Interceptor.Chain): Response { + val request = chain.request() + val source = request.tag(MangaSource::class.java) + val parser = source?.let { MangaLoaderContextMock.newParserInstance(it) } + val sourceHeaders = parser?.headers + val headersBuilder = request.headers.newBuilder() + if (sourceHeaders != null) { + headersBuilder.mergeWith(sourceHeaders, replaceExisting = false) + } + if (headersBuilder[HEADER_USER_AGENT] == null) { + headersBuilder[HEADER_USER_AGENT] = userAgent + } + if (headersBuilder[HEADER_REFERER] == null && parser != null) { + headersBuilder[HEADER_REFERER] = "https://${parser.domain}/" + } + val newRequest = request.newBuilder().headers(headersBuilder.build()).build() + return if (parser is Interceptor) { + parser.intercept(ProxyChain(chain, newRequest)) + } else { + return chain.proceed(newRequest) + } + } - private class ProxyChain( - private val delegate: Interceptor.Chain, - private val request: Request, - ) : Interceptor.Chain by delegate { + private class ProxyChain( + private val delegate: Interceptor.Chain, + private val request: Request, + ) : Interceptor.Chain by delegate { - override fun request(): Request = request - } + override fun request(): Request = request + } }