mirror of
https://github.com/gotson/komga.git
synced 2025-01-09 04:08:00 +08:00
feat(metadata): use group-position for epub series index
This commit is contained in:
parent
85a9934ff1
commit
435458107c
@ -77,12 +77,19 @@ class EpubMetadataProvider(
|
||||
.map { it.text().lowercase().removePrefix("isbn:") }
|
||||
.firstNotNullOfOrNull { isbnValidator.validate(it) }
|
||||
|
||||
val seriesIndex =
|
||||
opf.selectFirst("metadata > *|meta[property=belongs-to-collection]")?.attr("id")?.let { id ->
|
||||
opf.selectFirst("metadata > *|meta[refines=#$id][property=group-position]")
|
||||
}?.text()
|
||||
|
||||
return BookMetadataPatch(
|
||||
title = title,
|
||||
summary = description,
|
||||
releaseDate = date,
|
||||
authors = authors,
|
||||
isbn = isbn,
|
||||
number = seriesIndex?.ifBlank { null },
|
||||
numberSort = seriesIndex?.toFloatOrNull(),
|
||||
)
|
||||
}
|
||||
return null
|
||||
|
@ -54,6 +54,8 @@ class EpubMetadataProviderTest {
|
||||
Author("The Editor", "editor"),
|
||||
)
|
||||
assertThat(isbn).isEqualTo("9783440077894")
|
||||
assertThat(number).isEqualTo("1.5")
|
||||
assertThat(numberSort).isEqualTo(1.5f)
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,6 +76,8 @@ class EpubMetadataProviderTest {
|
||||
Author("Stefanie Wegner", "writer"),
|
||||
)
|
||||
assertThat(isbn).isEqualTo("9783440077931")
|
||||
assertThat(number).isEqualTo("3")
|
||||
assertThat(numberSort).isEqualTo(3f)
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,6 +98,8 @@ class EpubMetadataProviderTest {
|
||||
assertThat(releaseDate).isEqualTo(LocalDate.of(2021, 6, 20))
|
||||
assertThat(authors).containsExactlyInAnyOrder(Author("Ralph Burke", "writer"))
|
||||
assertThat(isbn).isNull()
|
||||
assertThat(number).isNull()
|
||||
assertThat(numberSort).isNull()
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,6 +120,8 @@ class EpubMetadataProviderTest {
|
||||
Author("The Editor", "editor"),
|
||||
)
|
||||
assertThat(isbn).isNull()
|
||||
assertThat(number).isNull()
|
||||
assertThat(numberSort).isNull()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
<opf:meta property="calibre:rating">6</opf:meta>
|
||||
<opf:meta property="belongs-to-collection" id="id-2">Die drei ??? Kids</opf:meta>
|
||||
<opf:meta refines="#id-2" property="collection-type">series</opf:meta>
|
||||
<opf:meta refines="#id-2" property="group-position">1</opf:meta>
|
||||
<opf:meta refines="#id-2" property="group-position">1.5</opf:meta>
|
||||
<opf:meta property="calibre:author_link_map">{"Ulf Blanck": ""}</opf:meta>
|
||||
</metadata>
|
||||
<manifest>
|
||||
|
Loading…
Reference in New Issue
Block a user