Skip to content

Commit

Permalink
Merge pull request #280 from Shikkanime/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Ziedelth authored Mar 12, 2024
2 parents d3f1801 + 7b39717 commit d27402c
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 70 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/playwright:v1.41.2-jammy
FROM mcr.microsoft.com/playwright:v1.42.1-jammy
ARG version=21.0.2.13-1
ENV LANG C.UTF-8
ENV JAVA_HOME /usr/lib/jvm/java-21-amazon-corretto
Expand Down
10 changes: 3 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import java.net.URI

val ktorVersion = "2.3.9"
val ktorSwaggerUiVersion = "2.7.4"
val hibernateCoreVersion = "6.4.4.Final"
Expand All @@ -14,13 +12,13 @@ val liquibaseCoreVersion = "4.26.0"
val quartzVersion = "2.5.0-rc1"
val guavaVersion = "33.0.0-jre"
val jacksonVersion = "2.16.2"
val playwrightVersion = "1.41.2"
val playwrightVersion = "1.42.0"
val jsoupVersion = "1.17.2"
val gsonVersion = "2.10.1"
val openCvVersion = "4.9.0-0"
val bcprovVersion = "1.77"
val javaImageScalingVersion = "0.8.6"
val jdaVersion = "5.0.0-beta.20"
val jdaVersion = "5.0.0-beta.21"
val twitter4jVersion = "4.0.7"
val twitter4jV2Version = "1.4.3"

Expand All @@ -46,8 +44,6 @@ application {

repositories {
mavenCentral()
maven { url = URI("https://jitpack.io") }
maven { url = uri("https://repo.repsy.io/mvn/uakihir0/public") }
}

dependencies {
Expand Down Expand Up @@ -94,7 +90,7 @@ dependencies {
implementation("org.apache.tika:tika-langdetect-optimaize:$tikaVersion")

// Social networks
implementation("com.github.discord-jda:JDA:$jdaVersion")
implementation("net.dv8tion:JDA:$jdaVersion")
implementation("org.twitter4j:twitter4j-core:$twitter4jVersion")
implementation("io.github.takke:jp.takke.twitter4j-v2:$twitter4jV2Version")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.google.inject.Inject
import fr.shikkanime.converters.AbstractConverter
import fr.shikkanime.dtos.AnimeDto
import fr.shikkanime.dtos.EpisodeDto
import fr.shikkanime.dtos.PlatformDto
import fr.shikkanime.dtos.enums.Status
import fr.shikkanime.entities.Episode
import fr.shikkanime.services.caches.LanguageCacheService
Expand All @@ -25,7 +26,7 @@ class EpisodeToEpisodeDtoConverter : AbstractConverter<Episode, EpisodeDto>() {

return EpisodeDto(
uuid = from.uuid,
platform = from.platform!!,
platform = convert(from.platform!!, PlatformDto::class.java),
anime = convert(from.anime, AnimeDto::class.java),
episodeType = from.episodeType!!,
langType = from.langType!!,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package fr.shikkanime.converters.platform

import fr.shikkanime.converters.AbstractConverter
import fr.shikkanime.dtos.PlatformDto
import fr.shikkanime.entities.enums.Platform

class PlatformToPlatformDtoConverter : AbstractConverter<Platform, PlatformDto>() {
override fun convert(from: Platform): PlatformDto {
return PlatformDto(
id = from.name,
name = from.platformName,
url = from.url,
image = from.image
)
}
}
3 changes: 1 addition & 2 deletions src/main/kotlin/fr/shikkanime/dtos/EpisodeDto.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ package fr.shikkanime.dtos
import fr.shikkanime.dtos.enums.Status
import fr.shikkanime.entities.enums.EpisodeType
import fr.shikkanime.entities.enums.LangType
import fr.shikkanime.entities.enums.Platform
import java.util.*

data class EpisodeDto(
val uuid: UUID?,
val platform: Platform,
val platform: PlatformDto,
var anime: AnimeDto,
val episodeType: EpisodeType,
val langType: LangType,
Expand Down
8 changes: 8 additions & 0 deletions src/main/kotlin/fr/shikkanime/dtos/PlatformDto.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package fr.shikkanime.dtos

data class PlatformDto(
val id: String,
val name: String,
val url: String,
val image: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package fr.shikkanime.socialnetworks

import com.google.inject.Inject
import fr.shikkanime.dtos.EpisodeDto
import fr.shikkanime.dtos.PlatformDto
import fr.shikkanime.entities.enums.EpisodeType
import fr.shikkanime.entities.enums.LangType
import fr.shikkanime.entities.enums.Platform
import fr.shikkanime.services.caches.ConfigCacheService
import fr.shikkanime.utils.Constant
import fr.shikkanime.utils.StringUtils
Expand All @@ -18,8 +18,8 @@ abstract class AbstractSocialNetwork {

abstract fun sendMessage(message: String)

open fun platformAccount(platform: Platform): String {
return platform.platformName
open fun platformAccount(platform: PlatformDto): String {
return platform.name
}

private fun information(episodeDto: EpisodeDto): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class DiscordSocialNetwork : AbstractSocialNetwork() {
val image = ImageIO.read(URI(episodeDto.image).toURL())
embedMessage.setColor(ImageService.getDominantColor(image))
embedMessage.setAuthor(
episodeDto.platform.platformName,
episodeDto.platform.name,
episodeDto.platform.url,
"${Constant.BASE_URL}/assets/img/platforms/${episodeDto.platform.image}"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package fr.shikkanime.socialnetworks

import fr.shikkanime.dtos.EpisodeDto
import fr.shikkanime.dtos.PlatformDto
import fr.shikkanime.entities.enums.ConfigPropertyKey
import fr.shikkanime.entities.enums.Platform
import fr.shikkanime.utils.LoggerFactory
import fr.shikkanime.wrappers.ThreadsWrapper
import kotlinx.coroutines.runBlocking
Expand Down Expand Up @@ -67,12 +67,12 @@ class ThreadsSocialNetwork : AbstractSocialNetwork() {
runBlocking { threadsWrapper.publish(username!!, deviceId!!, userId!!, token!!, message) }
}

override fun platformAccount(platform: Platform): String {
return when (platform) {
Platform.CRUN -> "@crunchyroll_fr"
Platform.NETF -> "@netflixfr"
Platform.PRIM -> "@primevideofr"
else -> platform.platformName
override fun platformAccount(platform: PlatformDto): String {
return when (platform.id) {
"CRUN" -> "@crunchyroll_fr"
"NETF" -> "@netflixfr"
"PRIM" -> "@primevideofr"
else -> platform.name
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package fr.shikkanime.socialnetworks

import fr.shikkanime.dtos.EpisodeDto
import fr.shikkanime.dtos.PlatformDto
import fr.shikkanime.entities.enums.ConfigPropertyKey
import fr.shikkanime.entities.enums.Platform
import fr.shikkanime.utils.LoggerFactory
import twitter4j.Twitter
import twitter4j.TwitterFactory
Expand Down Expand Up @@ -68,13 +68,14 @@ class TwitterSocialNetwork : AbstractSocialNetwork() {
twitter!!.v2.createTweet(text = message)
}

override fun platformAccount(platform: Platform): String {
return when (platform) {
Platform.ANIM -> "@ADNanime"
Platform.CRUN -> "@Crunchyroll_fr"
Platform.NETF -> "@NetflixFR"
Platform.DISN -> "@DisneyPlusFR"
Platform.PRIM -> "@PrimeVideoFR"
override fun platformAccount(platform: PlatformDto): String {
return when (platform.id) {
"ANIM" -> "@ADNanime"
"CRUN" -> "@Crunchyroll_fr"
"NETF" -> "@NetflixFR"
"DISN" -> "@DisneyPlusFR"
"PRIM" -> "@PrimeVideoFR"
else -> platform.name
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/admin/episodes/list.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
return `<tr>
<th scope="row"><span class="me-2 badge bg-` + (isInvalid ? 'danger' : 'success') + `">` + (isInvalid ? 'Invalid' : 'Valid') + `</span>` + anime + `</th>
<td>` + platform + `</td>
<td>` + platform.name + `</td>
<td>` + details + `</td>
<td>` + description + `</td>
<td>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/site/components/episode.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
class="img-fluid<#if episode.uncensored> blur</#if>" width="640" height="360">

<img src="https://www.shikkanime.fr/assets/img/platforms/${episode.platform.image}"
alt="${episode.platform.name()} platform image"
alt="${episode.platform.name} platform image"
class="position-absolute top-0 end-0 rounded-circle me-1 mt-1" width="24"
height="24">
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package fr.shikkanime.controllers.admin

import com.google.inject.Inject
import com.microsoft.playwright.Playwright
import com.microsoft.playwright.Page
import com.microsoft.playwright.junit.UsePlaywright
import fr.shikkanime.converters.AbstractConverter
import fr.shikkanime.dtos.AnimeDto
import fr.shikkanime.entities.Anime
Expand All @@ -28,6 +29,7 @@ import java.net.ServerSocket
import java.util.*
import java.util.concurrent.atomic.AtomicReference

@UsePlaywright
class AdminControllerTest {
private var port: Int = -1
private var server: ApplicationEngine? = null
Expand Down Expand Up @@ -69,7 +71,7 @@ class AdminControllerTest {
"(Test) - C'est l'histoire de la suite de Dragon Ball Z. L'histoire se passe 10 ans après la défaite de Majin Buu."
)

val listFiles = File(ClassLoader.getSystemClassLoader().getResource("animes")?.file).listFiles()
val listFiles = ClassLoader.getSystemClassLoader().getResource("animes")?.file?.let { File(it).listFiles() }

listFiles
?.sortedBy { it.name.lowercase() }
Expand Down Expand Up @@ -114,10 +116,7 @@ class AdminControllerTest {
}

@Test
fun `test admin login and all links`() {
val playwright = Playwright.create()
val browser = playwright.chromium().launch()
val page = browser.newPage()
fun `test admin login and all links`(page: Page) {
page.navigate("http://localhost:$port/admin")
assertEquals("Login - Shikkanime", page.title())
page.fill("input[name=username]", "admin")
Expand All @@ -137,18 +136,10 @@ class AdminControllerTest {
println(s)
assertEquals(s, page.title())
}

page.close()
browser.close()
playwright.close()
}

@Test
fun `create netflix simulcast`() {
val playwright = Playwright.create()
val browser = playwright.chromium().launch()
val page = browser.newPage()

fun `create netflix simulcast`(page: Page) {
page.navigate("http://localhost:$port/admin")
assertEquals("Login - Shikkanime", page.title())
page.fill("input[name=username]", "admin")
Expand All @@ -166,18 +157,10 @@ class AdminControllerTest {
page.fill("input[name=season]", "2")

page.click("button[type=submit]")

page.close()
browser.close()
playwright.close()
}

@Test
fun `create prime video simulcast`() {
val playwright = Playwright.create()
val browser = playwright.chromium().launch()
val page = browser.newPage()

fun `create prime video simulcast`(page: Page) {
page.navigate("http://localhost:$port/admin")
assertEquals("Login - Shikkanime", page.title())
page.fill("input[name=username]", "admin")
Expand All @@ -194,28 +177,16 @@ class AdminControllerTest {
page.fill("input[name=releaseTime]", "17:01")

page.click("button[type=submit]")

page.close()
browser.close()
playwright.close()
}

@Test
fun `invalidate simulcasts`() {
val playwright = Playwright.create()
val browser = playwright.chromium().launch()
val page = browser.newPage()

fun `invalidate simulcasts`(page: Page) {
page.navigate("http://localhost:$port/admin")
assertEquals("Login - Shikkanime", page.title())
page.fill("input[name=username]", "admin")
page.fill("input[name=password]", password.get())
page.click("button[type=submit]")

page.click("#simulcasts-invalidate")

page.close()
browser.close()
playwright.close()
}
}
4 changes: 3 additions & 1 deletion src/test/kotlin/fr/shikkanime/services/ImageServiceTest.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package fr.shikkanime.services

import fr.shikkanime.converters.AbstractConverter
import fr.shikkanime.dtos.AnimeDto
import fr.shikkanime.dtos.EpisodeDto
import fr.shikkanime.dtos.PlatformDto
import fr.shikkanime.dtos.SimulcastDto
import fr.shikkanime.dtos.enums.Status
import fr.shikkanime.entities.enums.CountryCode
Expand Down Expand Up @@ -40,7 +42,7 @@ class ImageServiceTest {
fun toEpisodeImage() {
val dto = EpisodeDto(
uuid = UUID.fromString("0335449b-87af-489e-9513-57cb2c854738"),
platform = Platform.CRUN,
platform = AbstractConverter.convert(Platform.CRUN, PlatformDto::class.java),
anime = AnimeDto(
uuid = UUID.fromString("ebf540e4-42d2-4c35-92fc-6069b08d6db3"),
countryCode = CountryCode.FR,
Expand Down

0 comments on commit d27402c

Please sign in to comment.