Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle updates through merged chapters #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Comment on lines 515 to +518
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@majora2007 we sure there won't ever be other underscores apart from the salt one we add, right? Otherwise seems fine.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the url map to? A special can technically have _ in the name.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

url is defined as url = chapter.id.toString().

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So maybe I missed it, how is the underscore being sent?

Copy link
Author

@Zehkul Zehkul Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s not, I’m adding it locally.
<chapterId>_<numberOfFiles>
As ThePromidius points out, this approach would fail if the id somehow already contains an underscore.

}

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>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)