Various bug fixes.

This commit is contained in:
NerdNumber9 2017-03-09 20:46:24 -05:00
parent fa6790856d
commit 3222e0646d
6 changed files with 31 additions and 18 deletions

View File

@ -163,7 +163,8 @@ class NHentai(context: Context) : HttpSource() {
listOf(SChapter.create().apply {
url = manga.url
name = "Chapter"
date_upload = it.uploadDate ?: 0
//TODO Get this working later
// date_upload = it.uploadDate ?: 0
chapter_number = 1f
})
}!!

View File

@ -118,7 +118,7 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
searchSubscription = presenter
.searchSubject
.debounce(100L, TimeUnit.MILLISECONDS)
.debounce(10L, TimeUnit.MILLISECONDS)
.subscribe { text -> //Debounce search (EH)
adapter.asyncSearchText = text?.trim()?.toLowerCase()
adapter.updateDataSet()

View File

@ -54,13 +54,6 @@ class MetadataHelper {
exGalleryBook().read<ExGalleryMetadata>(it)
}
fun hasMetadata(url: String, exh: Boolean): Boolean
= ExGalleryMetadata().let {
it.url = url
it.exh = exh
return exGalleryBook().exist(it.galleryUniqueIdentifier())
}
//TODO Problem, our new metadata structures are incompatible.
//TODO We will probably just delete the old metadata structures
fun exGalleryBook() = Paper.book("gallery-ex")!!

View File

@ -3,6 +3,8 @@ package exh.metadata
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.all.EHentai
import eu.kanade.tachiyomi.source.online.all.EHentaiMetadata
import eu.kanade.tachiyomi.source.online.all.PervEden
import exh.metadata.models.*
import exh.plusAssign
@ -194,6 +196,16 @@ fun NHentaiMetadata.copyTo(manga: SManga) {
.joinToString(separator = "\n")
}
fun SearchableGalleryMetadata.genericCopyTo(manga: SManga): Boolean {
when(this) {
is ExGalleryMetadata -> this.copyTo(manga)
is PervEdenGalleryMetadata -> this.copyTo(manga)
is NHentaiMetadata -> this.copyTo(manga)
else -> return false
}
return true
}
private fun buildTagsDescription(metadata: SearchableGalleryMetadata)
= StringBuilder("Tags:\n").apply {
//BiConsumer only available in Java 8, don't bother calling forEach directly on 'tags'

View File

@ -8,6 +8,7 @@ class Text: QueryComponent() {
private var regex: VerbalExpression? = null
private var lenientRegex: VerbalExpression? = null
private var rawText: String? = null
fun asRegex(): VerbalExpression {
if(regex == null) {
@ -35,9 +36,14 @@ class Text: QueryComponent() {
return builder
}
fun rawTextOnly() = components
fun rawTextOnly() = if(rawText != null)
rawText!!
else {
rawText = components
.filter { it is StringTextComponent }
.joinToString(separator = "", transform = {
(it as StringTextComponent).value
})
rawText!!
}
}

View File

@ -10,8 +10,10 @@ import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.source.online.all.EHentai
import exh.isExSource
import exh.isLewdSource
import exh.metadata.MetadataHelper
import exh.metadata.copyTo
import exh.metadata.genericCopyTo
import timber.log.Timber
import uy.kohesive.injekt.injectLazy
import kotlin.concurrent.thread
@ -44,8 +46,8 @@ class MetadataFetchDialog {
val libraryMangas = db.getLibraryMangas()
.executeAsBlocking()
.filter {
it.source <= 2
&& !metadataHelper.hasMetadata(it.url, isExSource(it.source))
isLewdSource(it.source)
&& metadataHelper.fetchMetadata(it.url, it.source) == null
}
context.runOnUiThread {
@ -61,9 +63,8 @@ class MetadataFetchDialog {
try {
val source = sourceManager.get(manga.source)
source?.let {
it as EHentai
manga.copyFrom(it.fetchMangaDetails(manga).toBlocking().first())
metadataHelper.fetchEhMetadata(manga.url, it.exh)?.copyTo(manga)
metadataHelper.fetchMetadata(manga.url, manga.source)?.genericCopyTo(manga)
}
} catch(t: Throwable) {
Timber.e(t, "Could not migrate manga!")