feat(metadata): use group-position for epub series index

This commit is contained in:
Jens van Almsick 2024-08-29 05:46:49 +02:00 committed by GitHub
parent 85a9934ff1
commit 435458107c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 1 deletions

View File

@ -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

View File

@ -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()
}
}
}

View File

@ -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>