-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
594 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package fr.shikkanime.entities | ||
|
||
import jakarta.persistence.* | ||
import java.time.ZonedDateTime | ||
import java.util.* | ||
|
||
@Entity | ||
@Table(name = "anime") | ||
data class Anime( | ||
override val uuid: UUID? = null, | ||
@ManyToOne(optional = false, fetch = FetchType.LAZY) | ||
val country: Country? = null, | ||
@Column(nullable = false) | ||
val name: String? = null, | ||
@Column(nullable = false, name = "release_date") | ||
val releaseDate: ZonedDateTime = ZonedDateTime.now(), | ||
@Column(nullable = false) | ||
var image: String? = null, | ||
@Column(nullable = true, columnDefinition = "TEXT") | ||
var description: String? = null, | ||
) : ShikkEntity(uuid) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package fr.shikkanime.entities | ||
|
||
import fr.shikkanime.entities.enums.EpisodeType | ||
import fr.shikkanime.entities.enums.LangType | ||
import jakarta.persistence.* | ||
import java.time.ZonedDateTime | ||
import java.util.* | ||
|
||
@Entity | ||
@Table(name = "episode") | ||
data class Episode( | ||
override val uuid: UUID? = null, | ||
@ManyToOne(optional = false, fetch = FetchType.LAZY) | ||
var platform: Platform? = null, | ||
@ManyToOne(optional = false, fetch = FetchType.LAZY) | ||
var anime: Anime? = null, | ||
@Column(nullable = false, name = "episode_type") | ||
@Enumerated(EnumType.STRING) | ||
val episodeType: EpisodeType? = null, | ||
@Column(nullable = false, name = "lang_type") | ||
@Enumerated(EnumType.STRING) | ||
val langType: LangType? = null, | ||
@Column(nullable = false) | ||
val hash: String? = null, | ||
@Column(nullable = false, name = "release_date") | ||
val releaseDate: ZonedDateTime = ZonedDateTime.now(), | ||
@Column(nullable = false) | ||
var season: Int? = null, | ||
@Column(nullable = false) | ||
var number: Int? = null, | ||
@Column(nullable = true, columnDefinition = "TEXT") | ||
var title: String? = null, | ||
@Column(nullable = false, columnDefinition = "TEXT") | ||
var url: String? = null, | ||
@Column(nullable = false, columnDefinition = "TEXT") | ||
var image: String? = null, | ||
@Column(nullable = false) | ||
var duration: Long = -1 | ||
) : ShikkEntity(uuid) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package fr.shikkanime.entities.enums | ||
|
||
enum class EpisodeType { | ||
EPISODE, | ||
SPECIAL, | ||
FILM, | ||
; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package fr.shikkanime.entities.enums | ||
|
||
enum class LangType { | ||
SUBTITLES, | ||
VOICE, | ||
; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,30 @@ | ||
package fr.shikkanime.jobs | ||
|
||
import fr.shikkanime.entities.Episode | ||
import fr.shikkanime.services.EpisodeService | ||
import fr.shikkanime.utils.Constant | ||
import jakarta.inject.Inject | ||
import java.time.ZonedDateTime | ||
|
||
class FetchEpisodesJob : AbstractJob() { | ||
@Inject | ||
private lateinit var episodeService: EpisodeService | ||
|
||
override fun run() { | ||
val zonedDateTime = ZonedDateTime.now().withNano(0) | ||
val episodes = mutableListOf<Episode>() | ||
|
||
Constant.abstractPlatforms.forEach { abstractPlatform -> | ||
println("Fetching episodes for ${abstractPlatform.getPlatform().name}...") | ||
|
||
try { | ||
abstractPlatform.fetchEpisodes(zonedDateTime) | ||
episodes.addAll(abstractPlatform.fetchEpisodes(zonedDateTime)) | ||
} catch (e: Exception) { | ||
println("Error while fetching episodes for ${abstractPlatform.getPlatform().name}: ${e.message}") | ||
e.printStackTrace() | ||
} | ||
} | ||
|
||
episodes.forEach { episodeService.saveOrUpdate(it) } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.