Log result in Tsumino and minor code cleanup

This commit is contained in:
NerdNumber9 2018-08-03 22:03:51 -04:00
parent 72504ca53f
commit 450fcccaa6
3 changed files with 31 additions and 24 deletions

View File

@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.source.online.english
import android.content.Context import android.content.Context
import android.net.Uri import android.net.Uri
import com.crashlytics.android.Crashlytics
import com.github.salomonbrys.kotson.* import com.github.salomonbrys.kotson.*
import com.google.gson.JsonParser import com.google.gson.JsonParser
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
@ -13,6 +14,7 @@ import eu.kanade.tachiyomi.source.model.*
import eu.kanade.tachiyomi.source.online.LewdSource import eu.kanade.tachiyomi.source.online.LewdSource
import eu.kanade.tachiyomi.source.online.ParsedHttpSource import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import eu.kanade.tachiyomi.util.asJsoup import eu.kanade.tachiyomi.util.asJsoup
import eu.kanade.tachiyomi.util.toast
import exh.TSUMINO_SOURCE_ID import exh.TSUMINO_SOURCE_ID
import exh.ui.captcha.CaptchaCompletionVerifier import exh.ui.captcha.CaptchaCompletionVerifier
import exh.ui.captcha.SolveCaptchaActivity import exh.ui.captcha.SolveCaptchaActivity
@ -316,9 +318,10 @@ class Tsumino(private val context: Context): ParsedHttpSource(), LewdSource<Tsum
Page(index, chapter.url + "#${index + 1}", newImageUrl.toString()) Page(index, chapter.url + "#${index + 1}", newImageUrl.toString())
} }
}.doOnError { }.doOnError {
try {
val aspNetCookie = preferences.eh_ts_aspNetCookie().getOrDefault() val aspNetCookie = preferences.eh_ts_aspNetCookie().getOrDefault()
val cookiesMap = if(aspNetCookie.isNotBlank()) val cookiesMap = if (aspNetCookie.isNotBlank())
mapOf(ASP_NET_COOKIE_NAME to aspNetCookie) mapOf(ASP_NET_COOKIE_NAME to aspNetCookie)
else else
emptyMap() emptyMap()
@ -328,6 +331,10 @@ class Tsumino(private val context: Context): ParsedHttpSource(), LewdSource<Tsum
cookiesMap, cookiesMap,
CAPTCHA_SCRIPT, CAPTCHA_SCRIPT,
"$BASE_URL/Read/Auth/$id") "$BASE_URL/Read/Auth/$id")
} catch(t: Throwable) {
Crashlytics.logException(t)
context.toast("Could not launch captcha-solving activity: ${t.message}")
}
} }
} }

View File

@ -67,9 +67,9 @@ class LibraryCategoryAdapter(val view: LibraryCategoryView) :
} }
try { try {
val thisCache = globalSearchCache.getOrPut(view.category.name, { val thisCache = globalSearchCache.getOrPut(view.category.name) {
SearchCache(mangas.size) SearchCache(mangas.size)
}) }
if(thisCache.ready) { if(thisCache.ready) {
//Skip everything if cache matches our query exactly //Skip everything if cache matches our query exactly

View File

@ -31,20 +31,20 @@ fun Realm.queryMetadataFromManga(manga: Manga,
fun Realm.syncMangaIds(mangas: List<LibraryItem>) { fun Realm.syncMangaIds(mangas: List<LibraryItem>) {
Timber.d("--> EH: Begin syncing ${mangas.size} manga IDs...") Timber.d("--> EH: Begin syncing ${mangas.size} manga IDs...")
executeTransaction { executeTransaction {
mangas.filter { mangas.forEach { manga ->
isLewdSource(it.manga.source) if(isLewdSource(manga.manga.source)) {
}.forEach { manga ->
try { try {
manga.hasMetadata = manga.hasMetadata =
queryMetadataFromManga(manga.manga).findFirst()?.let { meta -> queryMetadataFromManga(manga.manga).findFirst()?.let { meta ->
meta.mangaId = manga.manga.id meta.mangaId = manga.manga.id
true true
} ?: false } ?: false
} catch(e: Exception) { } catch (e: Exception) {
Timber.w(e, "Error syncing manga IDs! Ignoring...") Timber.w(e, "Error syncing manga IDs! Ignoring...")
} }
} }
} }
}
Timber.d("--> EH: Finish syncing ${mangas.size} manga IDs!") Timber.d("--> EH: Finish syncing ${mangas.size} manga IDs!")
} }