mirror of
https://github.com/tachiyomiorg/tachiyomi-extensions-inspector.git
synced 2025-02-28 22:43:38 +01:00
also backup chapter and category data
This commit is contained in:
parent
c04cc780b7
commit
8fbf564177
@ -12,9 +12,12 @@ import com.google.gson.JsonArray
|
|||||||
import com.google.gson.JsonElement
|
import com.google.gson.JsonElement
|
||||||
import com.google.gson.JsonObject
|
import com.google.gson.JsonObject
|
||||||
import eu.kanade.tachiyomi.source.LocalSource
|
import eu.kanade.tachiyomi.source.LocalSource
|
||||||
|
import ir.armor.tachidesk.impl.Category.getCategoryList
|
||||||
|
import ir.armor.tachidesk.impl.CategoryManga.getMangaCategories
|
||||||
import ir.armor.tachidesk.impl.backup.BackupFlags
|
import ir.armor.tachidesk.impl.backup.BackupFlags
|
||||||
import ir.armor.tachidesk.impl.backup.legacy.models.Backup
|
import ir.armor.tachidesk.impl.backup.legacy.models.Backup
|
||||||
import ir.armor.tachidesk.impl.backup.legacy.models.Backup.CURRENT_VERSION
|
import ir.armor.tachidesk.impl.backup.legacy.models.Backup.CURRENT_VERSION
|
||||||
|
import ir.armor.tachidesk.impl.backup.models.CategoryImpl
|
||||||
import ir.armor.tachidesk.impl.backup.models.ChapterImpl
|
import ir.armor.tachidesk.impl.backup.models.ChapterImpl
|
||||||
import ir.armor.tachidesk.impl.backup.models.Manga
|
import ir.armor.tachidesk.impl.backup.models.Manga
|
||||||
import ir.armor.tachidesk.impl.backup.models.MangaImpl
|
import ir.armor.tachidesk.impl.backup.models.MangaImpl
|
||||||
@ -83,11 +86,11 @@ object LegacyBackupExport : LegacyBackupBase() {
|
|||||||
|
|
||||||
// Backup manga fields
|
// Backup manga fields
|
||||||
entry[Backup.MANGA] = parser.toJsonTree(manga)
|
entry[Backup.MANGA] = parser.toJsonTree(manga)
|
||||||
|
val mangaId = manga.id!!.toInt()
|
||||||
|
|
||||||
// Check if user wants chapter information in backup
|
// Check if user wants chapter information in backup
|
||||||
if (options.includeChapters && false) { // TODO
|
if (options.includeChapters) {
|
||||||
// Backup all the chapters
|
// Backup all the chapters
|
||||||
val mangaId = manga.id!!.toInt()
|
|
||||||
val chapters = ChapterTable.select { ChapterTable.manga eq mangaId }.map { ChapterImpl.fromQuery(it) }
|
val chapters = ChapterTable.select { ChapterTable.manga eq mangaId }.map { ChapterImpl.fromQuery(it) }
|
||||||
if (chapters.count() > 0) {
|
if (chapters.count() > 0) {
|
||||||
val chaptersJson = parser.toJsonTree(chapters)
|
val chaptersJson = parser.toJsonTree(chapters)
|
||||||
@ -97,14 +100,50 @@ object LegacyBackupExport : LegacyBackupBase() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO the rest
|
// Check if user wants category information in backup
|
||||||
|
if (options.includeCategories) {
|
||||||
|
// Backup categories for this manga
|
||||||
|
val categoriesForManga = getMangaCategories(mangaId)
|
||||||
|
if (categoriesForManga.isNotEmpty()) {
|
||||||
|
val categoriesNames = categoriesForManga.map { it.name }
|
||||||
|
entry[Backup.CATEGORIES] = parser.toJsonTree(categoriesNames)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if user wants track information in backup
|
||||||
|
if (options.includeTracking) { // TODO
|
||||||
|
// val tracks = databaseHelper.getTracks(manga).executeAsBlocking()
|
||||||
|
// if (tracks.isNotEmpty()) {
|
||||||
|
// entry[TRACK] = parser.toJsonTree(tracks)
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// // Check if user wants history information in backup
|
||||||
|
if (options.includeHistory) { // TODO
|
||||||
|
// val historyForManga = databaseHelper.getHistoryByMangaId(manga.id!!).executeAsBlocking()
|
||||||
|
// if (historyForManga.isNotEmpty()) {
|
||||||
|
// val historyData = historyForManga.mapNotNull { history ->
|
||||||
|
// val url = databaseHelper.getChapter(history.chapter_id).executeAsBlocking()?.url
|
||||||
|
// url?.let { DHistory(url, history.last_read) }
|
||||||
|
// }
|
||||||
|
// val historyJson = parser.toJsonTree(historyData)
|
||||||
|
// if (historyJson.asJsonArray.size() > 0) {
|
||||||
|
// entry[HISTORY] = historyJson
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
return entry
|
return entry
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun backupCategories(root: JsonArray) { // TODO
|
private fun backupCategories(root: JsonArray) {
|
||||||
// val categories = databaseHelper.getCategories().executeAsBlocking()
|
val categories = getCategoryList().map{
|
||||||
// categories.forEach { root.add(parser.toJsonTree(it)) }
|
CategoryImpl().apply {
|
||||||
|
name = it.name
|
||||||
|
order = it.order
|
||||||
|
}
|
||||||
|
}
|
||||||
|
categories.forEach { root.add(parser.toJsonTree(it)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun backupExtensionInfo(root: JsonArray, extensions: Set<String>) {
|
private fun backupExtensionInfo(root: JsonArray, extensions: Set<String>) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package ir.armor.tachidesk.impl.backup.models
|
package ir.armor.tachidesk.impl.backup.models
|
||||||
|
|
||||||
|
import ir.armor.tachidesk.model.database.ChapterTable
|
||||||
import org.jetbrains.exposed.sql.ResultRow
|
import org.jetbrains.exposed.sql.ResultRow
|
||||||
|
|
||||||
class ChapterImpl : Chapter {
|
class ChapterImpl : Chapter {
|
||||||
@ -45,7 +46,10 @@ class ChapterImpl : Chapter {
|
|||||||
companion object {
|
companion object {
|
||||||
fun fromQuery(chapterRecord: ResultRow): ChapterImpl {
|
fun fromQuery(chapterRecord: ResultRow): ChapterImpl {
|
||||||
return ChapterImpl().apply {
|
return ChapterImpl().apply {
|
||||||
// TODO
|
url = chapterRecord[ChapterTable.url]
|
||||||
|
read = chapterRecord[ChapterTable.isRead]
|
||||||
|
bookmark = chapterRecord[ChapterTable.isBookmarked]
|
||||||
|
last_page_read = chapterRecord[ChapterTable.lastPageRead]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,10 @@ object ChapterTable : IntIdTable() {
|
|||||||
val chapter_number = float("chapter_number").default(-1f)
|
val chapter_number = float("chapter_number").default(-1f)
|
||||||
val scanlator = varchar("scanlator", 128).nullable()
|
val scanlator = varchar("scanlator", 128).nullable()
|
||||||
|
|
||||||
|
val isRead = bool("read").default(false)
|
||||||
|
val isBookmarked = bool("bookmark").default(false)
|
||||||
|
val lastPageRead = integer("last_page_read").default(0)
|
||||||
|
|
||||||
val chapterIndex = integer("number_in_list")
|
val chapterIndex = integer("number_in_list")
|
||||||
|
|
||||||
val manga = reference("manga", MangaTable)
|
val manga = reference("manga", MangaTable)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user