You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
2.1 KiB
Kotlin
90 lines
2.1 KiB
Kotlin
package moe.odango.index.entity
|
|
|
|
import io.requery.*
|
|
import moe.odango.index.scraper.mal.AnimePageScraper
|
|
import moe.odango.index.utils.EntityHelper
|
|
import moe.odango.index.utils.ISOTextConverter
|
|
import moe.odango.index.utils.helper
|
|
import moe.odango.index.utils.toIntDate
|
|
import org.joda.time.DateTime
|
|
import java.sql.Date
|
|
import java.util.*
|
|
|
|
@Entity
|
|
interface MyAnimeListInfo : Persistable {
|
|
@get:Key
|
|
val id: UUID
|
|
|
|
@get:OneToOne
|
|
@get:ForeignKey
|
|
val anime: Anime
|
|
|
|
var releaseType: ReleaseType
|
|
var episodes: Int?
|
|
|
|
@get:Convert(ISOTextConverter::class)
|
|
var lastScrape: DateTime?
|
|
var rating: Rating?
|
|
var image: String?
|
|
var description: String?
|
|
var source: String?
|
|
var airedStart: Date?
|
|
var airedEnd: Date?
|
|
var premieredSeason: String?
|
|
var premieredYear: Int?
|
|
var duration: Int?
|
|
|
|
|
|
@get:Transient
|
|
val aired: AnimePageScraper.Aired?
|
|
get() = airedStart?.let { AnimePageScraper.Aired(it.toIntDate(), airedEnd?.toIntDate()) }
|
|
|
|
@get:Transient
|
|
val premiered: AnimePageScraper.Premiered?
|
|
get() = premieredSeason
|
|
?.let(AnimePageScraper.Premiered.Season.Companion::fromString)
|
|
?.let { s ->
|
|
premieredYear?.let { y ->
|
|
AnimePageScraper.Premiered(s, y)
|
|
}
|
|
}
|
|
|
|
enum class Rating {
|
|
G,
|
|
PG,
|
|
PG13,
|
|
R,
|
|
RPlus,
|
|
Rx;
|
|
|
|
companion object {
|
|
fun fromString(rating: String): Rating? = when (rating) {
|
|
"G" -> G
|
|
"PG" -> PG
|
|
"PG-13" -> PG13
|
|
"R" -> R
|
|
"R+" -> RPlus
|
|
"Rx" -> Rx
|
|
else -> null
|
|
}
|
|
}
|
|
}
|
|
|
|
enum class ReleaseType {
|
|
TV,
|
|
ONA,
|
|
OVA,
|
|
Movie,
|
|
Special,
|
|
Music,
|
|
Unknown
|
|
}
|
|
|
|
companion object : EntityHelper<MyAnimeListInfoEntity> by helper(::MyAnimeListInfoEntity, {
|
|
setId(UUID.randomUUID())
|
|
episodes = null
|
|
releaseType = ReleaseType.Unknown
|
|
lastScrape = null
|
|
})
|
|
}
|