diff --git a/app/src/main/kotlin/com/hippo/ehviewer/EhApplication.kt b/app/src/main/kotlin/com/hippo/ehviewer/EhApplication.kt index 2daea7060..01dc40b93 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/EhApplication.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/EhApplication.kt @@ -56,7 +56,6 @@ import com.hippo.ehviewer.ktbuilder.imageLoader import com.hippo.ehviewer.ktor.Cronet import com.hippo.ehviewer.ktor.configureClient import com.hippo.ehviewer.ktor.configureCommon -import com.hippo.ehviewer.spider.trimHAtHBlacklist import com.hippo.ehviewer.ui.keepNoMediaFileStatus import com.hippo.ehviewer.ui.lockObserver import com.hippo.ehviewer.ui.screen.detailCache @@ -78,10 +77,8 @@ import eu.kanade.tachiyomi.util.lang.withUIContext import eu.kanade.tachiyomi.util.system.logcat import io.ktor.client.HttpClient import io.ktor.client.engine.okhttp.OkHttp -import kotlin.time.Duration.Companion.days import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch -import kotlinx.datetime.Clock import logcat.AndroidLogcatLogger import logcat.LogPriority import logcat.LogcatLogger @@ -115,7 +112,6 @@ class EhApplication : super.onCreate() System.loadLibrary("ehviewer") lifecycleScope.launchIO { - launch { trimHAtHBlacklist(Clock.System.now() - 7.days) } launchUI { FavouriteStatusRouter.collect { (gid, slot) -> detailCache[gid]?.favoriteSlot = slot } } EhTagDatabase.launchUpdate() launch { EhDB } diff --git a/app/src/main/kotlin/com/hippo/ehviewer/Settings.kt b/app/src/main/kotlin/com/hippo/ehviewer/Settings.kt index e47764c7c..25602cfd0 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/Settings.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/Settings.kt @@ -148,7 +148,6 @@ object Settings : DataStorePreferences(null) { var launchPage by intPref("launch_page_2", 0) var commentThreshold by intPref("comment_threshold", -101) var hardwareBitmapThreshold by intPref("hardware_bitmap_threshold", 16384) - var hAtHBlacklist by boolPref("H@H_blacklist", false).observed { updateWhenHAtHBlacklistChanges() } var showComments by boolPref("show_gallery_comments", true) var requestNews by boolPref("request_news", false).observed { updateWhenRequestNewsChanges() } var hideHvEvents by boolPref("hide_hv_events", false) diff --git a/app/src/main/kotlin/com/hippo/ehviewer/SettingsCollector.kt b/app/src/main/kotlin/com/hippo/ehviewer/SettingsCollector.kt index 6543a2f4c..9e77a92ff 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/SettingsCollector.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/SettingsCollector.kt @@ -5,7 +5,6 @@ import androidx.appcompat.app.AppCompatDelegate import com.hippo.ehviewer.client.EhEngine import com.hippo.ehviewer.client.EhTagDatabase import com.hippo.ehviewer.dailycheck.updateDailyCheckWork -import com.hippo.ehviewer.spider.trimHAtHBlacklist import com.hippo.ehviewer.ui.keepNoMediaFileStatus import com.hippo.ehviewer.util.isAtLeastS import eu.kanade.tachiyomi.util.lang.launchIO @@ -68,9 +67,3 @@ fun updateWhenGallerySiteChanges() { fun updateWhenTagTranslationChanges() { EhTagDatabase.launchUpdate() } - -fun updateWhenHAtHBlacklistChanges() { - collectScope.launchIO { - trimHAtHBlacklist() - } -} diff --git a/app/src/main/kotlin/com/hippo/ehviewer/spider/HAtHBlacklist.kt b/app/src/main/kotlin/com/hippo/ehviewer/spider/HAtHBlacklist.kt deleted file mode 100644 index d9d1c389e..000000000 --- a/app/src/main/kotlin/com/hippo/ehviewer/spider/HAtHBlacklist.kt +++ /dev/null @@ -1,37 +0,0 @@ -package com.hippo.ehviewer.spider - -import com.hippo.files.read -import com.hippo.files.write -import io.ktor.utils.io.core.writeFully -import kotlinx.datetime.Clock -import kotlinx.datetime.Instant -import kotlinx.io.readByteArray -import kotlinx.serialization.Serializable -import kotlinx.serialization.cbor.Cbor -import kotlinx.serialization.decodeFromByteArray -import kotlinx.serialization.encodeToByteArray -import okio.Path.Companion.toOkioPath -import splitties.init.appCtx - -@Serializable -class HAtHBlacklist(val blacklist: MutableMap = mutableMapOf()) - -private val cache = appCtx.cacheDir.toOkioPath() / "H@H_blacklist" - -val blacklist by lazy { - runCatching { - cache.read { Cbor.decodeFromByteArray(readByteArray()) } - }.getOrElse { - cache.write { HAtHBlacklist().also { writeFully(Cbor.encodeToByteArray(it)) } } - } -} - -fun appendHAtHBlacklist(host: String) = synchronized(blacklist) { - blacklist.blacklist[host] = Clock.System.now() - cache.write { writeFully(Cbor.encodeToByteArray(blacklist)) } -} - -fun trimHAtHBlacklist(time: Instant = Clock.System.now()) = synchronized(blacklist) { - blacklist.blacklist.values.removeIf { i -> i < time } - cache.write { writeFully(Cbor.encodeToByteArray(blacklist)) } -} diff --git a/app/src/main/kotlin/com/hippo/ehviewer/spider/SpiderQueen.kt b/app/src/main/kotlin/com/hippo/ehviewer/spider/SpiderQueen.kt index f52f69c65..38bc1fd51 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/spider/SpiderQueen.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/spider/SpiderQueen.kt @@ -38,10 +38,8 @@ import com.hippo.ehviewer.client.parser.GalleryDetailParser.parsePreviewPages import com.hippo.ehviewer.client.parser.GalleryMultiPageViewerPTokenParser import com.hippo.ehviewer.client.parser.GalleryPageUrlParser import com.hippo.ehviewer.util.displayString -import com.hippo.ehviewer.util.isHAtHTimeoutException import com.hippo.files.find import eu.kanade.tachiyomi.util.system.logcat -import io.ktor.http.Url import java.util.concurrent.atomic.AtomicInteger import kotlin.time.Duration.Companion.milliseconds import kotlin.time.TimeSource @@ -638,20 +636,6 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS } checkNotNull(targetImageUrl) - val host = Url(targetImageUrl).host - synchronized(blacklist) { - if (lasthost == host) { - blacklist.blacklist.remove(host) - logcat(WORKER_DEBUG_TAG) { "Drop $host from H@H blacklist as its resource is unique for now!" } - } - - if (Settings.hAtHBlacklist && blacklist.blacklist.containsKey(host)) { - logcat(WORKER_DEBUG_TAG) { "$host hits H@H blacklist!" } - lasthost = host - return@repeat - } - } - runCatching { logcat(WORKER_DEBUG_TAG) { "Start download image $index" } spiderDen.makeHttpCallAndSaveImage( @@ -666,9 +650,6 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS }.onFailure { spiderDen.removeIntermediateFiles(index) logcat(WORKER_DEBUG_TAG) { "Download image $index failed" } - if (Settings.hAtHBlacklist && it.isHAtHTimeoutException()) { - appendHAtHBlacklist(host) - } when (it) { is CancellationException, is FileNotFoundException -> throw it } diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/i18n/EnStrings.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/i18n/EnStrings.kt index 8619543b2..4baf8c0e9 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/i18n/EnStrings.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/i18n/EnStrings.kt @@ -310,7 +310,6 @@ object EnStrings : Strings { override val settingsDownloadDownloadDelaySummary = { a: Int -> "Delay $a ms per download" } override val settingsDownloadConnectionTimeout = "Connection timeout (in seconds)" override val settingsDownloadTimeoutSpeed = "Minimum response speed (in KB/s)" - override val settingsDownloadHAtHBlacklist = "Enable H@H blacklist" override val settingsDownloadPreloadImage = "Preload image" override val settingsDownloadPreloadImageSummary = { a: Int -> "Preload next $a image" } override val settingsDownloadDownloadOriginImage = "Download original image" diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/i18n/Strings.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/i18n/Strings.kt index 1bf83fe56..a8da47f51 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/i18n/Strings.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/i18n/Strings.kt @@ -315,7 +315,6 @@ interface Strings { val settingsDownloadDownloadDelaySummary: (Int) -> String val settingsDownloadConnectionTimeout: String val settingsDownloadTimeoutSpeed: String - val settingsDownloadHAtHBlacklist: String val settingsDownloadPreloadImage: String val settingsDownloadPreloadImageSummary: (Int) -> String val settingsDownloadDownloadOriginImage: String diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/i18n/ZhCnStrings.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/i18n/ZhCnStrings.kt index ad22e000d..60e54a532 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/i18n/ZhCnStrings.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/i18n/ZhCnStrings.kt @@ -408,7 +408,6 @@ object ZhCnStrings : Strings by EnStrings { override val settingsDownloadDownloadDelaySummary = { a: Int -> "每次下载延时 $a 毫秒" } override val settingsDownloadConnectionTimeout = "连接超时(秒)" override val settingsDownloadTimeoutSpeed = "最低响应速度(KB/s)" - override val settingsDownloadHAtHBlacklist = "启用H@H黑名单" override val noBrowserInstalled = "请安装一个浏览器。" override val toplistAlltime = "从始至终" override val toplistPastyear = "过去一年" diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/settings/DownloadScreen.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/settings/DownloadScreen.kt index 2bd019042..82c5ab978 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/settings/DownloadScreen.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/settings/DownloadScreen.kt @@ -195,10 +195,6 @@ fun AnimatedVisibilityScope.DownloadScreen(navigator: DestinationsNavigator) = c value = Settings::timeoutSpeed, display = ::speedLevelToSpeed, ) - SwitchPreference( - title = settingsDownloadHAtHBlacklist, - value = Settings::hAtHBlacklist, - ) val preloadImage = Settings::preloadImage.observed SimpleMenuPreferenceInt( title = settingsDownloadPreloadImage,