mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-16 15:09:18 +01: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
@ -152,18 +152,33 @@ class LocalSource(
|
|||||||
// Augment manga details based on metadata files
|
// Augment manga details based on metadata files
|
||||||
try {
|
try {
|
||||||
val mangaDirFiles = getMangaDirsFiles(manga.url, baseDirsFile).toList()
|
val mangaDirFiles = getMangaDirsFiles(manga.url, baseDirsFile).toList()
|
||||||
|
|
||||||
val comicInfoFile = mangaDirFiles
|
val comicInfoFile = mangaDirFiles
|
||||||
.firstOrNull { it.name == COMIC_INFO_FILE }
|
.firstOrNull { it.name == COMIC_INFO_FILE }
|
||||||
val noXmlFile = mangaDirFiles
|
val noXmlFile = mangaDirFiles
|
||||||
.firstOrNull { it.name == ".noxml" }
|
.firstOrNull { it.name == ".noxml" }
|
||||||
if (comicInfoFile != null && noXmlFile != null) noXmlFile.delete()
|
val legacyJsonDetailsFile = mangaDirFiles
|
||||||
|
.firstOrNull { it.extension == "json" }
|
||||||
|
|
||||||
when {
|
when {
|
||||||
// Top level ComicInfo.xml
|
// Top level ComicInfo.xml
|
||||||
comicInfoFile != null -> {
|
comicInfoFile != null -> {
|
||||||
|
noXmlFile?.delete()
|
||||||
setMangaDetailsFromComicInfoFile(comicInfoFile.inputStream(), manga)
|
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
|
// Copy ComicInfo.xml from chapter archive to top level if found
|
||||||
noXmlFile == null -> {
|
noXmlFile == null -> {
|
||||||
val chapterArchives = mangaDirFiles
|
val chapterArchives = mangaDirFiles
|
||||||
@ -181,22 +196,6 @@ class LocalSource(
|
|||||||
File("$folderPath/.noxml").createNewFile()
|
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) {
|
} catch (e: Throwable) {
|
||||||
logcat(LogPriority.ERROR, e) { "Error setting manga details from local metadata for ${manga.title}" }
|
logcat(LogPriority.ERROR, e) { "Error setting manga details from local metadata for ${manga.title}" }
|
||||||
|
Loading…
Reference in New Issue
Block a user