Skip to content

Commit

Permalink
Merge pull request #159 from Shikkanime/dev
Browse files Browse the repository at this point in the history
Fix bugs
  • Loading branch information
Ziedelth authored Feb 8, 2024
2 parents 02a84cc + 8e47387 commit 23a59c0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/fr/shikkanime/Application.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fun main() {
animeService.preIndex()

animeService.findAll()
.filter { it.slug.isNullOrBlank() }
.filter { it.slug.isNullOrBlank() || it.slug != StringUtils.toSlug(StringUtils.getShortName(it.name!!)) }
.forEach {
val name = StringUtils.getShortName(it.name!!)
val slug = StringUtils.toSlug(name)
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/fr/shikkanime/platforms/NetflixPlatform.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class NetflixPlatform : AbstractPlatform<NetflixConfiguration, CountryCodeNetfli
val durationInSeconds = duration?.substringBefore(" ")?.trim()?.toLongOrNull()?.times(60) ?: -1
val image = episode.selectFirst(".episode-thumbnail-image")?.attr("src") ?: return@mapNotNull null
val imageWithoutParams = image.substringBefore("?")
val episodeDescription = episode.selectFirst(".epsiode-synopsis")?.text()

Episode(
platform = getPlatform(),
Expand All @@ -70,6 +71,7 @@ class NetflixPlatform : AbstractPlatform<NetflixConfiguration, CountryCodeNetfli
url = "https://www.netflix.com/${key.countryCode.name.lowercase()}/title/$id",
image = imageWithoutParams,
duration = durationInSeconds,
description = episodeDescription,
).also { add(it) }
}
}
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 @@ -68,7 +68,7 @@ object StringUtils {
fun toSlug(input: String): String {
val nowhitespace: String = WHITESPACE.matcher(input).replaceAll("-")
val normalized: String = Normalizer.normalize(nowhitespace, Normalizer.Form.NFD)
val slug: String = NONLATIN.matcher(normalized).replaceAll("")
val slug: String = NONLATIN.matcher(normalized).replaceAll("").replace("-+".toRegex(), "-")
return slug.lowercase()
}
}
2 changes: 1 addition & 1 deletion src/main/resources/templates/site/anime.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="container">
<div class="row g-3 mt-3">
<div class="col-md-4 col-12 mt-0 text-center">
<img loading="lazy" src="https://api.shikkanime.fr/v1/attachments?uuid=${anime.uuid}&type=image"
<img loading="lazy" data-src="https://api.shikkanime.fr/v1/attachments?uuid=${anime.uuid}&type=image"
alt="${anime.shortName?replace("\"", "'")} anime image" class="w-50">
</div>
Expand Down
11 changes: 11 additions & 0 deletions src/test/kotlin/fr/shikkanime/utils/StringUtilsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,15 @@ class StringUtilsTest {
assertEquals(expected, StringUtils.getShortName(input))
}
}

@Test
fun toSlug() {
val list = listOf(
"Gloutons & Dragons" to "gloutons-dragons",
)

list.forEach { (input, expected) ->
assertEquals(expected, StringUtils.toSlug(input))
}
}
}

0 comments on commit 23a59c0

Please sign in to comment.