diff --git a/src/main/kotlin/fr/shikkanime/dtos/WeeklyAnimeDto.kt b/src/main/kotlin/fr/shikkanime/dtos/WeeklyAnimeDto.kt index 8c53e611..206f6d48 100644 --- a/src/main/kotlin/fr/shikkanime/dtos/WeeklyAnimeDto.kt +++ b/src/main/kotlin/fr/shikkanime/dtos/WeeklyAnimeDto.kt @@ -1,10 +1,12 @@ package fr.shikkanime.dtos +import fr.shikkanime.dtos.variants.EpisodeVariantWithoutMappingDto import fr.shikkanime.entities.enums.LangType data class WeeklyAnimeDto( val anime: AnimeDto, val releaseDateTime: String, val langType: LangType, - val platforms: List + val platforms: List, + val variant: EpisodeVariantWithoutMappingDto? ) diff --git a/src/main/kotlin/fr/shikkanime/services/AnimeService.kt b/src/main/kotlin/fr/shikkanime/services/AnimeService.kt index 795ffc4b..d2ba2ee8 100644 --- a/src/main/kotlin/fr/shikkanime/services/AnimeService.kt +++ b/src/main/kotlin/fr/shikkanime/services/AnimeService.kt @@ -7,6 +7,7 @@ import fr.shikkanime.dtos.PlatformDto import fr.shikkanime.dtos.WeeklyAnimeDto import fr.shikkanime.dtos.WeeklyAnimesDto import fr.shikkanime.dtos.enums.Status +import fr.shikkanime.dtos.variants.EpisodeVariantWithoutMappingDto import fr.shikkanime.entities.* import fr.shikkanime.entities.enums.CountryCode import fr.shikkanime.entities.enums.LangType @@ -19,6 +20,7 @@ import java.time.LocalDate import java.time.ZoneId import java.time.ZonedDateTime import java.time.format.DateTimeFormatter +import java.time.temporal.ChronoField import java.util.* class AnimeService : AbstractService() { @@ -70,9 +72,8 @@ class AnimeService : AbstractService() { return startOfWeekDay.datesUntil(startOfWeekDay.plusDays(7)).toList().map { date -> val zonedDate = date.atStartOfDay(zoneId) - val episodeVariants = list.filter { - it.releaseDateTime.withZoneSameInstant(zoneId).dayOfWeek == zonedDate.dayOfWeek - } + val episodeVariants = list.sortedByDescending { it.releaseDateTime } + .filter { it.releaseDateTime.withZoneSameInstant(zoneId).dayOfWeek == zonedDate.dayOfWeek } WeeklyAnimesDto( date.format(DateTimeFormatter.ofPattern("EEEE", Locale.forLanguageTag(countryCode.locale))) @@ -92,7 +93,13 @@ class AnimeService : AbstractService() { .sorted() .distinct(), PlatformDto::class.java - )!! + )!!, + // If variant is same week as startOfWeekDay, return it + if (distinctVariant.releaseDateTime.withZoneSameInstant(zoneId)[ChronoField.ALIGNED_WEEK_OF_YEAR] == startOfWeekDay[ChronoField.ALIGNED_WEEK_OF_YEAR]) { + AbstractConverter.convert(distinctVariant, EpisodeVariantWithoutMappingDto::class.java) + } else { + null + } ) }.sortedWith(compareBy({ ZonedDateTime.parse(it.releaseDateTime).withZoneSameInstant(zoneId).toLocalTime() diff --git a/src/main/kotlin/fr/shikkanime/services/EpisodeMappingService.kt b/src/main/kotlin/fr/shikkanime/services/EpisodeMappingService.kt index f0df69fb..c0f094f8 100644 --- a/src/main/kotlin/fr/shikkanime/services/EpisodeMappingService.kt +++ b/src/main/kotlin/fr/shikkanime/services/EpisodeMappingService.kt @@ -172,6 +172,11 @@ class EpisodeMappingService : AbstractService val variant = episodeVariantService.find(variantDto.uuid) ?: return@forEach variant.mapping = update + + if (variantDto.releaseDateTime.isNotBlank() && variantDto.releaseDateTime != variant.releaseDateTime.toString()) { + variant.releaseDateTime = ZonedDateTime.parse(variantDto.releaseDateTime) + } + oldList.removeIf { it.uuid == variantDto.uuid } episodeVariantService.update(variant) } diff --git a/src/main/kotlin/fr/shikkanime/services/EpisodeVariantService.kt b/src/main/kotlin/fr/shikkanime/services/EpisodeVariantService.kt index 84d2bb54..978c4d04 100644 --- a/src/main/kotlin/fr/shikkanime/services/EpisodeVariantService.kt +++ b/src/main/kotlin/fr/shikkanime/services/EpisodeVariantService.kt @@ -139,7 +139,7 @@ class EpisodeVariantService : AbstractService + style="cursor: pointer" target="_blank" :href="episode.image"> @@ -170,7 +170,8 @@ + :value="variant.releaseDateTime.substring(0, 16)" + @input="variant.releaseDateTime = $event.target.value + ':00Z'">
@@ -192,8 +193,17 @@
- + +
+ + + + + +
Uncensored
- Variant image
diff --git a/src/main/resources/templates/site/calendar.ftl b/src/main/resources/templates/site/calendar.ftl index 06c8398a..6ce33c03 100644 --- a/src/main/resources/templates/site/calendar.ftl +++ b/src/main/resources/templates/site/calendar.ftl @@ -57,10 +57,27 @@