mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-24 01:48:24 +01:00
Made some changes to ComicInfo metadata (#459)
* Made some changes to ComicInfo metadata The web field now contains a " " separated list of source and tracker urls. The translator field will now use the source name if the scanlator field is empty. * lint * use already existing source instance * made translator not nullable * implemented requested changes created new Mihon exclusive ComicInfo source field and populated it with SourceName reverted previous changes to translator field * Update core-metadata/src/main/java/tachiyomi/core/metadata/comicinfo/ComicInfo.kt Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> * Update app/src/main/java/eu/kanade/domain/manga/model/Manga.kt Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> * Update app/src/main/java/eu/kanade/domain/manga/model/Manga.kt Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> * Update app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> * Update app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt --------- Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
This commit is contained in:
parent
5859a8bbf6
commit
4bfc5e7b51
@ -95,7 +95,13 @@ fun Manga.hasCustomCover(coverCache: CoverCache = Injekt.get()): Boolean {
|
||||
/**
|
||||
* Creates a ComicInfo instance based on the manga and chapter metadata.
|
||||
*/
|
||||
fun getComicInfo(manga: Manga, chapter: Chapter, chapterUrl: String, categories: List<String>?) = ComicInfo(
|
||||
fun getComicInfo(
|
||||
manga: Manga,
|
||||
chapter: Chapter,
|
||||
urls: List<String>,
|
||||
categories: List<String>?,
|
||||
sourceName: String,
|
||||
) = ComicInfo(
|
||||
title = ComicInfo.Title(chapter.name),
|
||||
series = ComicInfo.Series(manga.title),
|
||||
number = chapter.chapterNumber.takeIf { it >= 0 }?.let {
|
||||
@ -105,7 +111,7 @@ fun getComicInfo(manga: Manga, chapter: Chapter, chapterUrl: String, categories:
|
||||
ComicInfo.Number(it.toString())
|
||||
}
|
||||
},
|
||||
web = ComicInfo.Web(chapterUrl),
|
||||
web = ComicInfo.Web(urls.joinToString(" ")),
|
||||
summary = manga.description?.let { ComicInfo.Summary(it) },
|
||||
writer = manga.author?.let { ComicInfo.Writer(it) },
|
||||
penciller = manga.artist?.let { ComicInfo.Penciller(it) },
|
||||
@ -115,6 +121,7 @@ fun getComicInfo(manga: Manga, chapter: Chapter, chapterUrl: String, categories:
|
||||
ComicInfoPublishingStatus.toComicInfoValue(manga.status),
|
||||
),
|
||||
categories = categories?.let { ComicInfo.CategoriesTachiyomi(it.joinToString()) },
|
||||
source = ComicInfo.SourceMihon(sourceName),
|
||||
inker = null,
|
||||
colorist = null,
|
||||
letterer = null,
|
||||
|
@ -54,6 +54,7 @@ import tachiyomi.domain.chapter.model.Chapter
|
||||
import tachiyomi.domain.download.service.DownloadPreferences
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.domain.source.service.SourceManager
|
||||
import tachiyomi.domain.track.interactor.GetTracks
|
||||
import tachiyomi.i18n.MR
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
@ -78,6 +79,7 @@ class Downloader(
|
||||
private val downloadPreferences: DownloadPreferences = Injekt.get(),
|
||||
private val xml: XML = Injekt.get(),
|
||||
private val getCategories: GetCategories = Injekt.get(),
|
||||
private val getTracks: GetTracks = Injekt.get(),
|
||||
) {
|
||||
|
||||
/**
|
||||
@ -626,9 +628,22 @@ class Downloader(
|
||||
chapter: Chapter,
|
||||
source: HttpSource,
|
||||
) {
|
||||
val chapterUrl = source.getChapterUrl(chapter.toSChapter())
|
||||
val categories = getCategories.await(manga.id).map { it.name.trim() }.takeUnless { it.isEmpty() }
|
||||
val comicInfo = getComicInfo(manga, chapter, chapterUrl, categories)
|
||||
val urls = getTracks.await(manga.id)
|
||||
.mapNotNull { track ->
|
||||
track.remoteUrl.takeUnless { url -> url.isBlank() }?.trim()
|
||||
}
|
||||
.plus(source.getChapterUrl(chapter.toSChapter()).trim())
|
||||
.distinct()
|
||||
|
||||
val comicInfo = getComicInfo(
|
||||
manga,
|
||||
chapter,
|
||||
urls,
|
||||
categories,
|
||||
source.name
|
||||
)
|
||||
|
||||
// Remove the old file
|
||||
dir.findFile(COMIC_INFO_FILE, true)?.delete()
|
||||
dir.createFile(COMIC_INFO_FILE)!!.openOutputStream().use {
|
||||
|
@ -27,6 +27,7 @@ fun SManga.getComicInfo() = ComicInfo(
|
||||
coverArtist = null,
|
||||
tags = null,
|
||||
categories = null,
|
||||
source = null,
|
||||
)
|
||||
|
||||
fun SManga.copyFromComicInfo(comicInfo: ComicInfo) {
|
||||
@ -81,6 +82,7 @@ data class ComicInfo(
|
||||
val web: Web?,
|
||||
val publishingStatus: PublishingStatusTachiyomi?,
|
||||
val categories: CategoriesTachiyomi?,
|
||||
val source: SourceMihon?,
|
||||
) {
|
||||
@XmlElement(false)
|
||||
@XmlSerialName("xmlns:xsd", "", "")
|
||||
@ -154,6 +156,10 @@ data class ComicInfo(
|
||||
@Serializable
|
||||
@XmlSerialName("Categories", "http://www.w3.org/2001/XMLSchema", "ty")
|
||||
data class CategoriesTachiyomi(@XmlValue(true) val value: String = "")
|
||||
|
||||
@Serializable
|
||||
@XmlSerialName("SourceMihon", "http://www.w3.org/2001/XMLSchema", "mh")
|
||||
data class SourceMihon(@XmlValue(true) val value: String = "")
|
||||
}
|
||||
|
||||
enum class ComicInfoPublishingStatus(
|
||||
|
Loading…
Reference in New Issue
Block a user