From b8716ff6fed7fefccd03554337d0ce882f64bed2 Mon Sep 17 00:00:00 2001 From: Shamicen <84282253+Shamicen@users.noreply.github.com> Date: Sat, 20 May 2023 16:24:10 +0200 Subject: [PATCH] Populate the ComicInfo Number field with chapter numbers (#9514) * Populate the ComicInfo Number field * added negative number check --- app/src/main/java/eu/kanade/domain/manga/model/Manga.kt | 1 + .../main/java/tachiyomi/core/metadata/comicinfo/ComicInfo.kt | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/app/src/main/java/eu/kanade/domain/manga/model/Manga.kt b/app/src/main/java/eu/kanade/domain/manga/model/Manga.kt index 6712a06ae6..50eb84be64 100644 --- a/app/src/main/java/eu/kanade/domain/manga/model/Manga.kt +++ b/app/src/main/java/eu/kanade/domain/manga/model/Manga.kt @@ -98,6 +98,7 @@ fun Manga.hasCustomCover(coverCache: CoverCache = Injekt.get()): Boolean { fun getComicInfo(manga: Manga, chapter: Chapter, chapterUrl: String) = ComicInfo( title = ComicInfo.Title(chapter.name), series = ComicInfo.Series(manga.title), + number = chapter.chapterNumber.takeIf { it >= 0 }?.let { ComicInfo.Number(it.toString()) }, web = ComicInfo.Web(chapterUrl), summary = manga.description?.let { ComicInfo.Summary(it) }, writer = manga.author?.let { ComicInfo.Writer(it) }, diff --git a/core-metadata/src/main/java/tachiyomi/core/metadata/comicinfo/ComicInfo.kt b/core-metadata/src/main/java/tachiyomi/core/metadata/comicinfo/ComicInfo.kt index 80c0e9d4c1..b215b49936 100644 --- a/core-metadata/src/main/java/tachiyomi/core/metadata/comicinfo/ComicInfo.kt +++ b/core-metadata/src/main/java/tachiyomi/core/metadata/comicinfo/ComicInfo.kt @@ -44,6 +44,7 @@ fun SManga.copyFromComicInfo(comicInfo: ComicInfo) { data class ComicInfo( val title: Title?, val series: Series?, + val number: Number?, val summary: Summary?, val writer: Writer?, val penciller: Penciller?, @@ -75,6 +76,10 @@ data class ComicInfo( @XmlSerialName("Series", "", "") data class Series(@XmlValue(true) val value: String = "") + @Serializable + @XmlSerialName("Number", "", "") + data class Number(@XmlValue(true) val value: String = "") + @Serializable @XmlSerialName("Summary", "", "") data class Summary(@XmlValue(true) val value: String = "")