diff --git a/src/main/kotlin/fr/shikkanime/converters/episode/EpisodeToEpisodeDtoConverter.kt b/src/main/kotlin/fr/shikkanime/converters/episode/EpisodeToEpisodeDtoConverter.kt index f6147f22..a8fe52bf 100644 --- a/src/main/kotlin/fr/shikkanime/converters/episode/EpisodeToEpisodeDtoConverter.kt +++ b/src/main/kotlin/fr/shikkanime/converters/episode/EpisodeToEpisodeDtoConverter.kt @@ -3,12 +3,23 @@ package fr.shikkanime.converters.episode import fr.shikkanime.converters.AbstractConverter import fr.shikkanime.dtos.EpisodeDto import fr.shikkanime.dtos.animes.AnimeDto +import fr.shikkanime.dtos.enums.Status import fr.shikkanime.entities.Episode import fr.shikkanime.utils.withUTC +import org.apache.tika.language.detect.LanguageDetector import java.time.format.DateTimeFormatter class EpisodeToEpisodeDtoConverter : AbstractConverter() { + private val languageDetector: LanguageDetector = LanguageDetector.getDefaultLanguageDetector().loadModels() + override fun convert(from: Episode): EpisodeDto { + val status = if ( + from.image.isNullOrBlank() || + from.description.isNullOrBlank() || + from.description?.startsWith("(") == true || + languageDetector.detect(from.description).language.lowercase() != from.anime!!.countryCode!!.name.lowercase() + ) Status.INVALID else Status.VALID + return EpisodeDto( uuid = from.uuid, platform = from.platform!!, @@ -25,7 +36,8 @@ class EpisodeToEpisodeDtoConverter : AbstractConverter() { duration = from.duration, description = from.description, uncensored = from.image!!.contains("nc/", true), - lastUpdateDateTime = from.lastUpdateDateTime?.withUTC()?.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME) + lastUpdateDateTime = from.lastUpdateDateTime?.withUTC()?.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME), + status = status, ) } } \ No newline at end of file diff --git a/src/main/kotlin/fr/shikkanime/dtos/EpisodeDto.kt b/src/main/kotlin/fr/shikkanime/dtos/EpisodeDto.kt index 43392129..2610b661 100644 --- a/src/main/kotlin/fr/shikkanime/dtos/EpisodeDto.kt +++ b/src/main/kotlin/fr/shikkanime/dtos/EpisodeDto.kt @@ -1,6 +1,7 @@ package fr.shikkanime.dtos import fr.shikkanime.dtos.animes.AnimeDto +import fr.shikkanime.dtos.enums.Status import fr.shikkanime.entities.enums.EpisodeType import fr.shikkanime.entities.enums.LangType import fr.shikkanime.entities.enums.Platform @@ -24,4 +25,5 @@ data class EpisodeDto( val description: String?, val uncensored: Boolean, val lastUpdateDateTime: String?, + val status: Status? = null, ) : Serializable diff --git a/src/main/kotlin/fr/shikkanime/repositories/EpisodeRepository.kt b/src/main/kotlin/fr/shikkanime/repositories/EpisodeRepository.kt index 72e4d214..912852b7 100644 --- a/src/main/kotlin/fr/shikkanime/repositories/EpisodeRepository.kt +++ b/src/main/kotlin/fr/shikkanime/repositories/EpisodeRepository.kt @@ -35,7 +35,7 @@ class EpisodeRepository : AbstractRepository() { } private fun buildSortQuery(sort: List, query: StringBuilder) { - val fields = listOf("episodeType", "langType", "releaseDateTime", "season", "number") + val fields = listOf("episodeType", "langType", "releaseDateTime", "season", "number", "lastUpdateDateTime") val subQuery = mutableListOf() sort.filter { fields.contains(it.field) }.forEach { param -> diff --git a/src/main/kotlin/fr/shikkanime/services/EpisodeService.kt b/src/main/kotlin/fr/shikkanime/services/EpisodeService.kt index e160a8d2..2d7e08bf 100644 --- a/src/main/kotlin/fr/shikkanime/services/EpisodeService.kt +++ b/src/main/kotlin/fr/shikkanime/services/EpisodeService.kt @@ -151,6 +151,7 @@ class EpisodeService : AbstractService() { parameters["duration"]?.takeIf { it.isNotBlank() }?.let { episode.duration = it.toLong() } parameters["description"]?.takeIf { it.isNotBlank() }?.let { episode.description = it } + episode.lastUpdateDateTime = ZonedDateTime.now() val update = super.update(episode) MapCache.invalidate(Episode::class.java) diff --git a/src/main/resources/templates/admin/episodes/edit.ftl b/src/main/resources/templates/admin/episodes/edit.ftl index a3679a30..a09c5798 100644 --- a/src/main/resources/templates/admin/episodes/edit.ftl +++ b/src/main/resources/templates/admin/episodes/edit.ftl @@ -76,6 +76,13 @@ +
+ + " + disabled> +
diff --git a/src/main/resources/templates/admin/episodes/list.ftl b/src/main/resources/templates/admin/episodes/list.ftl index 568f3d39..df9ea59e 100644 --- a/src/main/resources/templates/admin/episodes/list.ftl +++ b/src/main/resources/templates/admin/episodes/list.ftl @@ -13,10 +13,8 @@ Anime Platform - Episode type - Lang type - Season - Number + Details + Description Actions @@ -34,14 +32,40 @@