Koharu: fix regex removing all title
This commit is contained in:
parent
1a3acc77d3
commit
d741e353e7
@ -1,7 +1,7 @@
|
|||||||
ext {
|
ext {
|
||||||
extName = 'Koharu'
|
extName = 'Koharu'
|
||||||
extClass = '.Koharu'
|
extClass = '.Koharu'
|
||||||
extVersionCode = 2
|
extVersionCode = 3
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,8 @@ class Koharu : HttpSource(), ConfigurableSource {
|
|||||||
|
|
||||||
private val json: Json by injectLazy()
|
private val json: Json by injectLazy()
|
||||||
|
|
||||||
private val titleRegex = Regex("""\s*[(\[{].*[)\]}]\s*""")
|
private val shortenTitleRegex = Regex("""(\[[^]]*]|[({][^)}]*[)}])""")
|
||||||
|
private fun String.shortenTitle() = replace(shortenTitleRegex, "").trim()
|
||||||
|
|
||||||
private val preferences: SharedPreferences by lazy {
|
private val preferences: SharedPreferences by lazy {
|
||||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||||
@ -64,7 +65,7 @@ class Koharu : HttpSource(), ConfigurableSource {
|
|||||||
|
|
||||||
private fun getManga(book: Entry) = SManga.create().apply {
|
private fun getManga(book: Entry) = SManga.create().apply {
|
||||||
setUrlWithoutDomain("${book.id}/${book.public_key}")
|
setUrlWithoutDomain("${book.id}/${book.public_key}")
|
||||||
title = if (remadd()) book.title.replace(titleRegex, "").trim() else book.title
|
title = if (remadd()) book.title.shortenTitle() else book.title
|
||||||
thumbnail_url = book.thumbnail.path
|
thumbnail_url = book.thumbnail.path
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,7 +165,7 @@ class Koharu : HttpSource(), ConfigurableSource {
|
|||||||
listOf(
|
listOf(
|
||||||
SManga.create().apply {
|
SManga.create().apply {
|
||||||
setUrlWithoutDomain("${entry.id}/${entry.public_key}")
|
setUrlWithoutDomain("${entry.id}/${entry.public_key}")
|
||||||
title = if (remadd()) entry.title.replace(titleRegex, "").trim() else entry.title
|
title = if (remadd()) entry.title.shortenTitle() else entry.title
|
||||||
thumbnail_url = entry.thumbnails.base + entry.thumbnails.main.path
|
thumbnail_url = entry.thumbnails.base + entry.thumbnails.main.path
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -214,7 +215,7 @@ class Koharu : HttpSource(), ConfigurableSource {
|
|||||||
|
|
||||||
var appended = false
|
var appended = false
|
||||||
fun List<String>.joinAndCapitalizeEach(): String? = this.emptyToNull()?.joinToString { it.capitalizeEach() }?.apply { appended = true }
|
fun List<String>.joinAndCapitalizeEach(): String? = this.emptyToNull()?.joinToString { it.capitalizeEach() }?.apply { appended = true }
|
||||||
title = if (remadd()) this@toSManga.title.replace(titleRegex, "").trim() else this@toSManga.title
|
title = if (remadd()) this@toSManga.title.shortenTitle() else this@toSManga.title
|
||||||
|
|
||||||
author = (circles.emptyToNull() ?: artists).joinToString { it.capitalizeEach() }
|
author = (circles.emptyToNull() ?: artists).joinToString { it.capitalizeEach() }
|
||||||
artist = artists.joinToString { it.capitalizeEach() }
|
artist = artists.joinToString { it.capitalizeEach() }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user