-
-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: retrieve metadata from ComicInfo.xml
retrieve for both Book and Series
- Loading branch information
Showing
28 changed files
with
1,066 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
<xs:element name="ComicInfo" nillable="true" type="ComicInfo" /> | ||
<xs:complexType name="ComicInfo"> | ||
<xs:sequence> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Title" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Series" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Number" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Count" type="xs:int" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Volume" type="xs:int" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="AlternateSeries" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="AlternateNumber" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="AlternateCount" type="xs:int" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Summary" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Notes" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Year" type="xs:int" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Month" type="xs:int" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Writer" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Penciller" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Inker" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Colorist" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Letterer" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="CoverArtist" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Editor" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Publisher" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Imprint" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Genre" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Web" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="0" name="PageCount" type="xs:int" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="LanguageISO" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Format" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="Unknown" name="BlackAndWhite" type="YesNo" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="Unknown" name="Manga" type="YesNo" /> | ||
<xs:element minOccurs="0" maxOccurs="1" name="Pages" type="ArrayOfComicPageInfo" /> | ||
</xs:sequence> | ||
</xs:complexType> | ||
<xs:simpleType name="YesNo"> | ||
<xs:restriction base="xs:string"> | ||
<xs:enumeration value="Unknown" /> | ||
<xs:enumeration value="No" /> | ||
<xs:enumeration value="Yes" /> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
<xs:complexType name="ArrayOfComicPageInfo"> | ||
<xs:sequence> | ||
<xs:element minOccurs="0" maxOccurs="unbounded" name="Page" nillable="true" type="ComicPageInfo" /> | ||
</xs:sequence> | ||
</xs:complexType> | ||
<xs:complexType name="ComicPageInfo"> | ||
<xs:attribute name="Image" type="xs:int" use="required" /> | ||
<xs:attribute default="Story" name="Type" type="ComicPageType" /> | ||
<xs:attribute default="false" name="DoublePage" type="xs:boolean" /> | ||
<xs:attribute default="0" name="ImageSize" type="xs:long" /> | ||
<xs:attribute default="" name="Key" type="xs:string" /> | ||
<xs:attribute default="-1" name="ImageWidth" type="xs:int" /> | ||
<xs:attribute default="-1" name="ImageHeight" type="xs:int" /> | ||
</xs:complexType> | ||
<xs:simpleType name="ComicPageType"> | ||
<xs:list> | ||
<xs:simpleType> | ||
<xs:restriction base="xs:string"> | ||
<xs:enumeration value="FrontCover" /> | ||
<xs:enumeration value="InnerCover" /> | ||
<xs:enumeration value="Roundup" /> | ||
<xs:enumeration value="Story" /> | ||
<xs:enumeration value="Advertisment" /> | ||
<xs:enumeration value="Editorial" /> | ||
<xs:enumeration value="Letters" /> | ||
<xs:enumeration value="Preview" /> | ||
<xs:enumeration value="BackCover" /> | ||
<xs:enumeration value="Other" /> | ||
<xs:enumeration value="Deleted" /> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
</xs:list> | ||
</xs:simpleType> | ||
</xs:schema> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
<xs:element name="ComicInfo" nillable="true" type="ComicInfo" /> | ||
<xs:complexType name="ComicInfo"> | ||
<xs:sequence> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Title" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Series" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Number" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Count" type="xs:int" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Volume" type="xs:int" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="AlternateSeries" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="AlternateNumber" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="AlternateCount" type="xs:int" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Summary" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Notes" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Year" type="xs:int" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Month" type="xs:int" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Writer" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Penciller" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Inker" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Colorist" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Letterer" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="CoverArtist" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Editor" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Publisher" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Imprint" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Genre" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Web" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="0" name="PageCount" type="xs:int" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="LanguageISO" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Format" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="Unknown" name="BlackAndWhite" type="YesNo" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="Unknown" name="Manga" type="Manga" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Characters" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Teams" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Locations" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="ScanInformation" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="StoryArc" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="" name="SeriesGroup" type="xs:string" /> | ||
<xs:element minOccurs="0" maxOccurs="1" default="Unknown" name="AgeRating" type="AgeRating" /> | ||
<xs:element minOccurs="0" maxOccurs="1" name="Pages" type="ArrayOfComicPageInfo" /> | ||
</xs:sequence> | ||
</xs:complexType> | ||
<xs:simpleType name="YesNo"> | ||
<xs:restriction base="xs:string"> | ||
<xs:enumeration value="Unknown" /> | ||
<xs:enumeration value="No" /> | ||
<xs:enumeration value="Yes" /> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
<xs:simpleType name="Manga"> | ||
<xs:restriction base="xs:string"> | ||
<xs:enumeration value="Unknown" /> | ||
<xs:enumeration value="No" /> | ||
<xs:enumeration value="Yes" /> | ||
<xs:enumeration value="YesAndRightToLeft" /> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
<xs:simpleType name="AgeRating"> | ||
<xs:restriction base="xs:string"> | ||
<xs:enumeration value="Unknown" /> | ||
<xs:enumeration value="Adults Only 18+" /> | ||
<xs:enumeration value="Early Childhood" /> | ||
<xs:enumeration value="Everyone" /> | ||
<xs:enumeration value="Everyone 10+" /> | ||
<xs:enumeration value="G" /> | ||
<xs:enumeration value="Kids to Adults" /> | ||
<xs:enumeration value="M" /> | ||
<xs:enumeration value="MA 15+" /> | ||
<xs:enumeration value="Mature 17+" /> | ||
<xs:enumeration value="PG" /> | ||
<xs:enumeration value="R18+" /> | ||
<xs:enumeration value="Rating Pending" /> | ||
<xs:enumeration value="Teen" /> | ||
<xs:enumeration value="X18+" /> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
<xs:complexType name="ArrayOfComicPageInfo"> | ||
<xs:sequence> | ||
<xs:element minOccurs="0" maxOccurs="unbounded" name="Page" nillable="true" type="ComicPageInfo" /> | ||
</xs:sequence> | ||
</xs:complexType> | ||
<xs:complexType name="ComicPageInfo"> | ||
<xs:attribute name="Image" type="xs:int" use="required" /> | ||
<xs:attribute default="Story" name="Type" type="ComicPageType" /> | ||
<xs:attribute default="false" name="DoublePage" type="xs:boolean" /> | ||
<xs:attribute default="0" name="ImageSize" type="xs:long" /> | ||
<xs:attribute default="" name="Key" type="xs:string" /> | ||
<xs:attribute default="-1" name="ImageWidth" type="xs:int" /> | ||
<xs:attribute default="-1" name="ImageHeight" type="xs:int" /> | ||
</xs:complexType> | ||
<xs:simpleType name="ComicPageType"> | ||
<xs:list> | ||
<xs:simpleType> | ||
<xs:restriction base="xs:string"> | ||
<xs:enumeration value="FrontCover" /> | ||
<xs:enumeration value="InnerCover" /> | ||
<xs:enumeration value="Roundup" /> | ||
<xs:enumeration value="Story" /> | ||
<xs:enumeration value="Advertisment" /> | ||
<xs:enumeration value="Editorial" /> | ||
<xs:enumeration value="Letters" /> | ||
<xs:enumeration value="Preview" /> | ||
<xs:enumeration value="BackCover" /> | ||
<xs:enumeration value="Other" /> | ||
<xs:enumeration value="Deleted" /> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
</xs:list> | ||
</xs:simpleType> | ||
</xs:schema> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
komga/src/main/kotlin/org/gotson/komga/application/service/MetadataLifecycle.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.gotson.komga.application.service | ||
|
||
import mu.KotlinLogging | ||
import org.gotson.komga.domain.model.Book | ||
import org.gotson.komga.domain.model.Series | ||
import org.gotson.komga.domain.persistence.BookRepository | ||
import org.gotson.komga.domain.persistence.SeriesRepository | ||
import org.gotson.komga.domain.service.MetadataApplier | ||
import org.gotson.komga.infrastructure.metadata.comicinfo.ComicInfoProvider | ||
import org.springframework.data.repository.findByIdOrNull | ||
import org.springframework.scheduling.annotation.Async | ||
import org.springframework.stereotype.Service | ||
import org.springframework.transaction.annotation.Transactional | ||
|
||
private val logger = KotlinLogging.logger {} | ||
|
||
@Service | ||
class MetadataLifecycle( | ||
private val comicInfoProvider: ComicInfoProvider, | ||
private val metadataApplier: MetadataApplier, | ||
private val bookRepository: BookRepository, | ||
private val seriesRepository: SeriesRepository | ||
) { | ||
|
||
@Transactional | ||
@Async("refreshMetadataTaskExecutor") | ||
fun refreshMetadata(book: Book) { | ||
logger.info { "Refresh metadata for book: $book" } | ||
val loadedBook = bookRepository.findByIdOrNull(book.id) | ||
|
||
loadedBook?.let { b -> | ||
val patch = comicInfoProvider.getBookMetadataFromBook(b) | ||
|
||
patch?.let { | ||
metadataApplier.apply(it, b) | ||
bookRepository.save(b) | ||
} | ||
|
||
val seriesPatch = comicInfoProvider.getSeriesMetadataFromBook(b) | ||
|
||
seriesPatch?.let { | ||
metadataApplier.apply(it, b.series) | ||
seriesRepository.save(b.series) | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,5 @@ class Author { | |
field = value.trim().toLowerCase() | ||
} | ||
|
||
override fun toString(): String = "Author($name, $role)" | ||
} |
15 changes: 15 additions & 0 deletions
15
komga/src/main/kotlin/org/gotson/komga/domain/model/BookMetadataPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.gotson.komga.domain.model | ||
|
||
import java.time.LocalDate | ||
|
||
class BookMetadataPatch( | ||
val title: String?, | ||
val summary: String?, | ||
val number: String?, | ||
val numberSort: Float?, | ||
val readingDirection: BookMetadata.ReadingDirection?, | ||
val publisher: String?, | ||
val ageRating: Int?, | ||
val releaseDate: LocalDate?, | ||
val authors: List<Author>? | ||
) |
Oops, something went wrong.