From bea44a7d04ee94adee7fcb87acfc6b2235201a36 Mon Sep 17 00:00:00 2001 From: Ziedelth Date: Sun, 7 Apr 2024 11:18:22 +0200 Subject: [PATCH] Fix bugs and add anime lang types --- .../admin/AdminPlatformController.kt | 15 ++++++++++--- .../controllers/site/SiteController.kt | 5 ++++- .../anime/AnimeToAnimeDtoConverter.kt | 1 - .../anime/AnimeToAnimeNoStatusDtoConverter.kt | 8 ++++++- .../fr/shikkanime/dtos/animes/AnimeDto.kt | 3 +++ .../dtos/animes/AnimeNoStatusDto.kt | 5 ++++- .../fr/shikkanime/jobs/FetchCalendarJob.kt | 18 +++++++++++---- .../AnimationDigitalNetworkPlatform.kt | 7 +++--- .../configuration/DisneyPlusConfiguration.kt | 18 +++++++++++++++ .../configuration/NetflixConfiguration.kt | 22 +++++++++++++++++++ .../configuration/PlatformConfiguration.kt | 16 ++++++++++++++ .../configuration/PrimeVideoConfiguration.kt | 22 ++++++++++++++++++- .../ReleaseDayPlatformSimulcast.kt | 20 +++++++++++++++++ .../repositories/AnimeRepository.kt | 13 +++++++++++ .../fr/shikkanime/services/AnimeService.kt | 22 ++++++++++--------- .../fr/shikkanime/services/EpisodeService.kt | 6 +++-- .../fr/shikkanime/services/ImageService.kt | 9 +++++++- .../services/caches/AnimeCacheService.kt | 7 +++--- .../socialnetworks/AbstractSocialNetwork.kt | 3 ++- .../socialnetworks/BskySocialNetwork.kt | 16 ++++++++++---- .../socialnetworks/ThreadsSocialNetwork.kt | 8 +++++-- .../socialnetworks/TwitterSocialNetwork.kt | 3 ++- src/main/resources/templates/site/anime.ftl | 9 ++++++++ .../resources/templates/site/calendar.ftl | 3 ++- .../templates/site/components/anime.ftl | 16 +++++++++++++- .../templates/site/components/episode.ftl | 6 +++-- .../templates/site/components/langType.ftl | 16 ++++++++++++++ 27 files changed, 254 insertions(+), 43 deletions(-) create mode 100644 src/main/resources/templates/site/components/langType.ftl diff --git a/src/main/kotlin/fr/shikkanime/controllers/admin/AdminPlatformController.kt b/src/main/kotlin/fr/shikkanime/controllers/admin/AdminPlatformController.kt index a50f25b6..0058e146 100644 --- a/src/main/kotlin/fr/shikkanime/controllers/admin/AdminPlatformController.kt +++ b/src/main/kotlin/fr/shikkanime/controllers/admin/AdminPlatformController.kt @@ -3,6 +3,7 @@ package fr.shikkanime.controllers.admin import fr.shikkanime.entities.enums.Link import fr.shikkanime.entities.enums.Platform import fr.shikkanime.utils.Constant +import fr.shikkanime.utils.LoggerFactory import fr.shikkanime.utils.routes.AdminSessionAuthenticated import fr.shikkanime.utils.routes.Controller import fr.shikkanime.utils.routes.Path @@ -13,9 +14,12 @@ import fr.shikkanime.utils.routes.param.BodyParam import fr.shikkanime.utils.routes.param.PathParam import io.ktor.http.* import java.util.* +import java.util.logging.Level @Controller("/admin/platforms") class AdminPlatformController { + private val logger = LoggerFactory.getLogger(javaClass) + @Path @Get @AdminSessionAuthenticated @@ -87,14 +91,19 @@ class AdminPlatformController { ): Response { val abstractPlatform = Constant.abstractPlatforms.find { it.getPlatform().name == platform.name } ?: return Response.redirect(Link.PLATFORMS.href) + val platformConfiguration = abstractPlatform.configuration!! + val uuid = parameters["uuid"]?.let { UUID.fromString(it) } - val simulcast = abstractPlatform.configuration!!.simulcasts.find { it.uuid == uuid } - ?: abstractPlatform.configuration!!.newPlatformSimulcast() + val simulcast = + platformConfiguration.simulcasts.find { it.uuid == uuid } ?: platformConfiguration.newPlatformSimulcast() simulcast.of(parameters) if (simulcast.uuid == null) { simulcast.uuid = UUID.randomUUID() - abstractPlatform.configuration?.addPlatformSimulcast(simulcast) + + if (!platformConfiguration.addPlatformSimulcast(simulcast)) { + logger.log(Level.SEVERE, "Failed to add simulcast") + } } abstractPlatform.saveConfiguration() diff --git a/src/main/kotlin/fr/shikkanime/controllers/site/SiteController.kt b/src/main/kotlin/fr/shikkanime/controllers/site/SiteController.kt index 9ede2d92..228148b3 100644 --- a/src/main/kotlin/fr/shikkanime/controllers/site/SiteController.kt +++ b/src/main/kotlin/fr/shikkanime/controllers/site/SiteController.kt @@ -167,7 +167,10 @@ class SiteController { return Response.template( Link.CALENDAR, mutableMapOf( - "weeklyAnimes" to animeCacheService.getWeeklyAnimes(now.minusDays(now.dayOfWeek.value.toLong() - 1), CountryCode.FR), + "weeklyAnimes" to animeCacheService.getWeeklyAnimes( + now.minusDays(now.dayOfWeek.value.toLong() - 1), + CountryCode.FR + ), ) ) } diff --git a/src/main/kotlin/fr/shikkanime/converters/anime/AnimeToAnimeDtoConverter.kt b/src/main/kotlin/fr/shikkanime/converters/anime/AnimeToAnimeDtoConverter.kt index 2614e5fd..3716d47d 100644 --- a/src/main/kotlin/fr/shikkanime/converters/anime/AnimeToAnimeDtoConverter.kt +++ b/src/main/kotlin/fr/shikkanime/converters/anime/AnimeToAnimeDtoConverter.kt @@ -21,7 +21,6 @@ class AnimeToAnimeDtoConverter : AbstractConverter() { languageCacheService.detectLanguage(from.description) != from.countryCode!!.name.lowercase() ) Status.INVALID else Status.VALID - return AnimeDto.from( convert(from, AnimeNoStatusDto::class.java), status diff --git a/src/main/kotlin/fr/shikkanime/converters/anime/AnimeToAnimeNoStatusDtoConverter.kt b/src/main/kotlin/fr/shikkanime/converters/anime/AnimeToAnimeNoStatusDtoConverter.kt index 30e5cbbd..c4a64827 100644 --- a/src/main/kotlin/fr/shikkanime/converters/anime/AnimeToAnimeNoStatusDtoConverter.kt +++ b/src/main/kotlin/fr/shikkanime/converters/anime/AnimeToAnimeNoStatusDtoConverter.kt @@ -1,9 +1,11 @@ package fr.shikkanime.converters.anime +import com.google.inject.Inject import fr.shikkanime.converters.AbstractConverter import fr.shikkanime.dtos.SimulcastDto import fr.shikkanime.dtos.animes.AnimeNoStatusDto import fr.shikkanime.entities.Anime +import fr.shikkanime.services.AnimeService import fr.shikkanime.services.SimulcastService.Companion.sortBySeasonAndYear import fr.shikkanime.utils.StringUtils import fr.shikkanime.utils.withUTC @@ -11,6 +13,9 @@ import org.hibernate.Hibernate import java.time.format.DateTimeFormatter class AnimeToAnimeNoStatusDtoConverter : AbstractConverter() { + @Inject + private lateinit var animeService: AnimeService + override fun convert(from: Anime): AnimeNoStatusDto { return AnimeNoStatusDto( uuid = from.uuid, @@ -28,7 +33,8 @@ class AnimeToAnimeNoStatusDtoConverter : AbstractConverter? = null, ) : AnimeNoStatusDto( uuid, countryCode, @@ -46,6 +48,7 @@ data class AnimeDto( animeNoStatusDto.slug, animeNoStatusDto.lastReleaseDateTime, status, + animeNoStatusDto.langTypes ) } } diff --git a/src/main/kotlin/fr/shikkanime/dtos/animes/AnimeNoStatusDto.kt b/src/main/kotlin/fr/shikkanime/dtos/animes/AnimeNoStatusDto.kt index 44fa45bf..6cfef990 100644 --- a/src/main/kotlin/fr/shikkanime/dtos/animes/AnimeNoStatusDto.kt +++ b/src/main/kotlin/fr/shikkanime/dtos/animes/AnimeNoStatusDto.kt @@ -2,6 +2,7 @@ package fr.shikkanime.dtos.animes import fr.shikkanime.dtos.SimulcastDto import fr.shikkanime.entities.enums.CountryCode +import fr.shikkanime.entities.enums.LangType import java.util.* open class AnimeNoStatusDto( @@ -26,7 +27,9 @@ open class AnimeNoStatusDto( @Transient open val slug: String? = null, @Transient - open val lastReleaseDateTime: String? = null + open val lastReleaseDateTime: String? = null, + @Transient + open val langTypes: List? = null, ) { fun toAnimeDto() = AnimeDto.from(this, null) } \ No newline at end of file diff --git a/src/main/kotlin/fr/shikkanime/jobs/FetchCalendarJob.kt b/src/main/kotlin/fr/shikkanime/jobs/FetchCalendarJob.kt index a7d3a89c..8f8c62c1 100644 --- a/src/main/kotlin/fr/shikkanime/jobs/FetchCalendarJob.kt +++ b/src/main/kotlin/fr/shikkanime/jobs/FetchCalendarJob.kt @@ -120,7 +120,12 @@ class FetchCalendarJob : AbstractJob { val platformImage = getPlatformImage(platform) platformImage?.let { graphics.drawImage(it, 25, y - 25, null) } graphics.drawString(platformName, 65, y) - graphics.fillRect(25, y + 15, (platformImage?.width ?: 0) + 10 + graphics.fontMetrics.stringWidth(platformName), 2) + graphics.fillRect( + 25, + y + 15, + (platformImage?.width ?: 0) + 10 + graphics.fontMetrics.stringWidth(platformName), + 2 + ) episodes.sortedBy { it.anime.lowercase() }.groupBy { it.anime }.forEach { (anime, episodes) -> val twoLines = if (episodes.size == 1) { @@ -213,14 +218,17 @@ class FetchCalendarJob : AbstractJob { val animeBody = Jsoup.parse(animePage.bodyAsText()) val list = animeBody.select(".info_fiche > div") ?: return@mapNotNull null - val licencePlatforms = list.find { it.text().contains("Licence VOD") }?.select("a")?.map { it.text() }?.toMutableList() + val licencePlatforms = + list.find { it.text().contains("Licence VOD") }?.select("a")?.map { it.text() }?.toMutableList() licencePlatforms?.removeIf { it.contains("TF1") } if (licencePlatforms.isNullOrEmpty()) { return@mapNotNull null } - val alternativeTitles = list.find { it.text().contains("Titre alternatif") }?.text()?.replace("Titre alternatif :", "")?.split("/") ?: emptyList() + val alternativeTitles = + list.find { it.text().contains("Titre alternatif") }?.text()?.replace("Titre alternatif :", "")?.split("/") + ?: emptyList() val detectedLanguage = languageCacheService.detectLanguage(title) if (detectedLanguage != null && detectedLanguage == "fr" && alternativeTitles.isNotEmpty()) { @@ -253,7 +261,9 @@ class FetchCalendarJob : AbstractJob { // If the last word of the first line and the first word of the second line is the same, we move the separator // Or if the first word of the first line and the first word of the second line is the same, we move the separator - if (first.split(" ").last() == second.split(" ").first() || first.split(" ").first() == second.split(" ").first()) { + if (first.split(" ").last() == second.split(" ").first() || first.split(" ").first() == second.split(" ") + .first() + ) { separator++ val (firstHalfTry, secondHalfTry) = words.withIndex().partition { (index, _) -> index < separator } first = firstHalfTry.joinToString(" ") { it.value } diff --git a/src/main/kotlin/fr/shikkanime/platforms/AnimationDigitalNetworkPlatform.kt b/src/main/kotlin/fr/shikkanime/platforms/AnimationDigitalNetworkPlatform.kt index 29247598..9fbc99ca 100644 --- a/src/main/kotlin/fr/shikkanime/platforms/AnimationDigitalNetworkPlatform.kt +++ b/src/main/kotlin/fr/shikkanime/platforms/AnimationDigitalNetworkPlatform.kt @@ -103,9 +103,10 @@ class AnimationDigitalNetworkPlatform : val descriptionLowercase = animeDescription.lowercase() isSimulcasted = isSimulcasted || - configCacheService.getValueAsString(ConfigPropertyKey.ANIMATION_DITIGAL_NETWORK_SIMULCAST_DETECTION_REGEX)?.let { - Regex(it).containsMatchIn(descriptionLowercase) - } == true + configCacheService.getValueAsString(ConfigPropertyKey.ANIMATION_DITIGAL_NETWORK_SIMULCAST_DETECTION_REGEX) + ?.let { + Regex(it).containsMatchIn(descriptionLowercase) + } == true if (!isSimulcasted) throw AnimeNotSimulcastedException("Anime is not simulcasted") diff --git a/src/main/kotlin/fr/shikkanime/platforms/configuration/DisneyPlusConfiguration.kt b/src/main/kotlin/fr/shikkanime/platforms/configuration/DisneyPlusConfiguration.kt index 3cf4d7b7..eb23d825 100644 --- a/src/main/kotlin/fr/shikkanime/platforms/configuration/DisneyPlusConfiguration.kt +++ b/src/main/kotlin/fr/shikkanime/platforms/configuration/DisneyPlusConfiguration.kt @@ -36,6 +36,24 @@ data class DisneyPlusConfiguration( ), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is DisneyPlusSimulcast) return false + if (!super.equals(other)) return false + + if (releaseDay != other.releaseDay) return false + if (releaseTime != other.releaseTime) return false + + return true + } + + override fun hashCode(): Int { + var result = super.hashCode() + result = 31 * result + releaseDay + result = 31 * result + releaseTime.hashCode() + return result + } } override fun newPlatformSimulcast() = DisneyPlusSimulcast() diff --git a/src/main/kotlin/fr/shikkanime/platforms/configuration/NetflixConfiguration.kt b/src/main/kotlin/fr/shikkanime/platforms/configuration/NetflixConfiguration.kt index 90887f65..8c253752 100644 --- a/src/main/kotlin/fr/shikkanime/platforms/configuration/NetflixConfiguration.kt +++ b/src/main/kotlin/fr/shikkanime/platforms/configuration/NetflixConfiguration.kt @@ -24,6 +24,28 @@ class NetflixConfiguration : PlatformConfiguration( diff --git a/src/main/kotlin/fr/shikkanime/platforms/configuration/PrimeVideoConfiguration.kt b/src/main/kotlin/fr/shikkanime/platforms/configuration/PrimeVideoConfiguration.kt index 31ea6bb2..5baf840c 100644 --- a/src/main/kotlin/fr/shikkanime/platforms/configuration/PrimeVideoConfiguration.kt +++ b/src/main/kotlin/fr/shikkanime/platforms/configuration/PrimeVideoConfiguration.kt @@ -5,7 +5,27 @@ class PrimeVideoConfiguration : PlatformConfiguration() { .resultList } } + + fun getAllLangTypes(anime: Anime): List { + return inTransaction { + createReadOnlyQuery( + it, + "SELECT DISTINCT e.langType FROM Episode e WHERE e.anime = :anime", + LangType::class.java + ) + .setParameter("anime", anime) + .resultList + } + } } \ No newline at end of file diff --git a/src/main/kotlin/fr/shikkanime/services/AnimeService.kt b/src/main/kotlin/fr/shikkanime/services/AnimeService.kt index 7f873bcb..896a145e 100644 --- a/src/main/kotlin/fr/shikkanime/services/AnimeService.kt +++ b/src/main/kotlin/fr/shikkanime/services/AnimeService.kt @@ -71,21 +71,23 @@ class AnimeService : AbstractService() { dateTitle, episodes.distinctBy { episode -> episode.anime?.uuid.toString() + episode.langType.toString() } .map { distinctEpisode -> - val platforms = episodes.filter { it.anime?.uuid == distinctEpisode.anime?.uuid } - .mapNotNull(Episode::platform) - .distinct() - - WeeklyAnimeDto( - AbstractConverter.convert(distinctEpisode.anime, AnimeNoStatusDto::class.java).toAnimeDto(), - distinctEpisode.releaseDateTime.withUTC().format(DateTimeFormatter.ISO_OFFSET_DATE_TIME), - distinctEpisode.langType!!, - AbstractConverter.convert(platforms, PlatformDto::class.java) - ) + val platforms = episodes.filter { it.anime?.uuid == distinctEpisode.anime?.uuid } + .mapNotNull(Episode::platform) + .distinct() + + WeeklyAnimeDto( + AbstractConverter.convert(distinctEpisode.anime, AnimeNoStatusDto::class.java).toAnimeDto(), + distinctEpisode.releaseDateTime.withUTC().format(DateTimeFormatter.ISO_OFFSET_DATE_TIME), + distinctEpisode.langType!!, + AbstractConverter.convert(platforms, PlatformDto::class.java) + ) }.sortedBy { ZonedDateTime.parse(it.releaseDateTime).withZoneSameInstant(zoneId).toLocalTime() } ) } } + fun getAllLangTypes(anime: Anime) = animeRepository.getAllLangTypes(anime) + fun addImage(uuid: UUID, image: String, bypass: Boolean = false) { ImageService.add(uuid, ImageService.Type.IMAGE, image, 480, 720, bypass) } diff --git a/src/main/kotlin/fr/shikkanime/services/EpisodeService.kt b/src/main/kotlin/fr/shikkanime/services/EpisodeService.kt index da970b27..a12f8707 100644 --- a/src/main/kotlin/fr/shikkanime/services/EpisodeService.kt +++ b/src/main/kotlin/fr/shikkanime/services/EpisodeService.kt @@ -77,7 +77,8 @@ class EpisodeService : AbstractService() { val nextSimulcast = simulcasts[2] val isAnimeReleaseDateTimeBeforeMinusXDays = anime.releaseDateTime.isBefore(adjustedDates[0]) - val animeEpisodes = anime.uuid?.let { episodeRepository.findAllByAnime(it).sortedBy { episode -> episode.releaseDateTime } } + val animeEpisodes = + anime.uuid?.let { episodeRepository.findAllByAnime(it).sortedBy { episode -> episode.releaseDateTime } } val previousEpisode = animeEpisodes?.lastOrNull { it.releaseDateTime.isBefore(entity.releaseDateTime) && it.episodeType == entity.episodeType && it.langType == entity.langType } val diff = previousEpisode?.releaseDateTime?.until(entity.releaseDateTime, ChronoUnit.MONTHS) ?: -1 @@ -110,7 +111,8 @@ class EpisodeService : AbstractService() { override fun save(entity: Episode): Episode { val copy = entity.anime!!.copy() - val anime = animeService.findAllByLikeName(copy.countryCode!!, copy.name!!).firstOrNull() ?: animeService.save(copy) + val anime = + animeService.findAllByLikeName(copy.countryCode!!, copy.name!!).firstOrNull() ?: animeService.save(copy) entity.anime = anime.copy() if (anime.banner.isNullOrBlank() && !copy.banner.isNullOrBlank()) { diff --git a/src/main/kotlin/fr/shikkanime/services/ImageService.kt b/src/main/kotlin/fr/shikkanime/services/ImageService.kt index 156277b8..fd86aa81 100644 --- a/src/main/kotlin/fr/shikkanime/services/ImageService.kt +++ b/src/main/kotlin/fr/shikkanime/services/ImageService.kt @@ -549,7 +549,14 @@ object ImageService { fillRoundRect(x, y, textWidth + marginX, textHeight + marginY, 10, 10) color = backgroundColor - fillRoundRect(x + borderWidth, y + borderWidth, textWidth + marginX - (borderWidth * 2), textHeight + marginY - (borderWidth * 2), 10, 10) + fillRoundRect( + x + borderWidth, + y + borderWidth, + textWidth + marginX - (borderWidth * 2), + textHeight + marginY - (borderWidth * 2), + 10, + 10 + ) color = Color.WHITE drawString(text, x + marginX / 2, y + (marginY / 2) + textHeight - 5) } diff --git a/src/main/kotlin/fr/shikkanime/services/caches/AnimeCacheService.kt b/src/main/kotlin/fr/shikkanime/services/caches/AnimeCacheService.kt index fb33f200..e6f8d284 100644 --- a/src/main/kotlin/fr/shikkanime/services/caches/AnimeCacheService.kt +++ b/src/main/kotlin/fr/shikkanime/services/caches/AnimeCacheService.kt @@ -41,9 +41,10 @@ class AnimeCacheService : AbstractCacheService { AbstractConverter.convert(animeService.findBySlug(it), AnimeDto::class.java) } - private val weeklyCache = MapCache>(classes = listOf(Episode::class.java)) { - animeService.getWeeklyAnimes(it.localDate, it.countryCode) - } + private val weeklyCache = + MapCache>(classes = listOf(Episode::class.java)) { + animeService.getWeeklyAnimes(it.localDate, it.countryCode) + } fun findAllBy( countryCode: CountryCode?, diff --git a/src/main/kotlin/fr/shikkanime/socialnetworks/AbstractSocialNetwork.kt b/src/main/kotlin/fr/shikkanime/socialnetworks/AbstractSocialNetwork.kt index 674bc4d3..a94d54c6 100644 --- a/src/main/kotlin/fr/shikkanime/socialnetworks/AbstractSocialNetwork.kt +++ b/src/main/kotlin/fr/shikkanime/socialnetworks/AbstractSocialNetwork.kt @@ -39,7 +39,8 @@ abstract class AbstractSocialNetwork { configMessage = configMessage.replace("{SHIKKANIME_URL}", getShikkanimeUrl(episodeDto)) configMessage = configMessage.replace("{URL}", episodeDto.url) configMessage = configMessage.replace("{PLATFORM_ACCOUNT}", platformAccount(episodeDto.platform)) - configMessage = configMessage.replace("{ANIME_HASHTAG}", "#${StringUtils.getHashtag(episodeDto.anime.shortName)}") + configMessage = + configMessage.replace("{ANIME_HASHTAG}", "#${StringUtils.getHashtag(episodeDto.anime.shortName)}") configMessage = configMessage.replace("{ANIME_TITLE}", episodeDto.anime.shortName) configMessage = configMessage.replace("{EPISODE_INFORMATION}", "${information(episodeDto)}${uncensored}") configMessage = configMessage.replace("{VOICE}", isVoice) diff --git a/src/main/kotlin/fr/shikkanime/socialnetworks/BskySocialNetwork.kt b/src/main/kotlin/fr/shikkanime/socialnetworks/BskySocialNetwork.kt index dd1db209..b255b353 100644 --- a/src/main/kotlin/fr/shikkanime/socialnetworks/BskySocialNetwork.kt +++ b/src/main/kotlin/fr/shikkanime/socialnetworks/BskySocialNetwork.kt @@ -47,7 +47,12 @@ class BskySocialNetwork : AbstractSocialNetwork() { } private fun checkSession() { - if (initializedAt != null && initializedAt!!.plusMinutes(configCacheService.getValueAsInt(ConfigPropertyKey.BSKY_SESSION_TIMEOUT, 10).toLong()) + if (initializedAt != null && initializedAt!!.plusMinutes( + configCacheService.getValueAsInt( + ConfigPropertyKey.BSKY_SESSION_TIMEOUT, + 10 + ).toLong() + ) .isAfter(ZonedDateTime.now()) ) { return @@ -66,9 +71,11 @@ class BskySocialNetwork : AbstractSocialNetwork() { override fun sendEpisodeRelease(episodeDto: EpisodeDto, mediaImage: ByteArray) { checkSession() if (!isInitialized) return - val message = getEpisodeMessage(episodeDto, configCacheService.getValueAsString(ConfigPropertyKey.BSKY_MESSAGE) ?: "") + val message = + getEpisodeMessage(episodeDto, configCacheService.getValueAsString(ConfigPropertyKey.BSKY_MESSAGE) ?: "") val webpByteArray = FileManager.encodeToWebP(mediaImage) - val imageJson = runBlocking { BskyWrapper.uploadBlob(accessJwt!!, ContentType.parse("image/webp"), webpByteArray) } + val imageJson = + runBlocking { BskyWrapper.uploadBlob(accessJwt!!, ContentType.parse("image/webp"), webpByteArray) } runBlocking { BskyWrapper.createRecord( accessJwt!!, @@ -83,7 +90,8 @@ class BskySocialNetwork : AbstractSocialNetwork() { checkSession() if (!isInitialized) return val webpByteArray = FileManager.encodeToWebP(calendarImage) - val imageJson = runBlocking { BskyWrapper.uploadBlob(accessJwt!!, ContentType.parse("image/webp"), webpByteArray) } + val imageJson = + runBlocking { BskyWrapper.uploadBlob(accessJwt!!, ContentType.parse("image/webp"), webpByteArray) } runBlocking { BskyWrapper.createRecord( accessJwt!!, diff --git a/src/main/kotlin/fr/shikkanime/socialnetworks/ThreadsSocialNetwork.kt b/src/main/kotlin/fr/shikkanime/socialnetworks/ThreadsSocialNetwork.kt index 776be512..f3ba244b 100644 --- a/src/main/kotlin/fr/shikkanime/socialnetworks/ThreadsSocialNetwork.kt +++ b/src/main/kotlin/fr/shikkanime/socialnetworks/ThreadsSocialNetwork.kt @@ -55,7 +55,9 @@ class ThreadsSocialNetwork : AbstractSocialNetwork() { private fun checkSession() { if (isInitialized && initializedAt != null && - initializedAt!!.plusMinutes(configCacheService.getValueAsInt(ConfigPropertyKey.THREADS_SESSION_TIMEOUT, 10).toLong()).isAfter(ZonedDateTime.now()) + initializedAt!!.plusMinutes( + configCacheService.getValueAsInt(ConfigPropertyKey.THREADS_SESSION_TIMEOUT, 10).toLong() + ).isAfter(ZonedDateTime.now()) ) { return } @@ -73,6 +75,7 @@ class ThreadsSocialNetwork : AbstractSocialNetwork() { override fun platformAccount(platform: PlatformDto): String { return when (platform.id) { "CRUN" -> "@crunchyroll_fr" + "DISN" -> "@disneyplus" "NETF" -> "@netflixfr" "PRIM" -> "@primevideofr" else -> platform.name @@ -82,7 +85,8 @@ class ThreadsSocialNetwork : AbstractSocialNetwork() { override fun sendEpisodeRelease(episodeDto: EpisodeDto, mediaImage: ByteArray) { checkSession() if (!isInitialized) return - val message = getEpisodeMessage(episodeDto, configCacheService.getValueAsString(ConfigPropertyKey.THREADS_MESSAGE) ?: "") + val message = + getEpisodeMessage(episodeDto, configCacheService.getValueAsString(ConfigPropertyKey.THREADS_MESSAGE) ?: "") runBlocking { threadsWrapper.publish(username!!, deviceId!!, userId!!, token!!, message, mediaImage) } } diff --git a/src/main/kotlin/fr/shikkanime/socialnetworks/TwitterSocialNetwork.kt b/src/main/kotlin/fr/shikkanime/socialnetworks/TwitterSocialNetwork.kt index eeb56fa3..699ced24 100644 --- a/src/main/kotlin/fr/shikkanime/socialnetworks/TwitterSocialNetwork.kt +++ b/src/main/kotlin/fr/shikkanime/socialnetworks/TwitterSocialNetwork.kt @@ -85,7 +85,8 @@ class TwitterSocialNetwork : AbstractSocialNetwork() { login() if (!isInitialized) return if (twitter == null) return - val message = getEpisodeMessage(episodeDto, configCacheService.getValueAsString(ConfigPropertyKey.TWITTER_MESSAGE) ?: "") + val message = + getEpisodeMessage(episodeDto, configCacheService.getValueAsString(ConfigPropertyKey.TWITTER_MESSAGE) ?: "") val uploadMedia = twitter!!.tweets().uploadMedia( UUID.randomUUID().toString(), diff --git a/src/main/resources/templates/site/anime.ftl b/src/main/resources/templates/site/anime.ftl index a17e1a68..e1bc180b 100644 --- a/src/main/resources/templates/site/anime.ftl +++ b/src/main/resources/templates/site/anime.ftl @@ -1,5 +1,6 @@ <#import "_navigation.ftl" as navigation /> <#import "components/episode.ftl" as episodeComponent /> +<#import "components/langType.ftl" as langTypeComponent /> <#assign canonicalUrl = ""> @@ -16,6 +17,14 @@

${anime.shortName?upper_case}

+
+ <#list anime.langTypes as langType> +

+ <@langTypeComponent.display langType=langType /> +

+ +
+ <#if (anime.simulcasts?size > 0)>
<#list anime.simulcasts as simulcast> diff --git a/src/main/resources/templates/site/calendar.ftl b/src/main/resources/templates/site/calendar.ftl index b53ef1ad..aa16a963 100644 --- a/src/main/resources/templates/site/calendar.ftl +++ b/src/main/resources/templates/site/calendar.ftl @@ -1,4 +1,5 @@ <#import "_navigation.ftl" as navigation /> +<#import "components/langType.ftl" as langTypeComponent /> <#assign canonicalUrl = "" /> @@ -49,7 +50,7 @@
${release.anime.shortName} -

<#if release.langType == 'SUBTITLES'>Sous-titrage<#else>Doublage

+

<@langTypeComponent.display langType=release.langType />

diff --git a/src/main/resources/templates/site/components/anime.ftl b/src/main/resources/templates/site/components/anime.ftl index 6d788441..ba11c37a 100644 --- a/src/main/resources/templates/site/components/anime.ftl +++ b/src/main/resources/templates/site/components/anime.ftl @@ -1,3 +1,5 @@ +<#import "langType.ftl" as langTypeComponent /> + <#macro display anime>
@@ -9,7 +11,19 @@ width="480" height="720"> - ${anime.shortName} +
+ ${anime.shortName} + +

+ <#list anime.langTypes as langType> + <@langTypeComponent.display langType=langType /> + + <#if langType_has_next> + & + + +

+
diff --git a/src/main/resources/templates/site/components/episode.ftl b/src/main/resources/templates/site/components/episode.ftl index a03dbf6a..fb785443 100644 --- a/src/main/resources/templates/site/components/episode.ftl +++ b/src/main/resources/templates/site/components/episode.ftl @@ -1,3 +1,5 @@ +<#import "langType.ftl" as langTypeComponent /> + <#function getPrefixEpisode(episodeType)> <#switch episodeType> <#case "EPISODE"> @@ -34,7 +36,7 @@ ${getPrefixEpisode(episode.episodeType)} ${episode.number?c}<#if episode.uncensored> non censuré

-

<#if episode.langType == 'SUBTITLES'>Sous-titrage<#else>Doublage

+

<@langTypeComponent.display langType=episode.langType />

@@ -47,7 +49,7 @@ ${getPrefixEpisode(episode.episodeType)} ${episode.number?c}<#if episode.uncensored> non censuré

-

<#if episode.langType == 'SUBTITLES'>Sous-titrage<#else>Doublage

+

<@langTypeComponent.display langType=episode.langType />

diff --git a/src/main/resources/templates/site/components/langType.ftl b/src/main/resources/templates/site/components/langType.ftl new file mode 100644 index 00000000..adf83a68 --- /dev/null +++ b/src/main/resources/templates/site/components/langType.ftl @@ -0,0 +1,16 @@ +<#macro display langType> + <#if langType == 'SUBTITLES'> + + + + Sous-titrage + <#else> + + + + + Doublage + + \ No newline at end of file