Skip to content

Commit

Permalink
Refactor social network episode release to use parallel streams
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziedelth committed Mar 8, 2024
1 parent a0f0bf7 commit 1bea6f3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
32 changes: 15 additions & 17 deletions src/main/kotlin/fr/shikkanime/jobs/FetchEpisodesJob.kt
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,21 @@ class FetchEpisodesJob : AbstractJob {
return
}

Constant.abstractSocialNetworks.forEach { socialNetwork ->
Thread {
try {
socialNetwork.sendEpisodeRelease(dto, mediaImage)
} catch (e: Exception) {
logger.log(
Level.SEVERE,
"Error while sending episode release for ${
socialNetwork.javaClass.simpleName.replace(
"SocialNetwork",
""
)
}",
e
)
}
}.start()
Constant.abstractSocialNetworks.parallelStream().forEach { socialNetwork ->
try {
socialNetwork.sendEpisodeRelease(dto, mediaImage)
} catch (e: Exception) {
logger.log(
Level.SEVERE,
"Error while sending episode release for ${
socialNetwork.javaClass.simpleName.replace(
"SocialNetwork",
""
)
}",
e
)
}
}
}
}
4 changes: 3 additions & 1 deletion src/main/kotlin/fr/shikkanime/services/ImageService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,9 @@ object ImageService {
ImageIO.read(URI(episode.anime.image!!).toURL()).resize((480 / scale).toInt(), (720 / scale).toInt())

val platformImage = try {
ImageIO.read(URI("http://localhost:37100/assets/img/platforms/${episode.platform.image}").toURL())
ImageIO.read(
ClassLoader.getSystemClassLoader().getResourceAsStream("assets/img/platforms/${episode.platform.image}")
)
.resize(32, 32)
} catch (e: Exception) {
e.printStackTrace()
Expand Down

0 comments on commit 1bea6f3

Please sign in to comment.