From 51e9d2aef14b94305ffa8d16804fe70f8cac4bab Mon Sep 17 00:00:00 2001 From: Ziedelth Date: Wed, 10 Apr 2024 14:44:10 +0200 Subject: [PATCH 1/2] Fix anime save status --- src/main/kotlin/fr/shikkanime/services/AnimeService.kt | 2 ++ src/main/kotlin/fr/shikkanime/services/EpisodeService.kt | 1 + src/main/kotlin/fr/shikkanime/utils/StringUtils.kt | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/fr/shikkanime/services/AnimeService.kt b/src/main/kotlin/fr/shikkanime/services/AnimeService.kt index 08a2cc7f..287f91e4 100644 --- a/src/main/kotlin/fr/shikkanime/services/AnimeService.kt +++ b/src/main/kotlin/fr/shikkanime/services/AnimeService.kt @@ -105,6 +105,8 @@ class AnimeService : AbstractService() { ) }.toMutableSet() + entity.description = entity.description?.replace("\n", "") + ?.replace("\r", "") entity.status = StringUtils.getStatus(entity) val savedEntity = super.save(entity) val uuid = savedEntity.uuid!! diff --git a/src/main/kotlin/fr/shikkanime/services/EpisodeService.kt b/src/main/kotlin/fr/shikkanime/services/EpisodeService.kt index 05377a07..2232c027 100644 --- a/src/main/kotlin/fr/shikkanime/services/EpisodeService.kt +++ b/src/main/kotlin/fr/shikkanime/services/EpisodeService.kt @@ -139,6 +139,7 @@ class EpisodeService : AbstractService() { } if (entity.anime != anime) { + anime.status = StringUtils.getStatus(anime) entity.anime = animeService.update(anime) } diff --git a/src/main/kotlin/fr/shikkanime/utils/StringUtils.kt b/src/main/kotlin/fr/shikkanime/utils/StringUtils.kt index bec924c7..6e16c96f 100644 --- a/src/main/kotlin/fr/shikkanime/utils/StringUtils.kt +++ b/src/main/kotlin/fr/shikkanime/utils/StringUtils.kt @@ -91,7 +91,7 @@ object StringUtils { ) = image.isNullOrBlank() || description.isNullOrBlank() || description.startsWith("(") || - languageCacheService.detectLanguage(description) != countryCode.name.lowercase() + (description.isNotBlank() && languageCacheService.detectLanguage(description) != countryCode.name.lowercase()) fun getStatus(anime: Anime): Status { val languageCacheService = Constant.injector.getInstance(LanguageCacheService::class.java) From 383ac6bdbd279544ac4dd7af89083ea5ab6a6328 Mon Sep 17 00:00:00 2001 From: Ziedelth Date: Wed, 10 Apr 2024 14:48:39 +0200 Subject: [PATCH 2/2] Add status on anime dto --- .../fr/shikkanime/converters/anime/AnimeToAnimeDtoConverter.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/fr/shikkanime/converters/anime/AnimeToAnimeDtoConverter.kt b/src/main/kotlin/fr/shikkanime/converters/anime/AnimeToAnimeDtoConverter.kt index 342c3ef3..3602ddcc 100644 --- a/src/main/kotlin/fr/shikkanime/converters/anime/AnimeToAnimeDtoConverter.kt +++ b/src/main/kotlin/fr/shikkanime/converters/anime/AnimeToAnimeDtoConverter.kt @@ -34,7 +34,8 @@ class AnimeToAnimeDtoConverter : AbstractConverter() { slug = from.slug, lastReleaseDateTime = from.lastReleaseDateTime.withUTC() .format(DateTimeFormatter.ISO_OFFSET_DATE_TIME), - langTypes = animeService.getAllLangTypes(from) + langTypes = animeService.getAllLangTypes(from), + status = from.status, ) } } \ No newline at end of file