Anchira: Improve chapter suffix parsing (#1904)
* Improve chapter suffix parsing * Don't convert Tags to sequence before sorting
This commit is contained in:
parent
0a0ff7c1ac
commit
046c2aa421
|
@ -1,7 +1,7 @@
|
|||
ext {
|
||||
extName = 'Anchira'
|
||||
extClass = '.Anchira'
|
||||
extVersionCode = 10
|
||||
extVersionCode = 11
|
||||
isNsfw = true
|
||||
}
|
||||
|
||||
|
|
|
@ -120,11 +120,6 @@ class Anchira : HttpSource(), ConfigurableSource {
|
|||
query.substringAfter(SLUG_BUNDLE_PREFIX),
|
||||
filters,
|
||||
).removeAllQueryParameters("page")
|
||||
if (
|
||||
url.build().queryParameter("sort") == "4"
|
||||
) {
|
||||
url.removeAllQueryParameters("sort")
|
||||
}
|
||||
val manga = SManga.create()
|
||||
.apply { this.url = "?${url.build().query}" }
|
||||
fetchMangaDetails(manga).map {
|
||||
|
@ -280,7 +275,7 @@ class Anchira : HttpSource(), ConfigurableSource {
|
|||
for (page in 1..pages) {
|
||||
results.entries.forEach { data ->
|
||||
chapterList.add(
|
||||
createChapter(data, response, anchiraData),
|
||||
createChapter(data, anchiraData),
|
||||
)
|
||||
}
|
||||
if (page < pages) {
|
||||
|
@ -298,7 +293,7 @@ class Anchira : HttpSource(), ConfigurableSource {
|
|||
} else {
|
||||
val data = json.decodeFromString<Entry>(response.body.string())
|
||||
chapterList.add(
|
||||
createChapter(data, response, anchiraData),
|
||||
createChapter(data, anchiraData),
|
||||
)
|
||||
}
|
||||
return chapterList
|
||||
|
@ -468,7 +463,7 @@ class Anchira : HttpSource(), ConfigurableSource {
|
|||
|
||||
companion object {
|
||||
const val SLUG_SEARCH_PREFIX = "id:"
|
||||
const val SLUG_BUNDLE_PREFIX = "bundle:"
|
||||
private const val SLUG_BUNDLE_PREFIX = "bundle:"
|
||||
private const val IMAGE_QUALITY_PREF = "image_quality"
|
||||
private const val OPEN_SOURCE_PREF = "use_manga_source"
|
||||
private const val USE_TAG_GROUPING = "use_tag_grouping"
|
||||
|
@ -477,4 +472,5 @@ class Anchira : HttpSource(), ConfigurableSource {
|
|||
}
|
||||
}
|
||||
|
||||
val CHAPTER_SUFFIX_RE = Regex("(?<!20\\d\\d-)\\b[\\d.]{1,4}$")
|
||||
val CHAPTER_SUFFIX_RE =
|
||||
Regex("\\W*(?:Ch\\.?|Chapter|Part|Vol\\.?|Volume|#)?\\W?(?<!20\\d{2}-?)\\b[\\d.]{1,4}\\W?")
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package eu.kanade.tachiyomi.extension.en.anchira
|
||||
|
||||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import okhttp3.Response
|
||||
import java.util.Locale
|
||||
|
||||
object AnchiraHelper {
|
||||
|
@ -13,6 +12,7 @@ object AnchiraHelper {
|
|||
}
|
||||
it
|
||||
}
|
||||
.sortedBy { it.name }
|
||||
.sortedBy { it.namespace }
|
||||
.map {
|
||||
val tag = it.name.lowercase()
|
||||
|
@ -30,30 +30,31 @@ object AnchiraHelper {
|
|||
}
|
||||
.joinToString(", ") { it }
|
||||
|
||||
fun createChapter(entry: Entry, response: Response, anchiraData: List<EntryKey>) =
|
||||
fun createChapter(entry: Entry, anchiraData: List<EntryKey>) =
|
||||
SChapter.create().apply {
|
||||
val ch =
|
||||
CHAPTER_SUFFIX_RE.find(entry.title)?.value?.trim('.') ?: "1"
|
||||
val source = anchiraData.find { it.id == entry.id }?.url
|
||||
?: response.request.url.toString()
|
||||
val chSuffix = CHAPTER_SUFFIX_RE.find(entry.title)?.value.orEmpty()
|
||||
val chNumber =
|
||||
chSuffix.replace(Regex("[^.\\d]"), "").trim('.').takeUnless { it.isEmpty() } ?: "1"
|
||||
val source = Regex("fakku|irodori").find(
|
||||
anchiraData.find { it.id == entry.id }?.url.orEmpty(),
|
||||
)?.value.orEmpty().titleCase()
|
||||
url = "/g/${entry.id}/${entry.key}"
|
||||
name = "$ch. ${entry.title.removeSuffix(" $ch")}"
|
||||
name = "$chNumber. ${entry.title.removeSuffix(chSuffix)}"
|
||||
date_upload = entry.publishedAt * 1000
|
||||
chapter_number = ch.toFloat()
|
||||
chapter_number = chNumber.toFloat()
|
||||
scanlator = buildString {
|
||||
append(
|
||||
Regex("fakku|irodori|anchira").find(source)?.value.orEmpty()
|
||||
.replaceFirstChar {
|
||||
if (it.isLowerCase()) {
|
||||
it.titlecase(
|
||||
Locale.getDefault(),
|
||||
)
|
||||
} else {
|
||||
it.toString()
|
||||
}
|
||||
},
|
||||
)
|
||||
append(" - ${entry.pages} pages")
|
||||
if (source.isNotEmpty()) {
|
||||
append("$source - ")
|
||||
}
|
||||
append("${entry.pages} pages")
|
||||
}
|
||||
}
|
||||
|
||||
private fun String.titleCase() = replaceFirstChar {
|
||||
if (it.isLowerCase()) {
|
||||
it.titlecase(Locale.getDefault())
|
||||
} else {
|
||||
it.toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue