mirror of
https://github.com/gotson/komga.git
synced 2025-12-16 13:33:49 +01:00
feat: import total book count from ComicInfo.xml and Mylar series.json
closes #450
This commit is contained in:
parent
6090e3f0c5
commit
64acfeff99
11 changed files with 17 additions and 2 deletions
|
|
@ -10,6 +10,7 @@ data class SeriesMetadataPatch(
|
|||
val ageRating: Int?,
|
||||
val language: String?,
|
||||
val genres: Set<String>?,
|
||||
val totalBookCount: Int?,
|
||||
|
||||
val collections: List<String>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ class BookMetadataLifecycle(
|
|||
logger.debug { "Apply metadata for book: $book" }
|
||||
|
||||
logger.debug { "Original metadata: $it" }
|
||||
logger.debug { "Patch: $patch" }
|
||||
val patched = metadataApplier.apply(bPatch, it)
|
||||
logger.debug { "Patched metadata: $patched" }
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@ class MetadataApplier {
|
|||
ageRating = getIfNotLocked(ageRating, patch.ageRating, ageRatingLock),
|
||||
publisher = getIfNotLocked(publisher, patch.publisher, publisherLock),
|
||||
language = getIfNotLocked(language, patch.language, languageLock),
|
||||
genres = getIfNotLocked(genres, patch.genres, genresLock)
|
||||
genres = getIfNotLocked(genres, patch.genres, genresLock),
|
||||
totalBookCount = getIfNotLocked(totalBookCount, patch.totalBookCount, totalBookCountLock)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,6 +131,7 @@ class SeriesMetadataLifecycle(
|
|||
readingDirection = patches.mostFrequent { it.readingDirection },
|
||||
ageRating = patches.mapNotNull { it.ageRating }.maxOrNull(),
|
||||
publisher = patches.mostFrequent { it.publisher },
|
||||
totalBookCount = patches.mapNotNull { it.totalBookCount }.maxOrNull(),
|
||||
collections = emptyList()
|
||||
)
|
||||
|
||||
|
|
@ -145,6 +146,7 @@ class SeriesMetadataLifecycle(
|
|||
logger.debug { "Apply metadata for series: $series" }
|
||||
|
||||
logger.debug { "Original metadata: $it" }
|
||||
logger.debug { "Patch: $patch" }
|
||||
val patched = metadataApplier.apply(patch, it)
|
||||
logger.debug { "Patched metadata: $patched" }
|
||||
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ class ComicInfoProvider(
|
|||
ageRating = comicInfo.ageRating?.ageRating,
|
||||
language = if (comicInfo.languageISO != null && BCP47TagValidator.isValid(comicInfo.languageISO!!)) comicInfo.languageISO else null,
|
||||
genres = if (!genres.isNullOrEmpty()) genres.toSet() else null,
|
||||
totalBookCount = comicInfo.count,
|
||||
collections = listOfNotNull(comicInfo.seriesGroup?.ifBlank { null })
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,6 +120,7 @@ class EpubMetadataProvider(
|
|||
summary = null,
|
||||
language = if (language != null && BCP47TagValidator.isValid(language)) language else null,
|
||||
genres = genres,
|
||||
totalBookCount = null,
|
||||
collections = emptyList()
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ class MylarSeriesProvider(
|
|||
ageRating = metadata.ageRating?.ageRating,
|
||||
language = null,
|
||||
genres = null,
|
||||
totalBookCount = metadata.totalIssues,
|
||||
collections = emptyList(),
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
|
|
|
|||
|
|
@ -321,6 +321,7 @@ class ComicInfoProviderTest {
|
|||
ageRating = AgeRating.MA_15
|
||||
manga = Manga.YES_AND_RIGHT_TO_LEFT
|
||||
languageISO = "en"
|
||||
count = 10
|
||||
genre = "Action, Adventure"
|
||||
}
|
||||
|
||||
|
|
@ -337,7 +338,8 @@ class ComicInfoProviderTest {
|
|||
assertThat(ageRating).isEqualTo(15)
|
||||
assertThat(readingDirection).isEqualTo(SeriesMetadata.ReadingDirection.RIGHT_TO_LEFT)
|
||||
assertThat(language).isEqualTo("en")
|
||||
assertThat(summary).isBlank()
|
||||
assertThat(summary).isBlank
|
||||
assertThat(totalBookCount).isEqualTo(10)
|
||||
assertThat(genres).containsExactlyInAnyOrder("Action", "Adventure")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ class ComicInfoTest {
|
|||
assertThat(notes).isEqualTo("Scraped metadata from Comixology [CMXDB727888], [RELDATE:2018-10-30]")
|
||||
assertThat(publisher).isEqualTo("DC")
|
||||
assertThat(imprint).isEqualTo("Vertigo")
|
||||
assertThat(count).isEqualTo(10)
|
||||
assertThat(genre).isEqualTo("Fantasy, Supernatural/Occult, Horror, Mature, Superhero, Mythology, Drama")
|
||||
assertThat(pageCount).isEqualTo(237)
|
||||
assertThat(languageISO).isEqualTo("en")
|
||||
|
|
@ -47,6 +48,7 @@ class ComicInfoTest {
|
|||
assertThat(notes).isEqualTo("Scraped metadata from Comixology [CMXDB727888], [RELDATE:2018-10-30]")
|
||||
assertThat(publisher).isEqualTo("DC")
|
||||
assertThat(imprint).isEqualTo("Vertigo")
|
||||
assertThat(pageCount).isNull()
|
||||
assertThat(genre).isEqualTo("Fantasy, Supernatural/Occult, Horror, Mature, Superhero, Mythology, Drama")
|
||||
assertThat(pageCount).isEqualTo(237)
|
||||
assertThat(languageISO).isEqualTo("en")
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ class MylarSeriesProviderTest {
|
|||
assertThat(ageRating).isEqualTo(18)
|
||||
assertThat(language).isNull()
|
||||
assertThat(genres).isNull()
|
||||
assertThat(totalBookCount).isEqualTo(2)
|
||||
assertThat(collections).isEmpty()
|
||||
}
|
||||
}
|
||||
|
|
@ -96,6 +97,7 @@ class MylarSeriesProviderTest {
|
|||
assertThat(ageRating).isNull()
|
||||
assertThat(language).isNull()
|
||||
assertThat(genres).isNull()
|
||||
assertThat(totalBookCount).isEqualTo(2)
|
||||
assertThat(collections).isEmpty()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
<Notes>Scraped metadata from Comixology [CMXDB727888], [RELDATE:2018-10-30]</Notes>
|
||||
<Publisher>DC</Publisher>
|
||||
<Imprint>Vertigo</Imprint>
|
||||
<Count>10</Count>
|
||||
<Genre>Fantasy, Supernatural/Occult, Horror, Mature, Superhero, Mythology, Drama</Genre>
|
||||
<PageCount>237</PageCount>
|
||||
<LanguageISO>en</LanguageISO>
|
||||
|
|
|
|||
Loading…
Reference in a new issue