diff --git a/src/main/kotlin/fr/shikkanime/Application.kt b/src/main/kotlin/fr/shikkanime/Application.kt index 5f87ae69..5f49dc99 100644 --- a/src/main/kotlin/fr/shikkanime/Application.kt +++ b/src/main/kotlin/fr/shikkanime/Application.kt @@ -84,6 +84,13 @@ private fun updateAndDeleteData(episodeMappingService: EpisodeMappingService, an return@forEach } + val toSlug = StringUtils.toSlug(StringUtils.getShortName(it.name!!)) + + if (toSlug != it.slug) { + it.slug = toSlug + logger.info("Updating slug for anime ${it.name} to $toSlug") + } + it.status = StringUtils.getStatus(it) animeService.update(it) } diff --git a/src/main/kotlin/fr/shikkanime/services/ImageService.kt b/src/main/kotlin/fr/shikkanime/services/ImageService.kt index 9300f368..8c7d810f 100644 --- a/src/main/kotlin/fr/shikkanime/services/ImageService.kt +++ b/src/main/kotlin/fr/shikkanime/services/ImageService.kt @@ -228,7 +228,7 @@ object ImageService { cache.removeIf { it.uuid == uuid.toString() && it.type == type } } - operator fun get(uuid: UUID, type: Type): Image? = cache.find { it.uuid == uuid.toString() && it.type == type } + operator fun get(uuid: UUID, type: Type): Image? = cache.toList().find { it.uuid == uuid.toString() && it.type == type } val size: Int get() = cache.size diff --git a/src/main/kotlin/fr/shikkanime/utils/StringUtils.kt b/src/main/kotlin/fr/shikkanime/utils/StringUtils.kt index ccd5cb09..5cef0b76 100644 --- a/src/main/kotlin/fr/shikkanime/utils/StringUtils.kt +++ b/src/main/kotlin/fr/shikkanime/utils/StringUtils.kt @@ -16,7 +16,7 @@ import java.util.regex.Pattern object StringUtils { private val nonLatinPattern: Pattern = Pattern.compile("[^\\w-]") private val whitespacePattern: Pattern = Pattern.compile("\\s") - private val regex = "([-|!].*[-|!])|(Saison \\d*)|\\(\\d*\\)".toRegex() + private val regex = "( [-|!].*[-|!])|(Saison \\d*)|\\(\\d*\\)".toRegex() private val separators = listOf(":", ",", "!", "–", " so ") private fun isAllPartsHaveSameAmountOfWords(parts: List, limit: Int): Boolean { diff --git a/src/test/kotlin/fr/shikkanime/utils/StringUtilsTest.kt b/src/test/kotlin/fr/shikkanime/utils/StringUtilsTest.kt index 18baadc0..063e1f22 100644 --- a/src/test/kotlin/fr/shikkanime/utils/StringUtilsTest.kt +++ b/src/test/kotlin/fr/shikkanime/utils/StringUtilsTest.kt @@ -39,6 +39,7 @@ class StringUtilsTest { "Yuru Camp" to "Yuru Camp – Au grand air", "Studio Apartment, Good Lighting, Angel Included" to "Studio Apartment, Good Lighting, Angel Included", "Je survivrai grâce aux potions !" to "Je survivrai grâce aux potions !", + "Rent-a-Girlfriend" to "Rent-a-Girlfriend", ) list.forEach { (expected, input) -> @@ -54,6 +55,7 @@ class StringUtilsTest { "I Was Reincarnated as the 7th Prince so I Can Take My Time Perfecting My Magical Ability" to "i-was-reincarnated-as-the-7th-prince", "Studio Apartment, Good Lighting, Angel Included" to "studio-apartment-good-lighting-angel-included", "Je survivrai grâce aux potions !" to "je-survivrai-grace-aux-potions", + "Rent-a-Girlfriend" to "rent-a-girlfriend", ) list.forEach { (input, expected) ->