diff --git a/app/src/main/java/ani/dantotsu/media/anime/AnimeNameAdapter.kt b/app/src/main/java/ani/dantotsu/media/anime/AnimeNameAdapter.kt index 272464ac23..ccc44eeca4 100644 --- a/app/src/main/java/ani/dantotsu/media/anime/AnimeNameAdapter.kt +++ b/app/src/main/java/ani/dantotsu/media/anime/AnimeNameAdapter.kt @@ -1,5 +1,6 @@ package ani.dantotsu.media.anime +import java.util.Locale import java.util.regex.Matcher import java.util.regex.Pattern @@ -10,7 +11,39 @@ class AnimeNameAdapter { const val failedEpisodeNumberRegex = "(? "sub" + SubDubType.DUB -> "dub" + } + val toggledCasePreserved = + if (subdub?.get(0)?.isUpperCase() == true || soft?.get(0) + ?.isUpperCase() == true + ) toggled.replaceFirstChar { + if (it.isLowerCase()) it.titlecase( + Locale.ROOT + ) else it.toString() + } else toggled + + subdubMatcher.replaceFirst(toggledCasePreserved + bed) + } else { + null + } + } + + enum class SubDubType { + SUB, DUB + } fun findSeasonNumber(text: String): Int? { val seasonPattern: Pattern = Pattern.compile(seasonRegex, Pattern.CASE_INSENSITIVE)