diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/model/BookMetadataPatch.kt b/komga/src/main/kotlin/org/gotson/komga/domain/model/BookMetadataPatch.kt index e18f1edb6..a164c5ab5 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/model/BookMetadataPatch.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/model/BookMetadataPatch.kt @@ -11,6 +11,7 @@ data class BookMetadataPatch( val authors: List? = null, val isbn: String? = null, val links: List? = null, + val tags: Set? = null, val readLists: List = emptyList(), ) { diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/service/MetadataApplier.kt b/komga/src/main/kotlin/org/gotson/komga/domain/service/MetadataApplier.kt index 6f8ed77f6..1c58b7193 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/service/MetadataApplier.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/service/MetadataApplier.kt @@ -24,6 +24,7 @@ class MetadataApplier { authors = getIfNotLocked(authors, patch.authors, authorsLock), isbn = getIfNotLocked(isbn, patch.isbn, isbnLock), links = getIfNotLocked(links, patch.links, linksLock), + tags = getIfNotLocked(tags, patch.tags, tagsLock), ) } diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/metadata/comicrack/ComicInfoProvider.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/metadata/comicrack/ComicInfoProvider.kt index bd0197682..62cb6c66e 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/metadata/comicrack/ComicInfoProvider.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/metadata/comicrack/ComicInfoProvider.kt @@ -94,6 +94,8 @@ class ComicInfoProvider( } } + val tags = comicInfo.tags?.split(',')?.mapNotNull { it.trim().lowercase().ifBlank { null } } + return BookMetadataPatch( title = comicInfo.title?.ifBlank { null }, summary = comicInfo.summary?.ifBlank { null }, @@ -103,6 +105,7 @@ class ComicInfoProvider( authors = authors.ifEmpty { null }, readLists = readLists, links = link, + tags = if (!tags.isNullOrEmpty()) tags.toSet() else null, ) } return null diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/metadata/comicrack/dto/ComicInfo.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/metadata/comicrack/dto/ComicInfo.kt index 722812378..26b60f63a 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/metadata/comicrack/dto/ComicInfo.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/metadata/comicrack/dto/ComicInfo.kt @@ -79,6 +79,9 @@ class ComicInfo { @JsonProperty(value = "Genre") var genre: String? = null + @JsonProperty(value = "Tags") + var tags: String? = null + @JsonProperty(value = "Web") var web: String? = null diff --git a/komga/src/test/kotlin/org/gotson/komga/domain/service/MetadataApplierTest.kt b/komga/src/test/kotlin/org/gotson/komga/domain/service/MetadataApplierTest.kt index f86f1c88e..7e0ac1f3c 100644 --- a/komga/src/test/kotlin/org/gotson/komga/domain/service/MetadataApplierTest.kt +++ b/komga/src/test/kotlin/org/gotson/komga/domain/service/MetadataApplierTest.kt @@ -45,6 +45,7 @@ class MetadataApplierTest { authors = listOf(Author("Marcel", "writer")), isbn = "9782811632397", links = listOf(WebLink("Comixology", URI("https://www.comixology.com/Sandman/digital-comic/727888"))), + tags = setOf("tag1", "tag2"), ) val patched = metadataApplier.apply(patch, metadata) @@ -58,6 +59,7 @@ class MetadataApplierTest { assertThat(patched.tags).isEmpty() assertThat(patched.isbn).isEqualTo("") assertThat(patched.links).isEmpty() + assertThat(patched.tags).isEmpty() } @Test @@ -77,6 +79,7 @@ class MetadataApplierTest { authors = listOf(Author("Marcel", "writer")), isbn = "9782811632397", links = listOf(WebLink("Comixology", URI("https://www.comixology.com/Sandman/digital-comic/727888"))), + tags = setOf("tag1", "tag2"), ) val patched = metadataApplier.apply(patch, metadata) @@ -91,13 +94,15 @@ class MetadataApplierTest { Author("Marcel", "writer"), ) assertThat(patched.releaseDate).isEqualTo(patch.releaseDate) - assertThat(patched.tags).isEmpty() assertThat(patched.isbn).isEqualTo(patch.isbn) assertThat(patched.links) .hasSize(1) .containsExactlyInAnyOrder( WebLink("Comixology", URI("https://www.comixology.com/Sandman/digital-comic/727888")), ) + assertThat(patched.tags) + .hasSize(2) + .containsExactlyInAnyOrder("tag1", "tag2") } } diff --git a/komga/src/test/kotlin/org/gotson/komga/infrastructure/metadata/comicrack/ComicInfoProviderTest.kt b/komga/src/test/kotlin/org/gotson/komga/infrastructure/metadata/comicrack/ComicInfoProviderTest.kt index 3232b8882..5f0542186 100644 --- a/komga/src/test/kotlin/org/gotson/komga/infrastructure/metadata/comicrack/ComicInfoProviderTest.kt +++ b/komga/src/test/kotlin/org/gotson/komga/infrastructure/metadata/comicrack/ComicInfoProviderTest.kt @@ -54,6 +54,7 @@ class ComicInfoProviderTest { alternateNumber = "5" storyArc = "one, two, three" web = "https://www.comixology.com/Sandman/digital-comic/727888" + tags = "dark, Occult" } every { mockMapper.readValue(any(), ComicInfo::class.java) } returns comicInfo @@ -67,18 +68,24 @@ class ComicInfoProviderTest { assertThat(numberSort).isEqualTo(10F) assertThat(releaseDate).isEqualTo(LocalDate.of(2020, 2, 1)) - assertThat(readLists).hasSize(4) - assertThat(readLists).containsExactlyInAnyOrder( - BookMetadataPatch.ReadListEntry("story arc", 5), - BookMetadataPatch.ReadListEntry("one"), - BookMetadataPatch.ReadListEntry("two"), - BookMetadataPatch.ReadListEntry("three"), - ) + assertThat(readLists) + .hasSize(4) + .containsExactlyInAnyOrder( + BookMetadataPatch.ReadListEntry("story arc", 5), + BookMetadataPatch.ReadListEntry("one"), + BookMetadataPatch.ReadListEntry("two"), + BookMetadataPatch.ReadListEntry("three"), + ) - assertThat(links).hasSize(1) - assertThat(links).containsExactlyInAnyOrder( - WebLink("www.comixology.com", URI("https://www.comixology.com/Sandman/digital-comic/727888")), - ) + assertThat(links) + .hasSize(1) + .containsExactlyInAnyOrder( + WebLink("www.comixology.com", URI("https://www.comixology.com/Sandman/digital-comic/727888")), + ) + + assertThat(tags) + .hasSize(2) + .containsExactlyInAnyOrder("dark", "occult") } } diff --git a/komga/src/test/kotlin/org/gotson/komga/infrastructure/metadata/comicrack/dto/ComicInfoTest.kt b/komga/src/test/kotlin/org/gotson/komga/infrastructure/metadata/comicrack/dto/ComicInfoTest.kt index 05d8b60ac..0f43de34e 100644 --- a/komga/src/test/kotlin/org/gotson/komga/infrastructure/metadata/comicrack/dto/ComicInfoTest.kt +++ b/komga/src/test/kotlin/org/gotson/komga/infrastructure/metadata/comicrack/dto/ComicInfoTest.kt @@ -25,6 +25,7 @@ class ComicInfoTest { assertThat(imprint).isEqualTo("Vertigo") assertThat(count).isEqualTo(10) assertThat(genre).isEqualTo("Fantasy, Supernatural/Occult, Horror, Mature, Superhero, Mythology, Drama") + assertThat(tags).isEqualTo("dark, Occult") assertThat(pageCount).isEqualTo(237) assertThat(languageISO).isEqualTo("en") assertThat(scanInformation).isEqualTo("") diff --git a/komga/src/test/resources/comicrack/ComicInfo.xml b/komga/src/test/resources/comicrack/ComicInfo.xml index c99ac502f..e20877cda 100644 --- a/komga/src/test/resources/comicrack/ComicInfo.xml +++ b/komga/src/test/resources/comicrack/ComicInfo.xml @@ -26,6 +26,7 @@ Vertigo 10 Fantasy, Supernatural/Occult, Horror, Mature, Superhero, Mythology, Drama + dark, Occult 237 en Mature 17+