Update parsers
This commit is contained in:
@@ -16,8 +16,8 @@ android {
|
|||||||
applicationId 'org.koitharu.kotatsu'
|
applicationId 'org.koitharu.kotatsu'
|
||||||
minSdk = 21
|
minSdk = 21
|
||||||
targetSdk = 35
|
targetSdk = 35
|
||||||
versionCode = 672
|
versionCode = 673
|
||||||
versionName = '7.6-b1'
|
versionName = '7.6'
|
||||||
generatedDensities = []
|
generatedDensities = []
|
||||||
testInstrumentationRunner 'org.koitharu.kotatsu.HiltTestRunner'
|
testInstrumentationRunner 'org.koitharu.kotatsu.HiltTestRunner'
|
||||||
ksp {
|
ksp {
|
||||||
@@ -83,7 +83,7 @@ afterEvaluate {
|
|||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
//noinspection GradleDependency
|
//noinspection GradleDependency
|
||||||
implementation('com.github.KotatsuApp:kotatsu-parsers:cc62981f12') {
|
implementation('com.github.KotatsuApp:kotatsu-parsers:3cdd391410') {
|
||||||
exclude group: 'org.json', module: 'json'
|
exclude group: 'org.json', module: 'json'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,10 @@ val ContentType.titleResId
|
|||||||
ContentType.MANHUA -> R.string.content_type_manhua
|
ContentType.MANHUA -> R.string.content_type_manhua
|
||||||
ContentType.NOVEL -> R.string.content_type_novel
|
ContentType.NOVEL -> R.string.content_type_novel
|
||||||
ContentType.ONE_SHOT -> R.string.content_type_one_shot
|
ContentType.ONE_SHOT -> R.string.content_type_one_shot
|
||||||
|
ContentType.DOUJINSHI -> R.string.content_type_doujinshi
|
||||||
|
ContentType.IMAGE_SET -> R.string.content_type_image_set
|
||||||
|
ContentType.ARTIST_CG -> R.string.content_type_artist_cg
|
||||||
|
ContentType.GAME_CG -> R.string.content_type_game_cg
|
||||||
}
|
}
|
||||||
|
|
||||||
tailrec fun MangaSource.unwrap(): MangaSource = if (this is MangaSourceInfo) {
|
tailrec fun MangaSource.unwrap(): MangaSource = if (this is MangaSourceInfo) {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import android.graphics.Rect as AndroidRect
|
|||||||
|
|
||||||
class BitmapWrapper private constructor(
|
class BitmapWrapper private constructor(
|
||||||
private val androidBitmap: AndroidBitmap,
|
private val androidBitmap: AndroidBitmap,
|
||||||
) : Bitmap {
|
) : Bitmap, AutoCloseable {
|
||||||
|
|
||||||
private val canvas by lazy { Canvas(androidBitmap) } // is not always used, so initialized lazily
|
private val canvas by lazy { Canvas(androidBitmap) } // is not always used, so initialized lazily
|
||||||
|
|
||||||
@@ -24,17 +24,21 @@ class BitmapWrapper private constructor(
|
|||||||
canvas.drawBitmap(androidSourceBitmap, src.toAndroidRect(), dst.toAndroidRect(), null)
|
canvas.drawBitmap(androidSourceBitmap, src.toAndroidRect(), dst.toAndroidRect(), null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun close() {
|
||||||
|
androidBitmap.recycle()
|
||||||
|
}
|
||||||
|
|
||||||
fun compressTo(output: OutputStream) {
|
fun compressTo(output: OutputStream) {
|
||||||
androidBitmap.compress(AndroidBitmap.CompressFormat.PNG, 100, output)
|
androidBitmap.compress(AndroidBitmap.CompressFormat.PNG, 100, output)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
fun create(width: Int, height: Int): Bitmap = BitmapWrapper(
|
fun create(width: Int, height: Int) = BitmapWrapper(
|
||||||
AndroidBitmap.createBitmap(width, height, AndroidBitmap.Config.ARGB_8888),
|
AndroidBitmap.createBitmap(width, height, AndroidBitmap.Config.ARGB_8888),
|
||||||
)
|
)
|
||||||
|
|
||||||
fun create(bitmap: AndroidBitmap): Bitmap = BitmapWrapper(
|
fun create(bitmap: AndroidBitmap) = BitmapWrapper(
|
||||||
if (bitmap.isMutable) bitmap else bitmap.copy(AndroidBitmap.Config.ARGB_8888, true),
|
if (bitmap.isMutable) bitmap else bitmap.copy(AndroidBitmap.Config.ARGB_8888, true),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -21,14 +21,15 @@ import org.koitharu.kotatsu.core.network.cookies.MutableCookieJar
|
|||||||
import org.koitharu.kotatsu.core.prefs.SourceSettings
|
import org.koitharu.kotatsu.core.prefs.SourceSettings
|
||||||
import org.koitharu.kotatsu.core.util.ext.configureForParser
|
import org.koitharu.kotatsu.core.util.ext.configureForParser
|
||||||
import org.koitharu.kotatsu.core.util.ext.printStackTraceDebug
|
import org.koitharu.kotatsu.core.util.ext.printStackTraceDebug
|
||||||
import org.koitharu.kotatsu.core.util.ext.requireBody
|
|
||||||
import org.koitharu.kotatsu.core.util.ext.sanitizeHeaderValue
|
import org.koitharu.kotatsu.core.util.ext.sanitizeHeaderValue
|
||||||
import org.koitharu.kotatsu.core.util.ext.toList
|
import org.koitharu.kotatsu.core.util.ext.toList
|
||||||
|
import org.koitharu.kotatsu.core.util.ext.use
|
||||||
import org.koitharu.kotatsu.parsers.MangaLoaderContext
|
import org.koitharu.kotatsu.parsers.MangaLoaderContext
|
||||||
import org.koitharu.kotatsu.parsers.bitmap.Bitmap
|
import org.koitharu.kotatsu.parsers.bitmap.Bitmap
|
||||||
import org.koitharu.kotatsu.parsers.config.MangaSourceConfig
|
import org.koitharu.kotatsu.parsers.config.MangaSourceConfig
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaSource
|
import org.koitharu.kotatsu.parsers.model.MangaSource
|
||||||
import org.koitharu.kotatsu.parsers.network.UserAgents
|
import org.koitharu.kotatsu.parsers.network.UserAgents
|
||||||
|
import org.koitharu.kotatsu.parsers.util.map
|
||||||
import java.lang.ref.WeakReference
|
import java.lang.ref.WeakReference
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@@ -76,32 +77,25 @@ class MangaLoaderContextImpl @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun redrawImageResponse(response: Response, redraw: (image: Bitmap) -> Bitmap): Response {
|
override fun redrawImageResponse(response: Response, redraw: (image: Bitmap) -> Bitmap): Response {
|
||||||
val image = response.requireBody().byteStream()
|
return response.map { body ->
|
||||||
|
val opts = BitmapFactory.Options()
|
||||||
val opts = BitmapFactory.Options()
|
opts.inMutable = true
|
||||||
opts.inMutable = true
|
BitmapFactory.decodeStream(body.byteStream(), null, opts)?.use { bitmap ->
|
||||||
val bitmap = BitmapFactory.decodeStream(image, null, opts) ?: error("Cannot decode bitmap")
|
(redraw(BitmapWrapper.create(bitmap)) as BitmapWrapper).use { result ->
|
||||||
val result = redraw(BitmapWrapper.create(bitmap)) as BitmapWrapper
|
Buffer().also {
|
||||||
|
result.compressTo(it.outputStream())
|
||||||
val body = Buffer().also {
|
}.asResponseBody("image/jpeg".toMediaType())
|
||||||
result.compressTo(it.outputStream())
|
}
|
||||||
}.asResponseBody("image/jpeg".toMediaType())
|
} ?: error("Cannot decode bitmap")
|
||||||
|
}
|
||||||
return response.newBuilder()
|
|
||||||
.body(body)
|
|
||||||
.build()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createBitmap(width: Int, height: Int): Bitmap {
|
override fun createBitmap(width: Int, height: Int): Bitmap = BitmapWrapper.create(width, height)
|
||||||
return BitmapWrapper.create(width, height)
|
|
||||||
}
|
|
||||||
|
|
||||||
@MainThread
|
@MainThread
|
||||||
private fun obtainWebView(): WebView {
|
private fun obtainWebView(): WebView = webViewCached?.get() ?: WebView(androidContext).also {
|
||||||
return webViewCached?.get() ?: WebView(androidContext).also {
|
it.configureForParser(null)
|
||||||
it.configureForParser(null)
|
webViewCached = WeakReference(it)
|
||||||
webViewCached = WeakReference(it)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun obtainWebViewUserAgent(): String {
|
private fun obtainWebViewUserAgent(): String {
|
||||||
|
|||||||
@@ -37,12 +37,12 @@ import org.koitharu.kotatsu.core.parser.EmptyMangaRepository
|
|||||||
import org.koitharu.kotatsu.core.parser.MangaRepository
|
import org.koitharu.kotatsu.core.parser.MangaRepository
|
||||||
import org.koitharu.kotatsu.core.parser.ParserMangaRepository
|
import org.koitharu.kotatsu.core.parser.ParserMangaRepository
|
||||||
import org.koitharu.kotatsu.core.parser.external.ExternalMangaRepository
|
import org.koitharu.kotatsu.core.parser.external.ExternalMangaRepository
|
||||||
import org.koitharu.kotatsu.core.util.ext.requireBody
|
|
||||||
import org.koitharu.kotatsu.core.util.ext.writeAllCancellable
|
import org.koitharu.kotatsu.core.util.ext.writeAllCancellable
|
||||||
import org.koitharu.kotatsu.local.data.CacheDir
|
import org.koitharu.kotatsu.local.data.CacheDir
|
||||||
import org.koitharu.kotatsu.local.data.util.withExtraCloseable
|
import org.koitharu.kotatsu.local.data.util.withExtraCloseable
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaSource
|
import org.koitharu.kotatsu.parsers.model.MangaSource
|
||||||
import org.koitharu.kotatsu.parsers.util.await
|
import org.koitharu.kotatsu.parsers.util.await
|
||||||
|
import org.koitharu.kotatsu.parsers.util.requireBody
|
||||||
import java.net.HttpURLConnection
|
import java.net.HttpURLConnection
|
||||||
import kotlin.coroutines.coroutineContext
|
import kotlin.coroutines.coroutineContext
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import okhttp3.HttpUrl
|
|||||||
import okhttp3.MediaType.Companion.toMediaType
|
import okhttp3.MediaType.Companion.toMediaType
|
||||||
import okhttp3.RequestBody.Companion.toRequestBody
|
import okhttp3.RequestBody.Companion.toRequestBody
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.ResponseBody
|
|
||||||
import okhttp3.internal.closeQuietly
|
import okhttp3.internal.closeQuietly
|
||||||
import okio.IOException
|
import okio.IOException
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
@@ -41,8 +40,6 @@ fun Response.ensureSuccess() = apply {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Response.requireBody(): ResponseBody = checkNotNull(body) { "Response body is null" }
|
|
||||||
|
|
||||||
fun Cookie.newBuilder(): Cookie.Builder = Cookie.Builder().also { c ->
|
fun Cookie.newBuilder(): Cookie.Builder = Cookie.Builder().also { c ->
|
||||||
c.name(name)
|
c.name(name)
|
||||||
c.value(value)
|
c.value(value)
|
||||||
|
|||||||
@@ -729,4 +729,8 @@
|
|||||||
<string name="filter_search_warning">This source does not support search with filters. Your filters have been cleared</string>
|
<string name="filter_search_warning">This source does not support search with filters. Your filters have been cleared</string>
|
||||||
<string name="demographic_kodomo">Kodomo</string>
|
<string name="demographic_kodomo">Kodomo</string>
|
||||||
<string name="content_type_one_shot">One shot</string>
|
<string name="content_type_one_shot">One shot</string>
|
||||||
|
<string name="content_type_doujinshi">Doujinshi</string>
|
||||||
|
<string name="content_type_image_set">Image set</string>
|
||||||
|
<string name="content_type_artist_cg">Artist CG</string>
|
||||||
|
<string name="content_type_game_cg">Game CG</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user