Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class EpubMetadataProviderTest {
Author("The Editor", "editor"),
)
assertThat(isbn).isEqualTo("9783440077894")
assertThat(number).isEqualTo("1.5")
assertThat(numberSort).isEqualTo(1.5f)
}
}

Expand All @@ -74,6 +76,8 @@ class EpubMetadataProviderTest {
Author("Stefanie Wegner", "writer"),
)
assertThat(isbn).isEqualTo("9783440077931")
assertThat(number).isEqualTo("3")
assertThat(numberSort).isEqualTo(3f)
}
}

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

Expand All @@ -114,6 +120,8 @@ class EpubMetadataProviderTest {
Author("The Editor", "editor"),
)
assertThat(isbn).isNull()
assertThat(number).isNull()
assertThat(numberSort).isNull()
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion komga/src/test/resources/epub/Panik im Paradies.opf
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down