Skip to content

Commit

Permalink
Fix some dash name
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziedelth committed May 6, 2024
1 parent 043b425 commit ce82b28
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/main/kotlin/fr/shikkanime/Application.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/fr/shikkanime/services/ImageService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/fr/shikkanime/utils/StringUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>, limit: Int): Boolean {
Expand Down
2 changes: 2 additions & 0 deletions src/test/kotlin/fr/shikkanime/utils/StringUtilsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) ->
Expand All @@ -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) ->
Expand Down

0 comments on commit ce82b28

Please sign in to comment.