mirror of
https://git.mihon.tech/mihonapp/mihon
synced 2024-11-26 23:28:58 +03:00
Fix local source detail JSON files not being read if .noxml was created
Fixes #8549
This commit is contained in:
parent
4f5270cb7d
commit
4622b18c99
1 changed files with 16 additions and 17 deletions
|
@ -152,18 +152,33 @@ class LocalSource(
|
|||
// Augment manga details based on metadata files
|
||||
try {
|
||||
val mangaDirFiles = getMangaDirsFiles(manga.url, baseDirsFile).toList()
|
||||
|
||||
val comicInfoFile = mangaDirFiles
|
||||
.firstOrNull { it.name == COMIC_INFO_FILE }
|
||||
val noXmlFile = mangaDirFiles
|
||||
.firstOrNull { it.name == ".noxml" }
|
||||
if (comicInfoFile != null && noXmlFile != null) noXmlFile.delete()
|
||||
val legacyJsonDetailsFile = mangaDirFiles
|
||||
.firstOrNull { it.extension == "json" }
|
||||
|
||||
when {
|
||||
// Top level ComicInfo.xml
|
||||
comicInfoFile != null -> {
|
||||
noXmlFile?.delete()
|
||||
setMangaDetailsFromComicInfoFile(comicInfoFile.inputStream(), manga)
|
||||
}
|
||||
|
||||
// TODO: automatically convert these to ComicInfo.xml
|
||||
legacyJsonDetailsFile != null -> {
|
||||
json.decodeFromStream<MangaDetails>(legacyJsonDetailsFile.inputStream()).run {
|
||||
title?.let { manga.title = it }
|
||||
author?.let { manga.author = it }
|
||||
artist?.let { manga.artist = it }
|
||||
description?.let { manga.description = it }
|
||||
genre?.let { manga.genre = it.joinToString() }
|
||||
status?.let { manga.status = it }
|
||||
}
|
||||
}
|
||||
|
||||
// Copy ComicInfo.xml from chapter archive to top level if found
|
||||
noXmlFile == null -> {
|
||||
val chapterArchives = mangaDirFiles
|
||||
|
@ -181,22 +196,6 @@ class LocalSource(
|
|||
File("$folderPath/.noxml").createNewFile()
|
||||
}
|
||||
}
|
||||
|
||||
// Fall back to legacy JSON details format
|
||||
else -> {
|
||||
mangaDirFiles
|
||||
.firstOrNull { it.extension == "json" }
|
||||
?.let { file ->
|
||||
json.decodeFromStream<MangaDetails>(file.inputStream()).run {
|
||||
title?.let { manga.title = it }
|
||||
author?.let { manga.author = it }
|
||||
artist?.let { manga.artist = it }
|
||||
description?.let { manga.description = it }
|
||||
genre?.let { manga.genre = it.joinToString() }
|
||||
status?.let { manga.status = it }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
logcat(LogPriority.ERROR, e) { "Error setting manga details from local metadata for ${manga.title}" }
|
||||
|
|
Loading…
Reference in a new issue