Support the short title setting in NHentai
This commit is contained in:
parent
05c2b43ffb
commit
9945752667
@ -1,6 +1,7 @@
|
||||
package eu.kanade.tachiyomi.source.online.all
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.net.Uri
|
||||
import eu.kanade.tachiyomi.network.asObservableSuccess
|
||||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
@ -32,6 +33,16 @@ class NHentai(delegate: HttpSource, val context: Context) :
|
||||
override val metaClass = NHentaiSearchMetadata::class
|
||||
override val lang = if (id == otherId) "all" else delegate.lang
|
||||
|
||||
private val sourcePreferences: SharedPreferences by lazy {
|
||||
context.getSharedPreferences("source_$id", 0x0000)
|
||||
}
|
||||
|
||||
private val preferredTitle: Int
|
||||
get() = when (sourcePreferences.getString(TITLE_PREF, "full")) {
|
||||
"full" -> NHentaiSearchMetadata.TITLE_TYPE_ENGLISH
|
||||
else -> NHentaiSearchMetadata.TITLE_TYPE_SHORT
|
||||
}
|
||||
|
||||
// Support direct URL importing
|
||||
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> =
|
||||
urlImportFetchSearchManga(context, query) {
|
||||
@ -73,6 +84,8 @@ class NHentai(delegate: HttpSource, val context: Context) :
|
||||
englishTitle = title.english
|
||||
}
|
||||
|
||||
preferredTitle = this@NHentai.preferredTitle
|
||||
|
||||
jsonResponse.images?.let { images ->
|
||||
coverImageType = NHentaiSearchMetadata.typeToExtension(images.cover?.type)
|
||||
images.pages.mapNotNull {
|
||||
@ -173,5 +186,6 @@ class NHentai(delegate: HttpSource, val context: Context) :
|
||||
|
||||
private val GALLERY_JSON_REGEX = Regex(".parse\\(\"(.*)\"\\);")
|
||||
private val UNICODE_ESCAPE_REGEX = Regex("\\\\u([0-9a-fA-F]{4})")
|
||||
private const val TITLE_PREF = "Display manga title as:"
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import exh.metadata.EX_DATE_FORMAT
|
||||
import exh.metadata.ONGOING_SUFFIX
|
||||
import exh.metadata.metadata.base.RaisedSearchMetadata
|
||||
import kotlinx.serialization.Serializable
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.util.Date
|
||||
|
||||
@Serializable
|
||||
@ -37,6 +36,8 @@ class NHentaiSearchMetadata : RaisedSearchMetadata() {
|
||||
|
||||
var scanlator: String? = null
|
||||
|
||||
var preferredTitle: Int? = null
|
||||
|
||||
override fun copyTo(manga: SManga) {
|
||||
nhId?.let { manga.url = nhIdToPath(it) }
|
||||
|
||||
@ -46,7 +47,11 @@ class NHentaiSearchMetadata : RaisedSearchMetadata() {
|
||||
}
|
||||
}
|
||||
|
||||
manga.title = englishTitle ?: japaneseTitle ?: shortTitle!!
|
||||
manga.title = when (preferredTitle) {
|
||||
TITLE_TYPE_SHORT -> shortTitle ?: englishTitle ?: japaneseTitle!!
|
||||
0, TITLE_TYPE_ENGLISH -> englishTitle ?: japaneseTitle ?: shortTitle!!
|
||||
else -> englishTitle ?: japaneseTitle ?: shortTitle!!
|
||||
}
|
||||
|
||||
// Set artist (if we can find one)
|
||||
tags.filter { it.namespace == NHENTAI_ARTIST_NAMESPACE }.let {
|
||||
@ -88,8 +93,8 @@ class NHentaiSearchMetadata : RaisedSearchMetadata() {
|
||||
|
||||
companion object {
|
||||
private const val TITLE_TYPE_JAPANESE = 0
|
||||
private const val TITLE_TYPE_ENGLISH = 1
|
||||
private const val TITLE_TYPE_SHORT = 2
|
||||
const val TITLE_TYPE_ENGLISH = 1
|
||||
const val TITLE_TYPE_SHORT = 2
|
||||
|
||||
const val TAG_TYPE_DEFAULT = 0
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user