mirror of
https://github.com/gotson/komga.git
synced 2026-05-08 12:35:30 +02:00
parent
b7fe4bde74
commit
30bf7f469f
1 changed files with 11 additions and 7 deletions
|
|
@ -36,7 +36,6 @@ class EpubMetadataProvider(
|
||||||
val description = opf.selectFirst("metadata > dc|description")?.text()
|
val description = opf.selectFirst("metadata > dc|description")?.text()
|
||||||
val date = opf.selectFirst("metadata > dc|date")?.text()?.let { parseDate(it) }
|
val date = opf.selectFirst("metadata > dc|date")?.text()?.let { parseDate(it) }
|
||||||
|
|
||||||
|
|
||||||
val direction = opf.getElementsByTag("spine").first().attr("page-progression-direction")?.let {
|
val direction = opf.getElementsByTag("spine").first().attr("page-progression-direction")?.let {
|
||||||
when (it) {
|
when (it) {
|
||||||
"rtl" -> BookMetadata.ReadingDirection.RIGHT_TO_LEFT
|
"rtl" -> BookMetadata.ReadingDirection.RIGHT_TO_LEFT
|
||||||
|
|
@ -45,14 +44,17 @@ class EpubMetadataProvider(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val creators = opf.select("metadata > dc|creator")
|
|
||||||
.associate { it.attr("id") to it.text() }
|
|
||||||
val creatorRefines = opf.select("metadata > meta[property=role][scheme=marc:relators]")
|
val creatorRefines = opf.select("metadata > meta[property=role][scheme=marc:relators]")
|
||||||
.associate { it.attr("refines").removePrefix("#") to it.text() }
|
.associate { it.attr("refines").removePrefix("#") to it.text() }
|
||||||
val authors = creators.map { (id, name) ->
|
val authors = opf.select("metadata > dc|creator")
|
||||||
val role = relators[creatorRefines[id]] ?: "writer"
|
.map {
|
||||||
Author(name, role)
|
val name = it.text()
|
||||||
}
|
val opfRole = it.attr("opf|role").orNull()
|
||||||
|
val id = it.attr("id").orNull()
|
||||||
|
val refineRole = creatorRefines[id]
|
||||||
|
val role = opfRole ?: refineRole
|
||||||
|
Author(name, relators[role] ?: "writer")
|
||||||
|
}
|
||||||
|
|
||||||
val series = opf.selectFirst("metadata > meta[property=belongs-to-collection]")?.text()
|
val series = opf.selectFirst("metadata > meta[property=belongs-to-collection]")?.text()
|
||||||
|
|
||||||
|
|
@ -72,6 +74,8 @@ class EpubMetadataProvider(
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun String.orNull() = if (isBlank()) null else this
|
||||||
|
|
||||||
private fun parseDate(date: String): LocalDate? =
|
private fun parseDate(date: String): LocalDate? =
|
||||||
try {
|
try {
|
||||||
LocalDate.parse(date, DateTimeFormatter.ISO_DATE)
|
LocalDate.parse(date, DateTimeFormatter.ISO_DATE)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue