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 { listOf(SChapter.create().apply {
url = manga.url url = manga.url
name = "Chapter" name = "Chapter"
date_upload = it.uploadDate ?: 0 //TODO Get this working later
// date_upload = it.uploadDate ?: 0
chapter_number = 1f chapter_number = 1f
}) })
}!! }!!

View File

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

View File

@ -54,13 +54,6 @@ class MetadataHelper {
exGalleryBook().read<ExGalleryMetadata>(it) 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 Problem, our new metadata structures are incompatible.
//TODO We will probably just delete the old metadata structures //TODO We will probably just delete the old metadata structures
fun exGalleryBook() = Paper.book("gallery-ex")!! 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.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.source.model.SManga 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 eu.kanade.tachiyomi.source.online.all.PervEden
import exh.metadata.models.* import exh.metadata.models.*
import exh.plusAssign import exh.plusAssign
@ -194,6 +196,16 @@ fun NHentaiMetadata.copyTo(manga: SManga) {
.joinToString(separator = "\n") .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) private fun buildTagsDescription(metadata: SearchableGalleryMetadata)
= StringBuilder("Tags:\n").apply { = StringBuilder("Tags:\n").apply {
//BiConsumer only available in Java 8, don't bother calling forEach directly on 'tags' //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 regex: VerbalExpression? = null
private var lenientRegex: VerbalExpression? = null private var lenientRegex: VerbalExpression? = null
private var rawText: String? = null
fun asRegex(): VerbalExpression { fun asRegex(): VerbalExpression {
if(regex == null) { if(regex == null) {
@ -35,9 +36,14 @@ class Text: QueryComponent() {
return builder return builder
} }
fun rawTextOnly() = components fun rawTextOnly() = if(rawText != null)
.filter { it is StringTextComponent } rawText!!
.joinToString(separator = "", transform = { else {
(it as StringTextComponent).value 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.SourceManager
import eu.kanade.tachiyomi.source.online.all.EHentai import eu.kanade.tachiyomi.source.online.all.EHentai
import exh.isExSource import exh.isExSource
import exh.isLewdSource
import exh.metadata.MetadataHelper import exh.metadata.MetadataHelper
import exh.metadata.copyTo import exh.metadata.copyTo
import exh.metadata.genericCopyTo
import timber.log.Timber import timber.log.Timber
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
import kotlin.concurrent.thread import kotlin.concurrent.thread
@ -44,8 +46,8 @@ class MetadataFetchDialog {
val libraryMangas = db.getLibraryMangas() val libraryMangas = db.getLibraryMangas()
.executeAsBlocking() .executeAsBlocking()
.filter { .filter {
it.source <= 2 isLewdSource(it.source)
&& !metadataHelper.hasMetadata(it.url, isExSource(it.source)) && metadataHelper.fetchMetadata(it.url, it.source) == null
} }
context.runOnUiThread { context.runOnUiThread {
@ -61,9 +63,8 @@ class MetadataFetchDialog {
try { try {
val source = sourceManager.get(manga.source) val source = sourceManager.get(manga.source)
source?.let { source?.let {
it as EHentai
manga.copyFrom(it.fetchMangaDetails(manga).toBlocking().first()) 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) { } catch(t: Throwable) {
Timber.e(t, "Could not migrate manga!") Timber.e(t, "Could not migrate manga!")