Error out on cover search for V2 galleries

This commit is contained in:
FooIbar committed 2024-11-09 20:35:09 +08:00
1 parent 40caa7b1eb
commit 11edb8ce5d
2 files changed
+11 -7

No files matched your search

@@ -84,12 +84,16 @@ object EhUtils {
)
private val CATEGORY_STRINGS = CATEGORY_VALUES.entries.map { (k, v) -> v to k }
private val ImageHashRegex = Regex("[0-9a-f]{40}")
val isExHentai: Boolean
get() = Settings.gallerySite.value == EhUrl.SITE_EX
val isMpvAvailable
get() = EhCookieStore.getHathPerks()?.contains('q') == true
fun getImageHash(thumbUrl: String) = ImageHashRegex.find(thumbUrl)?.groupValues[0]
fun getCategory(type: String?): Int {
for (entry in CATEGORY_STRINGS) {
for (str in entry.first) {
@@ -524,17 +524,17 @@ fun BelowHeader(galleryDetail: GalleryDetail) {
}
},
)
val invalidUrl = stringResource(R.string.error_invalid_url)
EhIconButton(
icon = Icons.Default.ImageSearch,
text = stringResource(id = R.string.search_cover),
onClick = {
val key = galleryDetail.thumbKey!!
navigate(
ListUrlBuilder(
mode = ListUrlBuilder.MODE_IMAGE_SEARCH,
hash = key.substringAfterLast('/').substringBefore('-'),
).asDst(),
)
val hash = EhUtils.getImageHash(galleryDetail.thumbKey!!)
if (hash != null) {
navigate(ListUrlBuilder(mode = ListUrlBuilder.MODE_IMAGE_SEARCH, hash = hash).asDst())
} else {
launch { showSnackbar(invalidUrl) }
}
},
)
val torrentText = stringResource(R.string.torrent_count, galleryDetail.torrentCount)