Merge branch 'KotatsuApp:master' into test

master
Draken 1 year ago committed by GitHub
commit 8d82bacaa3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,4 +1,4 @@
package org.koitharu.kotatsu.parsers.site.mangareader.en
package org.koitharu.kotatsu.parsers.site.en
import androidx.collection.ArraySet
import okhttp3.HttpUrl

@ -6,7 +6,9 @@ import kotlinx.coroutines.async
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import org.koitharu.kotatsu.parsers.MangaLoaderContext
import org.koitharu.kotatsu.parsers.PagedMangaParser
import org.koitharu.kotatsu.parsers.config.ConfigKey
@ -43,9 +45,6 @@ internal abstract class WpComicsParser(
isSearchSupported = true,
)
@JvmField
protected val coverSrcAttrs = arrayOf("data-original", "src")
override suspend fun getFilterOptions() = MangaListFilterOptions(
availableTags = fetchAvailableTags(),
availableStates = EnumSet.of(MangaState.ONGOING, MangaState.FINISHED),
@ -164,7 +163,7 @@ internal abstract class WpComicsParser(
publicUrl = absUrl,
rating = RATING_UNKNOWN,
isNsfw = false,
coverUrl = item.selectFirst("div.image a img")?.src(coverSrcAttrs).orEmpty(),
coverUrl = item.selectFirst("div.image a img")?.findImageUrl().orEmpty(),
largeCoverUrl = null,
tags = mangaTags,
state = mangaState,
@ -333,4 +332,12 @@ internal abstract class WpComicsParser(
else -> 0
}
}
protected fun Element.findImageUrl(): String? {
val attrs = attributes().filter { attr ->
attr.value.toHttpUrlOrNull() != null
}
// src attribute should have a lowest priority
return attrs.maxByOrNull { it.key != "src" }?.value
}
}

@ -98,7 +98,7 @@ internal class DocTruyen3Q(context: MangaLoaderContext) :
id = generateUid(href),
url = href,
publicUrl = href.toAbsoluteUrl(div.host ?: domain),
coverUrl = div.selectFirst("div.image-item img")?.src(coverSrcAttrs).orEmpty(),
coverUrl = div.selectFirst("div.image-item img")?.findImageUrl().orEmpty(),
title = div.selectFirst("h3 a")?.text().orEmpty(),
altTitle = null,
rating = RATING_UNKNOWN,

@ -99,7 +99,7 @@ internal class TopTruyen(context: MangaLoaderContext) :
id = generateUid(href),
url = href,
publicUrl = href.toAbsoluteUrl(div.host ?: domain),
coverUrl = div.selectFirst("div.image-item img")?.src(coverSrcAttrs).orEmpty(),
coverUrl = div.selectFirst("div.image-item img")?.findImageUrl().orEmpty(),
title = div.selectFirst("h3 a")?.text().orEmpty(),
altTitle = null,
rating = RATING_UNKNOWN,

Loading…
Cancel
Save