Recognize merged part-chapters as new chapters

For example:
ch2 1.zip
ch2 2.zip
Kavita will merge these into one big ch2.
Recognize and handle chapter merges.
This commit is contained in:
zehkul
2024-10-30 21:26:01 +01:00
parent d16187172a
commit 43ba7c84f7
3 changed files with 21 additions and 2 deletions

View File

@@ -513,11 +513,14 @@ class Kavita(private val suffix: String = "") : ConfigurableSource, UnmeteredSou
* Fetches the "url" of each page from the chapter
* **/
override fun pageListRequest(chapter: SChapter): Request {
return GET("$apiUrl/${chapter.url}", headersBuilder().build())
// remove potential _<part> chapter salt
val chapterId = chapter.url.substringBefore("_")
return GET("$apiUrl/$chapterId", headersBuilder().build())
}
override fun fetchPageList(chapter: SChapter): Observable<List<Page>> {
val chapterId = chapter.url
// remove potential _<part> chapter salt
val chapterId = chapter.url.substringBefore("_")
val numPages = chapter.scanlator?.replace(" pages", "")?.toInt()
val numPages2 = "$numPages".toInt() - 1
val pages = mutableListOf<Page>()

View File

@@ -98,6 +98,13 @@ class KavitaHelper {
}
url = chapter.id.toString()
if (chapter.fileCount > 1) {
// salt/offset to recognize chapters with new merged part-chapters as new and hence unread
chapter_number += 0.001f * chapter.fileCount
url = "${url}_${chapter.fileCount}"
}
date_upload = parseDate(chapter.created)
scanlator = "${chapter.pages} pages"
}

View File

@@ -123,4 +123,13 @@ data class ChapterDto(
val coverImageLocked: Boolean,
val volumeId: Int,
val created: String,
val files: List<FileDto>? = null,
) {
val fileCount: Int
get() = files?.size ?: 0
}
@Serializable
data class FileDto(
val id: Int,
)