From de13abf7011759d9f63456e710289ee9236a0416 Mon Sep 17 00:00:00 2001 From: Alessandro Jean Date: Mon, 1 Feb 2021 19:47:23 -0300 Subject: [PATCH] Fix exception when there is no description or key. (#5604) --- src/en/vizshonenjump/build.gradle | 2 +- .../extension/en/vizshonenjump/VizImageInterceptor.kt | 8 +++----- .../extension/en/vizshonenjump/VizShonenJump.kt | 10 +++++++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/en/vizshonenjump/build.gradle b/src/en/vizshonenjump/build.gradle index 2d8b60ffa..d3e574ae7 100644 --- a/src/en/vizshonenjump/build.gradle +++ b/src/en/vizshonenjump/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'VIZ Shonen Jump' pkgNameSuffix = 'en.vizshonenjump' extClass = '.VizShonenJump' - extVersionCode = 5 + extVersionCode = 6 libVersion = '1.2' } diff --git a/src/en/vizshonenjump/src/eu/kanade/tachiyomi/extension/en/vizshonenjump/VizImageInterceptor.kt b/src/en/vizshonenjump/src/eu/kanade/tachiyomi/extension/en/vizshonenjump/VizImageInterceptor.kt index 7666075c4..053ccac48 100644 --- a/src/en/vizshonenjump/src/eu/kanade/tachiyomi/extension/en/vizshonenjump/VizImageInterceptor.kt +++ b/src/en/vizshonenjump/src/eu/kanade/tachiyomi/extension/en/vizshonenjump/VizImageInterceptor.kt @@ -12,7 +12,6 @@ import okhttp3.Response import okhttp3.ResponseBody import java.io.ByteArrayInputStream import java.io.ByteArrayOutputStream -import java.io.IOException import java.io.InputStream class VizImageInterceptor : Interceptor { @@ -40,6 +39,7 @@ class VizImageInterceptor : Interceptor { val byteInputStreamForMetadata = ByteArrayInputStream(byteOutputStream.toByteArray()) val imageData = getImageData(byteInputStreamForMetadata) + ?: return byteOutputStream.toByteArray() val input = BitmapFactory.decodeStream(byteInputStreamForImage) val width = input.width @@ -127,7 +127,7 @@ class VizImageInterceptor : Interceptor { drawBitmap(from, srcRect, dstRect, null) } - private fun getImageData(inputStream: InputStream): ImageData { + private fun getImageData(inputStream: InputStream): ImageData? { val metadata = ImageMetadataReader.readMetadata(inputStream) val sizeDir = metadata.directories.firstOrNull { @@ -141,7 +141,7 @@ class VizImageInterceptor : Interceptor { it.containsTag(ExifSubIFDDirectory.TAG_IMAGE_UNIQUE_ID) } val metaUniqueId = keyDir?.getString(ExifSubIFDDirectory.TAG_IMAGE_UNIQUE_ID) - ?: throw IOException(KEY_NOT_FOUND) + ?: return null return ImageData(metaWidth, metaHeight, metaUniqueId) } @@ -166,7 +166,5 @@ class VizImageInterceptor : Interceptor { private const val COMMON_WIDTH = 800 private const val COMMON_HEIGHT = 1200 - - private const val KEY_NOT_FOUND = "Decryption key not found in image metadata." } } diff --git a/src/en/vizshonenjump/src/eu/kanade/tachiyomi/extension/en/vizshonenjump/VizShonenJump.kt b/src/en/vizshonenjump/src/eu/kanade/tachiyomi/extension/en/vizshonenjump/VizShonenJump.kt index 88005f53b..4f2163f40 100644 --- a/src/en/vizshonenjump/src/eu/kanade/tachiyomi/extension/en/vizshonenjump/VizShonenJump.kt +++ b/src/en/vizshonenjump/src/eu/kanade/tachiyomi/extension/en/vizshonenjump/VizShonenJump.kt @@ -135,11 +135,11 @@ class VizShonenJump : ParsedHttpSource() { val mangaFromList = mangaList!!.firstOrNull { it.url == mangaUrl } return SManga.create().apply { - author = seriesIntro.select("div.type-rg span").first()?.text() + author = seriesIntro.select("div.type-rg span").firstOrNull()?.text() ?.replace("Created by ", "") artist = author status = SManga.ONGOING - description = seriesIntro.select("h4").first().text() + description = seriesIntro.select("h4").firstOrNull()?.text() thumbnail_url = mangaFromList?.thumbnail_url ?: "" } } @@ -192,8 +192,12 @@ class VizShonenJump : ParsedHttpSource() { } override fun pageListRequest(chapter: SChapter): Request { + val mangaUrl = chapter.url + .substringBefore("-chapter") + .replace("jump/", "jump/chapters/") + val newHeaders = headersBuilder() - .set("Referer", baseUrl + chapter.url.substringBefore("-chapter")) + .set("Referer", baseUrl + mangaUrl) .build() return GET(baseUrl + chapter.url, newHeaders)