Update parsers
This commit is contained in:
3
.idea/.gitignore
generated
vendored
3
.idea/.gitignore
generated
vendored
@@ -5,4 +5,5 @@ misc.xml
|
||||
kotlinc.xml
|
||||
vcs.xml
|
||||
/inspectionProfiles/
|
||||
/artifacts/
|
||||
/artifacts/
|
||||
/kotlin-statistics.xml
|
||||
|
||||
@@ -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:764c65563b")
|
||||
implementation("com.github.KotatsuApp:kotatsu-parsers:1.6")
|
||||
implementation("com.squareup.okhttp3:okhttp:4.12.0")
|
||||
implementation("com.squareup.okio:okio:3.9.0")
|
||||
implementation("io.webfolder:quickjs:1.1.0")
|
||||
|
||||
@@ -5,9 +5,9 @@ import kotlinx.coroutines.runInterruptible
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import okhttp3.internal.closeQuietly
|
||||
import org.koitharu.kotatsu.dl.util.toFileNameSafe
|
||||
import org.koitharu.kotatsu.parsers.model.Manga
|
||||
import org.koitharu.kotatsu.parsers.model.MangaChapter
|
||||
import org.koitharu.kotatsu.parsers.util.toFileNameSafe
|
||||
import java.io.File
|
||||
|
||||
class LocalMangaDirOutput(
|
||||
|
||||
@@ -5,9 +5,9 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.runInterruptible
|
||||
import okio.Closeable
|
||||
import org.koitharu.kotatsu.dl.util.getNextAvailable
|
||||
import org.koitharu.kotatsu.dl.util.toFileNameSafe
|
||||
import org.koitharu.kotatsu.parsers.model.Manga
|
||||
import org.koitharu.kotatsu.parsers.model.MangaChapter
|
||||
import org.koitharu.kotatsu.parsers.util.toFileNameSafe
|
||||
import java.io.File
|
||||
|
||||
sealed class LocalMangaOutput(
|
||||
|
||||
@@ -64,7 +64,7 @@ class MangaDownloader(
|
||||
val totalChapters = chaptersRange.size(chapters)
|
||||
try {
|
||||
val parser = context.newParserInstance(manga.source as MangaParserSource)
|
||||
val coverUrl = manga.largeCoverUrl.ifNullOrEmpty { manga.coverUrl }
|
||||
val coverUrl = manga.largeCoverUrl.ifNullOrEmpty { manga.coverUrl.orEmpty() }
|
||||
if (coverUrl.isNotEmpty()) {
|
||||
downloadFile(coverUrl, tempDir, parser.source).let { file ->
|
||||
output.addCover(file, getFileExtensionFromUrl(coverUrl).orEmpty())
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.koitharu.kotatsu.dl.util
|
||||
|
||||
import androidx.collection.IntList
|
||||
import androidx.collection.arraySetOf
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||
import okhttp3.Response
|
||||
import okhttp3.internal.closeQuietly
|
||||
@@ -51,3 +52,32 @@ fun File.getNextAvailable(): File {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun String.transliterate(skipMissing: Boolean): String {
|
||||
val cyr = charArrayOf(
|
||||
'а', 'б', 'в', 'г', 'д', 'е', 'ж', 'з', 'и', 'й', 'к', 'л', 'м', 'н', 'о', 'п',
|
||||
'р', 'с', 'т', 'у', 'ф', 'х', 'ц', 'ч', 'ш', 'щ', 'ъ', 'ы', 'ь', 'э', 'ю', 'я', 'ё', 'ў',
|
||||
)
|
||||
val lat = arrayOf(
|
||||
"a", "b", "v", "g", "d", "e", "zh", "z", "i", "y", "k", "l", "m", "n", "o", "p",
|
||||
"r", "s", "t", "u", "f", "h", "ts", "ch", "sh", "sch", "", "i", "", "e", "ju", "ja", "jo", "w",
|
||||
)
|
||||
return buildString(length + 5) {
|
||||
for (c in this@transliterate) {
|
||||
val p = cyr.binarySearch(c.lowercaseChar())
|
||||
if (p in lat.indices) {
|
||||
if (c.isUpperCase()) {
|
||||
append(lat[p].uppercase())
|
||||
} else {
|
||||
append(lat[p])
|
||||
}
|
||||
} else if (!skipMissing) {
|
||||
append(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun String.toFileNameSafe(): String = this.transliterate(false)
|
||||
.replace(Regex("[^a-z0-9_\\-]", arraySetOf(RegexOption.IGNORE_CASE)), " ")
|
||||
.replace(Regex("\\s+"), "_")
|
||||
Reference in New Issue
Block a user