Fix exception when there is no description or key. (#5604)

This commit is contained in:
Alessandro Jean 2021-02-01 19:47:23 -03:00 committed by GitHub
parent 39c348e10f
commit de13abf701
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 9 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'VIZ Shonen Jump' extName = 'VIZ Shonen Jump'
pkgNameSuffix = 'en.vizshonenjump' pkgNameSuffix = 'en.vizshonenjump'
extClass = '.VizShonenJump' extClass = '.VizShonenJump'
extVersionCode = 5 extVersionCode = 6
libVersion = '1.2' libVersion = '1.2'
} }

View File

@ -12,7 +12,6 @@ import okhttp3.Response
import okhttp3.ResponseBody import okhttp3.ResponseBody
import java.io.ByteArrayInputStream import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream
import java.io.IOException
import java.io.InputStream import java.io.InputStream
class VizImageInterceptor : Interceptor { class VizImageInterceptor : Interceptor {
@ -40,6 +39,7 @@ class VizImageInterceptor : Interceptor {
val byteInputStreamForMetadata = ByteArrayInputStream(byteOutputStream.toByteArray()) val byteInputStreamForMetadata = ByteArrayInputStream(byteOutputStream.toByteArray())
val imageData = getImageData(byteInputStreamForMetadata) val imageData = getImageData(byteInputStreamForMetadata)
?: return byteOutputStream.toByteArray()
val input = BitmapFactory.decodeStream(byteInputStreamForImage) val input = BitmapFactory.decodeStream(byteInputStreamForImage)
val width = input.width val width = input.width
@ -127,7 +127,7 @@ class VizImageInterceptor : Interceptor {
drawBitmap(from, srcRect, dstRect, null) drawBitmap(from, srcRect, dstRect, null)
} }
private fun getImageData(inputStream: InputStream): ImageData { private fun getImageData(inputStream: InputStream): ImageData? {
val metadata = ImageMetadataReader.readMetadata(inputStream) val metadata = ImageMetadataReader.readMetadata(inputStream)
val sizeDir = metadata.directories.firstOrNull { val sizeDir = metadata.directories.firstOrNull {
@ -141,7 +141,7 @@ class VizImageInterceptor : Interceptor {
it.containsTag(ExifSubIFDDirectory.TAG_IMAGE_UNIQUE_ID) it.containsTag(ExifSubIFDDirectory.TAG_IMAGE_UNIQUE_ID)
} }
val metaUniqueId = keyDir?.getString(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) return ImageData(metaWidth, metaHeight, metaUniqueId)
} }
@ -166,7 +166,5 @@ class VizImageInterceptor : Interceptor {
private const val COMMON_WIDTH = 800 private const val COMMON_WIDTH = 800
private const val COMMON_HEIGHT = 1200 private const val COMMON_HEIGHT = 1200
private const val KEY_NOT_FOUND = "Decryption key not found in image metadata."
} }
} }

View File

@ -135,11 +135,11 @@ class VizShonenJump : ParsedHttpSource() {
val mangaFromList = mangaList!!.firstOrNull { it.url == mangaUrl } val mangaFromList = mangaList!!.firstOrNull { it.url == mangaUrl }
return SManga.create().apply { 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 ", "") ?.replace("Created by ", "")
artist = author artist = author
status = SManga.ONGOING status = SManga.ONGOING
description = seriesIntro.select("h4").first().text() description = seriesIntro.select("h4").firstOrNull()?.text()
thumbnail_url = mangaFromList?.thumbnail_url ?: "" thumbnail_url = mangaFromList?.thumbnail_url ?: ""
} }
} }
@ -192,8 +192,12 @@ class VizShonenJump : ParsedHttpSource() {
} }
override fun pageListRequest(chapter: SChapter): Request { override fun pageListRequest(chapter: SChapter): Request {
val mangaUrl = chapter.url
.substringBefore("-chapter")
.replace("jump/", "jump/chapters/")
val newHeaders = headersBuilder() val newHeaders = headersBuilder()
.set("Referer", baseUrl + chapter.url.substringBefore("-chapter")) .set("Referer", baseUrl + mangaUrl)
.build() .build()
return GET(baseUrl + chapter.url, newHeaders) return GET(baseUrl + chapter.url, newHeaders)