mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
fix(chapter): Fixed chapter number parsing when number is after unwanted tag
This commit is contained in:
parent
b34ca34d1c
commit
4549f937f2
1 changed files with 25 additions and 15 deletions
|
@ -37,25 +37,35 @@ object ChapterRecognition {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get chapter title with lower case
|
// Get chapter title with lower case
|
||||||
var name = chapterName.lowercase()
|
val cleanChapterName = chapterName.lowercase()
|
||||||
|
// Remove manga title from chapter title.
|
||||||
|
.replace(mangaTitle.lowercase(), "").trim()
|
||||||
|
// Remove comma's or hyphens.
|
||||||
|
.replace(',', '.')
|
||||||
|
.replace('-', '.')
|
||||||
|
// Remove unwanted white spaces.
|
||||||
|
.replace(unwantedWhiteSpace, "")
|
||||||
|
|
||||||
// Remove manga title from chapter title.
|
val numberMatch = number.findAll(cleanChapterName)
|
||||||
name = name.replace(mangaTitle.lowercase(), "").trim()
|
|
||||||
|
|
||||||
// Remove comma's or hyphens.
|
when {
|
||||||
name = name.replace(',', '.').replace('-', '.')
|
numberMatch.none() -> {
|
||||||
|
return chapterNumber ?: -1f
|
||||||
|
}
|
||||||
|
numberMatch.count() > 1 -> {
|
||||||
|
// Remove unwanted tags.
|
||||||
|
unwanted.replace(cleanChapterName, "").let { name ->
|
||||||
|
// Check base case ch.xx
|
||||||
|
basic.find(name)?.let { return getChapterNumberFromMatch(it) }
|
||||||
|
|
||||||
// Remove unwanted white spaces.
|
// need to find again first number might already removed
|
||||||
name = unwantedWhiteSpace.replace(name, "")
|
number.find(name)?.let { return getChapterNumberFromMatch(it) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remove unwanted tags.
|
// return the first number encountered
|
||||||
name = unwanted.replace(name, "")
|
return getChapterNumberFromMatch(numberMatch.first())
|
||||||
|
|
||||||
basic.find(name)?.let { return getChapterNumberFromMatch(it) }
|
|
||||||
|
|
||||||
number.find(name)?.let { return getChapterNumberFromMatch(it) }
|
|
||||||
|
|
||||||
return chapterNumber ?: -1f
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue