chore: Prepare ComicInfo

This commit is contained in:
Ahmad Ansori Palembani 2024-05-29 07:59:12 +07:00
parent fb6c463cf2
commit 66ac6201e5
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6
5 changed files with 156 additions and 12 deletions

View file

@ -213,9 +213,7 @@ dependencies {
implementation(kotlin("reflect", version = kotlinx.versions.kotlin.get()))
// JSON
implementation(kotlinx.serialization.json)
implementation(kotlinx.serialization.protobuf)
implementation(kotlinx.serialization.json.okio)
implementation(kotlinx.bundles.serialization)
// JavaScript engine
implementation(libs.quickjs.android)

View file

@ -89,6 +89,9 @@
-keepclassmembers class kotlinx.serialization.** {
<methods>;
}
# XmlUtil
-keep public enum nl.adaptivity.xmlutil.EventType { *; }
##---------------End: proguard configuration for kotlinx.serialization ----------
# Apache Commons Compress

View file

@ -0,0 +1,134 @@
package dev.yokai.core.metadata
import eu.kanade.tachiyomi.source.model.SManga
import kotlinx.serialization.Serializable
import nl.adaptivity.xmlutil.serialization.XmlElement
import nl.adaptivity.xmlutil.serialization.XmlSerialName
import nl.adaptivity.xmlutil.serialization.XmlValue
// REF: https://anansi-project.github.io/docs/comicinfo/schemas/v2.0
@Serializable
@XmlSerialName("ComicInfo", "", "")
data class ComicInfo(
val title: Title?,
val series: Series?,
val number: Number?,
val summary: Summary?,
val writer: Writer?,
val penciller: Penciller?,
val inker: Inker?,
val colorist: Colorist?,
val letterer: Letterer?,
val coverArtist: CoverArtist?,
val translator: Translator?,
val genre: Genre?,
val tags: Tags?,
val web: Web?,
val publishingStatus: PublishingStatusTachiyomi?,
val categories: CategoriesTachiyomi?,
val source: SourceMihon?,
) {
@XmlElement(false)
@XmlSerialName("xmlns:xsd", "", "")
val xmlSchema: String = "http://www.w3.org/2001/XMLSchema"
@XmlElement(false)
@XmlSerialName("xmlns:xsi", "", "")
val xmlSchemaInstance: String = "http://www.w3.org/2001/XMLSchema-instance"
@Serializable
@XmlSerialName("Title", "", "")
data class Title(@XmlValue(true) val value: String = "")
@Serializable
@XmlSerialName("Series", "", "")
data class Series(val value: String = "")
@Serializable
@XmlSerialName("Number", "", "")
data class Number(@XmlValue(true) val value: String = "")
@Serializable
@XmlSerialName("Summary", "", "")
data class Summary(val value: String = "")
@Serializable
@XmlSerialName("Writer", "", "")
data class Writer(val value: String = "")
@Serializable
@XmlSerialName("Penciller", "", "")
data class Penciller(val value: String = "")
@Serializable
@XmlSerialName("Inker", "", "")
data class Inker(val value: String = "")
@Serializable
@XmlSerialName("Colorist", "", "")
data class Colorist(val value: String = "")
@Serializable
@XmlSerialName("Letterer", "", "")
data class Letterer(val value: String = "")
@Serializable
@XmlSerialName("CoverArtist", "", "")
data class CoverArtist(val value: String = "")
@Serializable
@XmlSerialName("Translator", "", "")
data class Translator(val value: String = "")
@Serializable
@XmlSerialName("Genre", "", "")
data class Genre(val value: String = "")
@Serializable
@XmlSerialName("Tags", "", "")
data class Tags(val value: String = "")
@Serializable
@XmlSerialName("Web", "", "")
data class Web(val value: String = "")
// Tachi Note: The spec doesn't have a good field for this
// REF: https://github.com/anansi-project/comicinfo/issues/5
@Serializable
@XmlSerialName("PublishingStatusTachiyomi", "http://www.w3.org/2001/XMLSchema", "ty")
data class PublishingStatusTachiyomi(val value: String = "")
@Serializable
@XmlSerialName("Categories", "http://www.w3.org/2001/XMLSchema", "ty")
data class CategoriesTachiyomi(val value: String = "")
@Serializable
@XmlSerialName("SourceMihon", "http://www.w3.org/2001/XMLSchema", "mh")
data class SourceMihon(val value: String = "")
}
enum class ComicInfoPublishingStatus(
val comicInfoValue: String,
val sMangaModelValue: Int,
) {
ONGOING("Ongoing", SManga.ONGOING),
COMPLETED("Completed", SManga.COMPLETED),
LICENSED("Licensed", SManga.LICENSED),
PUBLISHING_FINISHED("Publishing finished", SManga.PUBLISHING_FINISHED),
CANCELLED("Cancelled", SManga.CANCELLED),
ON_HIATUS("On hiatus", SManga.ON_HIATUS),
UNKNOWN("Unknown", SManga.UNKNOWN),
;
companion object {
fun toComicInfoValue(value: Long): String {
return entries.firstOrNull { it.sMangaModelValue == value.toInt() }?.comicInfoValue
?: UNKNOWN.comicInfoValue
}
fun toSMangaValue(value: String?): Int {
return entries.firstOrNull { it.comicInfoValue == value }?.sMangaModelValue
?: UNKNOWN.sMangaModelValue
}
}
}

View file

@ -2,15 +2,24 @@
kotlin = "1.9.24"
coroutines = "1.8.0"
serialization = "1.6.2"
xml_serialization = "0.86.3"
[libraries]
coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" }
coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
serialization-gradle = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin" }
serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serialization" }
serialization-json-okio = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json-okio", version.ref = "serialization" }
serialization-protobuf = { module = "org.jetbrains.kotlinx:kotlinx-serialization-protobuf", version.ref = "serialization" }
coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" }
coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
serialization-xml-core = { module = "io.github.pdvrieze.xmlutil:core-android", version.ref = "xml_serialization" }
serialization-xml = { module = "io.github.pdvrieze.xmlutil:serialization-android", version.ref = "xml_serialization" }
[bundles]
serialization = [
"serialization-gradle", "serialization-json", "serialization-json-okio", "serialization-protobuf",
"serialization-xml", "serialization-xml-core"
]
[plugins]
android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }

View file

@ -25,6 +25,9 @@ directionalviewpager = { module = "com.github.tachiyomiorg:DirectionalViewPager"
disklrucache = { module = "com.jakewharton:disklrucache", version = "2.0.2" }
fastadapter-extensions-binding = { module = "com.mikepenz:fastadapter-extensions-binding", version.ref = "fast_adapter" }
fastadapter = { module = "com.mikepenz:fastadapter", version.ref = "fast_adapter" }
firebase = { module = "com.google.firebase:firebase-bom", version = "33.0.0" }
firebase-analytics = { module = "com.google.firebase:firebase-analytics-ktx" }
firebase-crashlytics = { module = "com.google.firebase:firebase-crashlytics-ktx" }
firebase-crashlytics-gradle = { module = "com.google.firebase:firebase-crashlytics-gradle", version = "3.0.1" }
flexbox = { module = "com.google.android.flexbox:flexbox", version = "3.0.0" }
flexible-adapter-ui = { module = "com.github.arkon.FlexibleAdapter:flexible-adapter-ui", version.ref = "flexible-adapter" }
@ -43,8 +46,12 @@ nucleus = { module = "info.android15.nucleus:nucleus", version.ref = "nucleus" }
java-nat-sort = { module = "com.github.gpanther:java-nat-sort", version = "natural-comparator-1.1" }
java-string-similarity = { module = "info.debatty:java-string-similarity", version = "2.0.0" }
jsoup = { module = "org.jsoup:jsoup", version = "1.16.1" }
junit-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit" }
junit-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit" }
junit-android = { module = "androidx.test.ext:junit", version = "1.1.5" }
junrar = { module = "com.github.junrar:junrar", version = "7.5.5" }
loading-button = { module = "br.com.simplepass:loading-button-android", version = "2.2.0" }
mockk = { module = "io.mockk:mockk", version = "1.13.11" }
okio = { module = "com.squareup.okio:okio", version = "3.8.0" }
okhttp-brotli = { module = "com.squareup.okhttp3:okhttp-brotli", version.ref = "okhttp" }
okhttp-dnsoverhttps = { module = "com.squareup.okhttp3:okhttp-dnsoverhttps", version.ref = "okhttp" }
@ -65,16 +72,9 @@ shizuku-provider = { module = "dev.rikka.shizuku:provider", version.ref = "shizu
taptargetview = { module = "com.getkeepsafe.taptargetview:taptargetview", version = "1.13.3" }
timber = { module = "com.jakewharton.timber:timber", version = "4.7.1" }
oss-licenses-plugin = { module = "com.google.android.gms:oss-licenses-plugin", version = "0.10.6" }
firebase = { module = "com.google.firebase:firebase-bom", version = "33.0.0" }
firebase-analytics = { module = "com.google.firebase:firebase-analytics-ktx" }
firebase-crashlytics = { module = "com.google.firebase:firebase-crashlytics-ktx" }
unifile = { module = "com.github.tachiyomiorg:unifile", version = "7c257e1c64" }
viewstatepageradapter = { module = "com.nightlynexus.viewstatepageradapter:viewstatepageradapter", version = "1.1.0" }
viewtooltip = { module = "com.github.florent37:viewtooltip", version = "1.2.2" }
junit-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit" }
junit-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit" }
junit-android = { module = "androidx.test.ext:junit", version = "1.1.5" }
mockk = { module = "io.mockk:mockk", version = "1.13.11" }
[plugins]
kotlinter = { id = "org.jmailen.kotlinter", version = "4.1.1" }