mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-04 03:14:40 -05:00
chapter new parameters get endpoint
This commit is contained in:
@@ -30,10 +30,10 @@ object Chapter {
|
|||||||
val source = getHttpSource(mangaDetails.sourceId.toLong())
|
val source = getHttpSource(mangaDetails.sourceId.toLong())
|
||||||
|
|
||||||
val chapterList = source.fetchChapterList(
|
val chapterList = source.fetchChapterList(
|
||||||
SManga.create().apply {
|
SManga.create().apply {
|
||||||
title = mangaDetails.title
|
title = mangaDetails.title
|
||||||
url = mangaDetails.url
|
url = mangaDetails.url
|
||||||
}
|
}
|
||||||
).awaitSingle()
|
).awaitSingle()
|
||||||
|
|
||||||
val chapterCount = chapterList.count()
|
val chapterCount = chapterList.count()
|
||||||
@@ -69,17 +69,30 @@ object Chapter {
|
|||||||
val dbChapterCount = transaction { ChapterTable.selectAll().count() }
|
val dbChapterCount = transaction { ChapterTable.selectAll().count() }
|
||||||
if (dbChapterCount > chapterCount) { // we got some clean up due
|
if (dbChapterCount > chapterCount) { // we got some clean up due
|
||||||
// TODO: delete orphan chapters
|
// TODO: delete orphan chapters
|
||||||
|
val dbChapterList = transaction { ChapterTable.selectAll().orderBy() }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val dbChapters = transaction { ChapterTable.selectAll() }
|
||||||
|
.associateBy({ it[ChapterTable.url] }, { it })
|
||||||
|
|
||||||
chapterList.mapIndexed { index, it ->
|
chapterList.mapIndexed { index, it ->
|
||||||
|
|
||||||
|
val dbChapter = dbChapters.getValue(it.url)
|
||||||
|
|
||||||
ChapterDataClass(
|
ChapterDataClass(
|
||||||
it.url,
|
it.url,
|
||||||
it.name,
|
it.name,
|
||||||
it.date_upload,
|
it.date_upload,
|
||||||
it.chapter_number,
|
it.chapter_number,
|
||||||
it.scanlator,
|
it.scanlator,
|
||||||
mangaId,
|
mangaId,
|
||||||
chapterCount - index,
|
|
||||||
|
dbChapter[ChapterTable.isRead],
|
||||||
|
dbChapter[ChapterTable.isBookmarked],
|
||||||
|
dbChapter[ChapterTable.lastPageRead],
|
||||||
|
|
||||||
|
chapterCount - index,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -96,10 +109,10 @@ object Chapter {
|
|||||||
val source = getHttpSource(mangaEntry[MangaTable.sourceReference])
|
val source = getHttpSource(mangaEntry[MangaTable.sourceReference])
|
||||||
|
|
||||||
val pageList = source.fetchPageList(
|
val pageList = source.fetchPageList(
|
||||||
SChapter.create().apply {
|
SChapter.create().apply {
|
||||||
url = chapterEntry[ChapterTable.url]
|
url = chapterEntry[ChapterTable.url]
|
||||||
name = chapterEntry[ChapterTable.name]
|
name = chapterEntry[ChapterTable.name]
|
||||||
}
|
}
|
||||||
).awaitSingle()
|
).awaitSingle()
|
||||||
|
|
||||||
val chapterId = chapterEntry[ChapterTable.id].value
|
val chapterId = chapterEntry[ChapterTable.id].value
|
||||||
@@ -125,16 +138,21 @@ object Chapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return ChapterDataClass(
|
return ChapterDataClass(
|
||||||
chapterEntry[ChapterTable.url],
|
chapterEntry[ChapterTable.url],
|
||||||
chapterEntry[ChapterTable.name],
|
chapterEntry[ChapterTable.name],
|
||||||
chapterEntry[ChapterTable.date_upload],
|
chapterEntry[ChapterTable.date_upload],
|
||||||
chapterEntry[ChapterTable.chapter_number],
|
chapterEntry[ChapterTable.chapter_number],
|
||||||
chapterEntry[ChapterTable.scanlator],
|
chapterEntry[ChapterTable.scanlator],
|
||||||
mangaId,
|
mangaId,
|
||||||
chapterEntry[ChapterTable.chapterIndex],
|
chapterEntry[ChapterTable.isRead],
|
||||||
chapterCount.toInt(),
|
chapterEntry[ChapterTable.isBookmarked],
|
||||||
pageList.count()
|
chapterEntry[ChapterTable.lastPageRead],
|
||||||
|
|
||||||
|
chapterEntry[ChapterTable.chapterIndex],
|
||||||
|
chapterCount.toInt(),
|
||||||
|
pageList.count()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,11 +80,11 @@ object LegacyBackupImport : LegacyBackupBase() {
|
|||||||
return validationResult
|
return validationResult
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun restoreCategories(jsonCategories: JsonElement) { // TODO
|
private fun restoreCategories(jsonCategories: JsonElement) {
|
||||||
val backupCategories = parser.fromJson<List<CategoryImpl>>(jsonCategories)
|
val backupCategories = parser.fromJson<List<CategoryImpl>>(jsonCategories)
|
||||||
val dbCategories = getCategoryList()
|
val dbCategories = getCategoryList()
|
||||||
|
|
||||||
// Iterate over them
|
// Iterate over them and create missing categories
|
||||||
backupCategories.forEach { category ->
|
backupCategories.forEach { category ->
|
||||||
if (dbCategories.none { it.name == category.name }) {
|
if (dbCategories.none { it.name == category.name }) {
|
||||||
createCategory(category.name)
|
createCategory(category.name)
|
||||||
|
|||||||
@@ -10,12 +10,21 @@ package ir.armor.tachidesk.model.dataclass
|
|||||||
data class ChapterDataClass(
|
data class ChapterDataClass(
|
||||||
val url: String,
|
val url: String,
|
||||||
val name: String,
|
val name: String,
|
||||||
val date_upload: Long,
|
val uploadDate: Long,
|
||||||
val chapter_number: Float,
|
val chapterNumber: Float,
|
||||||
val scanlator: String?,
|
val scanlator: String?,
|
||||||
val mangaId: Int,
|
val mangaId: Int,
|
||||||
|
|
||||||
/** this chapter's index */
|
/** chapter is read */
|
||||||
|
val read: Boolean,
|
||||||
|
|
||||||
|
/** chapter is bookmarked */
|
||||||
|
val bookmarked: Boolean,
|
||||||
|
|
||||||
|
/** last read page, zero means not read/no data */
|
||||||
|
val lastPageRead: Int,
|
||||||
|
|
||||||
|
/** this chapter's index, starts with 1 */
|
||||||
val chapterIndex: Int? = null,
|
val chapterIndex: Int? = null,
|
||||||
|
|
||||||
/** total chapter count, used to calculate if there's a next and prev chapter */
|
/** total chapter count, used to calculate if there's a next and prev chapter */
|
||||||
|
|||||||
Reference in New Issue
Block a user