From b8eb75fc689c8b0e2736a5e08138c6ff58756d6d Mon Sep 17 00:00:00 2001 From: Jobobby04 Date: Thu, 20 Nov 2025 12:37:37 -0500 Subject: [PATCH] Throttle E-Hentai requests --- .../list/MigrationListScreenModel.kt | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/mihon/feature/migration/list/MigrationListScreenModel.kt b/app/src/main/java/mihon/feature/migration/list/MigrationListScreenModel.kt index 14724ba45..3da75bd91 100644 --- a/app/src/main/java/mihon/feature/migration/list/MigrationListScreenModel.kt +++ b/app/src/main/java/mihon/feature/migration/list/MigrationListScreenModel.kt @@ -9,6 +9,8 @@ import eu.kanade.domain.manga.model.toSManga import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.tachiyomi.source.CatalogueSource import eu.kanade.tachiyomi.source.getNameForMangaInfo +import eu.kanade.tachiyomi.source.online.all.EHentai +import exh.util.ThrottleManager import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.toImmutableList @@ -57,6 +59,10 @@ class MigrationListScreenModel( private val smartSearchEngine = SmartSourceSearchEngine(extraSearchQuery) + // SY --> + private val throttleManager = ThrottleManager() + // SY <-- + val items inline get() = state.value.items @@ -110,6 +116,9 @@ class MigrationListScreenModel( } private suspend fun runMigrations(mangas: List) { + // SY --> + throttleManager.resetThrottle() + // SY <-- val prioritizeByChapters = preferences.migrationPrioritizeByChapters().get() val deepSearchMode = preferences.migrationDeepSearchMode().get() @@ -192,7 +201,13 @@ class MigrationListScreenModel( val localManga = networkToLocalManga(searchResult) try { - val chapters = source.getChapterList(localManga.toSManga()) + // SY --> + val chapters = if (source is EHentai) { + source.getChapterList(localManga.toSManga(), throttleManager::throttle) + } else { + source.getChapterList(localManga.toSManga()) + } + // SY <-- syncChaptersWithSource.await(chapters, localManga, source) } catch (e: Exception) { logcat(LogPriority.ERROR, e) @@ -228,7 +243,13 @@ class MigrationListScreenModel( val manga = getManga.await(target) ?: return@async null try { val source = sourceManager.get(manga.source)!! - val chapters = source.getChapterList(manga.toSManga()) + // SY --> + val chapters = if (source is EHentai) { + source.getChapterList(manga.toSManga(), throttleManager::throttle) + } else { + source.getChapterList(manga.toSManga()) + } + // SY <-- syncChaptersWithSource.await(chapters, manga, source) } catch (_: Exception) { return@async null