Fix: delegate nhentai failed to load cover
Site might intended putting cover's type 'w' in JSON while it's in fact using 'cover.jpg.webp'
This commit is contained in:
parent
974cc4d239
commit
7d38c10776
2 changed files with 17 additions and 1 deletions
|
|
@ -17,6 +17,7 @@ import eu.kanade.tachiyomi.source.online.HttpSource
|
|||
import eu.kanade.tachiyomi.source.online.MetadataSource
|
||||
import eu.kanade.tachiyomi.source.online.NamespaceSource
|
||||
import eu.kanade.tachiyomi.source.online.UrlImportableSource
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import exh.metadata.metadata.NHentaiSearchMetadata
|
||||
import exh.metadata.metadata.RaisedSearchMetadata
|
||||
import exh.metadata.metadata.base.RaisedTag
|
||||
|
|
@ -29,6 +30,7 @@ import kotlinx.serialization.Serializable
|
|||
import kotlinx.serialization.json.Json
|
||||
import okhttp3.CacheControl
|
||||
import okhttp3.Response
|
||||
import org.jsoup.nodes.Document
|
||||
|
||||
class NHentai(delegate: HttpSource, val context: Context) :
|
||||
DelegatedHttpSource(delegate),
|
||||
|
|
@ -101,7 +103,8 @@ class NHentai(delegate: HttpSource, val context: Context) :
|
|||
preferredTitle = this@NHentai.preferredTitle
|
||||
|
||||
jsonResponse.images?.let { images ->
|
||||
coverImageType = images.cover?.type
|
||||
coverImageType = input.asJsoup(strdata).parseCoverType()
|
||||
?: images.cover?.type
|
||||
images.pages.mapNotNull {
|
||||
it.type
|
||||
}.let {
|
||||
|
|
@ -129,6 +132,18 @@ class NHentai(delegate: HttpSource, val context: Context) :
|
|||
}
|
||||
}
|
||||
|
||||
// KMK -->
|
||||
/**
|
||||
* Site JSON is saying cover of type `w` but instead it's using cover like `cover.jpg.webp`
|
||||
*/
|
||||
private fun Document.parseCoverType(): String? {
|
||||
return selectFirst("#cover > a > img")?.attr("data-src")
|
||||
?.substringAfterLast('/')
|
||||
?.substringAfter('.')
|
||||
?.first()?.toString()
|
||||
}
|
||||
// KMK <--
|
||||
|
||||
@Serializable
|
||||
data class JsonResponse(
|
||||
val id: Long,
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ class NHentaiSearchMetadata : RaisedSearchMetadata() {
|
|||
|
||||
val cover = if (mediaId != null) {
|
||||
// AZ -->
|
||||
// Default media server for cover is always 1 (see in page header)
|
||||
val server = mediaServer ?: 1
|
||||
// AZ <--
|
||||
typeToExtension(coverImageType)?.let {
|
||||
|
|
|
|||
Loading…
Reference in a new issue