Update parsers

This commit is contained in:
Koitharu
2024-10-18 09:04:17 +03:00
parent 57e7c8d685
commit 7c2c037654
3 changed files with 6 additions and 10 deletions

View File

@@ -31,7 +31,7 @@ dependencies {
testImplementation(kotlin("test"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.9.0")
implementation("com.github.ajalt.clikt:clikt-core:5.0.1")
implementation("com.github.KotatsuApp:kotatsu-parsers:481fb4f0d0")
implementation("com.github.KotatsuApp:kotatsu-parsers:08fe54c36d")
implementation("com.squareup.okhttp3:okhttp:4.12.0")
implementation("com.squareup.okio:okio:3.9.0")
implementation("io.webfolder:quickjs:1.1.0")

View File

@@ -1,7 +1,6 @@
package org.koitharu.kotatsu.dl
import com.github.ajalt.clikt.command.main
import com.github.ajalt.clikt.core.ProgramResult
import com.github.ajalt.clikt.parameters.arguments.argument
import com.github.ajalt.clikt.parameters.options.*
import com.github.ajalt.clikt.parameters.types.enum
@@ -68,10 +67,10 @@ class Main : AppCommand(name = "kotatsu-dl") {
val linkResolver = context.newLinkResolver(link)
print("Resolving link…")
val source = linkResolver.getSource()
val manga = linkResolver.getManga()
if (source == null) {
println()
System.err.println("Unsupported manga source")
return 1
error("Unsupported manga source")
}
println('\r')
colored {
@@ -79,10 +78,8 @@ class Main : AppCommand(name = "kotatsu-dl") {
print(source.title.bold)
println()
}
val manga = linkResolver.getManga()
if (manga == null) {
System.err.println("Manga not found")
return 1
error("Manga not found")
}
colored {
print("Title: ".cyan)
@@ -90,8 +87,7 @@ class Main : AppCommand(name = "kotatsu-dl") {
}
var chapters = manga.chapters
if (chapters.isNullOrEmpty()) {
System.err.println("Manga contains no chapters")
throw ProgramResult(1)
error("Manga contains no chapters")
}
chapters = askSelectBranch(chapters)
colored {

View File

@@ -39,7 +39,7 @@ abstract class AppCommand(name: String) : CoreSuspendingCliktCommand(name) {
val exitCode = try {
invoke()
} catch (e: IllegalStateException) {
throw PrintMessage(e.message.ifNullOrEmpty { GENERIC_ERROR_MSG }, 2, true)
throw PrintMessage(e.message.ifNullOrEmpty { GENERIC_ERROR_MSG }, 1, true)
} catch (e: NotImplementedError) {
throw PrintMessage(e.message.ifNullOrEmpty { GENERIC_ERROR_MSG }, 2, true)
}