Refactor as requested
This commit is contained in:
@@ -8,7 +8,7 @@ pref_group_tags_summary_on=Will prefix tags with their type
|
|||||||
pref_group_tags_summary_off=List all tags together
|
pref_group_tags_summary_off=List all tags together
|
||||||
pref_last_volume_cover_title=Keep cover updated
|
pref_last_volume_cover_title=Keep cover updated
|
||||||
pref_last_volume_cover_summary_off=Keep current cover
|
pref_last_volume_cover_summary_off=Keep current cover
|
||||||
pref_last_volume_cover_summary_on=Update cover to current Volume/Issue
|
pref_last_volume_cover_summary_on=Always show current Volume/Issue cover on refresh
|
||||||
pref_show_epub_title=Show EPUB (EPUB can't be read in Mihon)
|
pref_show_epub_title=Show EPUB (EPUB can't be read in Mihon)
|
||||||
pref_show_epub_summary_off=Hide EPUB titles in browsing
|
pref_show_epub_summary_off=Hide EPUB titles in browsing
|
||||||
pref_show_epub_summary_on=Show EPUB titles in browsing
|
pref_show_epub_summary_on=Show EPUB titles in browsing
|
||||||
|
|||||||
@@ -162,8 +162,6 @@ class Kavita(private val suffix: String = "") : ConfigurableSource, UnmeteredSou
|
|||||||
|
|
||||||
// Fallback - use original URL if we don't recognize the pattern
|
// Fallback - use original URL if we don't recognize the pattern
|
||||||
else -> manga.url
|
else -> manga.url
|
||||||
}.also { url ->
|
|
||||||
// Log.d(LOG_TAG, "Generated webview URL: $url (tracking URL: ${manga.url})")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,11 +178,10 @@ class Kavita(private val suffix: String = "") : ConfigurableSource, UnmeteredSou
|
|||||||
return client.newCall(request)
|
return client.newCall(request)
|
||||||
.asObservableSuccess()
|
.asObservableSuccess()
|
||||||
.onErrorResumeNext { throwable ->
|
.onErrorResumeNext { throwable ->
|
||||||
// Get Http code
|
|
||||||
val field = throwable.javaClass.getDeclaredField("code")
|
val field = throwable.javaClass.getDeclaredField("code")
|
||||||
field.isAccessible = true // Make the field accessible
|
field.isAccessible = true
|
||||||
try {
|
try {
|
||||||
var code = field.get(throwable) // Get the value of the code property
|
var code = field.get(throwable)
|
||||||
Log.e(LOG_TAG, "Error fetching manga: ${throwable.message}", throwable)
|
Log.e(LOG_TAG, "Error fetching manga: ${throwable.message}", throwable)
|
||||||
if (code as Int !in intArrayOf(401, 201, 500)) {
|
if (code as Int !in intArrayOf(401, 201, 500)) {
|
||||||
code = 500
|
code = 500
|
||||||
@@ -351,13 +348,13 @@ class Kavita(private val suffix: String = "") : ConfigurableSource, UnmeteredSou
|
|||||||
name = buildString {
|
name = buildString {
|
||||||
append("${item.order + 1}. ")
|
append("${item.order + 1}. ")
|
||||||
when {
|
when {
|
||||||
!item.chapterTitleName.isNullOrBlank() && !item.chapterTitleName.matches(Regex("^\\d+\$")) -> {
|
!item.chapterTitleName.isNullOrBlank() && !item.chapterTitleName.matches(Regex("^\\d+$")) -> {
|
||||||
append(item.chapterTitleName)
|
append(item.chapterTitleName)
|
||||||
}
|
}
|
||||||
!item.volumeNumber.isNullOrBlank() && item.volumeNumber != "-100000" -> {
|
!item.volumeNumber.isNullOrBlank() && item.volumeNumber != UNNUMBERED_VOLUME_STR -> {
|
||||||
append("Volume ${item.volumeNumber.padStart(2, '0')}")
|
append("Volume ${item.volumeNumber.padStart(2, '0')}")
|
||||||
}
|
}
|
||||||
!item.chapterNumber.isNullOrBlank() && item.chapterNumber != "-100000" -> {
|
!item.chapterNumber.isNullOrBlank() && item.chapterNumber != UNNUMBERED_VOLUME_STR -> {
|
||||||
val libraryType = getLibraryType(item.seriesId)
|
val libraryType = getLibraryType(item.seriesId)
|
||||||
when (libraryType) {
|
when (libraryType) {
|
||||||
LibraryTypeEnum.Comic, LibraryTypeEnum.ComicVine ->
|
LibraryTypeEnum.Comic, LibraryTypeEnum.ComicVine ->
|
||||||
@@ -905,7 +902,6 @@ class Kavita(private val suffix: String = "") : ConfigurableSource, UnmeteredSou
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
manga.apply {
|
manga.apply {
|
||||||
// description = helper.intl["error_reading_list_not_found"]
|
|
||||||
initialized = true
|
initialized = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1024,21 +1020,17 @@ class Kavita(private val suffix: String = "") : ConfigurableSource, UnmeteredSou
|
|||||||
val coverCandidates = mutableListOf<Triple<String, Boolean, Float>>()
|
val coverCandidates = mutableListOf<Triple<String, Boolean, Float>>()
|
||||||
|
|
||||||
for (volume in volumes) {
|
for (volume in volumes) {
|
||||||
if (isComicLibrary && volume.number == -100000) {
|
|
||||||
// Issue: use chapter covers
|
// Issue: use chapter covers
|
||||||
for (chapter in volume.chapters) {
|
if (isComicLibrary && volume.number == UNNUMBERED_VOLUME) {
|
||||||
if (!chapter.coverImage.isNullOrBlank()) {
|
coverCandidates += volume.chapters
|
||||||
val isUnread = chapter.pagesRead < chapter.pages
|
.filterNot { it.coverImage.isNullOrBlank() }
|
||||||
val sortKey = chapter.number.toFloatOrNull() ?: 0f
|
.map { chapter ->
|
||||||
coverCandidates.add(
|
|
||||||
Triple(
|
Triple(
|
||||||
"$apiUrl/Image/chapter-cover?chapterId=${chapter.id}&apiKey=$apiKey",
|
"$apiUrl/Image/chapter-cover?chapterId=${chapter.id}&apiKey=$apiKey",
|
||||||
isUnread,
|
chapter.pagesRead < chapter.pages,
|
||||||
sortKey,
|
chapter.number.toFloatOrNull() ?: 0f,
|
||||||
),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else if (!isComicLibrary) {
|
} else if (!isComicLibrary) {
|
||||||
// Manga: use volume cover if it has a SingleFileVolume chapter
|
// Manga: use volume cover if it has a SingleFileVolume chapter
|
||||||
val hasSingleFile = volume.chapters.any { chapter ->
|
val hasSingleFile = volume.chapters.any { chapter ->
|
||||||
@@ -1250,24 +1242,6 @@ class Kavita(private val suffix: String = "") : ConfigurableSource, UnmeteredSou
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// override fun chapterListParse(response: Response): List<SChapter> {
|
|
||||||
// try {
|
|
||||||
// val volumes = response.parseAs<List<VolumeDto>>()
|
|
||||||
// val allChapterList = mutableListOf<SChapter>()
|
|
||||||
// volumes.forEach { volume ->
|
|
||||||
// // Add all chapters from each volume as individual SChapter
|
|
||||||
// volume.chapters.forEach { chapter ->
|
|
||||||
// allChapterList.add(helper.chapterFromVolume(chapter, volume))
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// allChapterList.sortWith(KavitaHelper.CompareChapters)
|
|
||||||
// return allChapterList
|
|
||||||
// } catch (e: Exception) {
|
|
||||||
// Log.e(LOG_TAG, "Unhandled exception parsing chapters. Send logs to kavita devs", e)
|
|
||||||
// throw IOException(helper.intl["version_exceptions_chapters_parse"])
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
override fun chapterListParse(response: Response): List<SChapter> {
|
override fun chapterListParse(response: Response): List<SChapter> {
|
||||||
try {
|
try {
|
||||||
val seriesId = response.request.url.queryParameter("seriesId")?.toIntOrNull()
|
val seriesId = response.request.url.queryParameter("seriesId")?.toIntOrNull()
|
||||||
@@ -1872,6 +1846,9 @@ class Kavita(private val suffix: String = "") : ConfigurableSource, UnmeteredSou
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
private const val UNNUMBERED_VOLUME = -100000
|
||||||
|
private const val UNNUMBERED_VOLUME_STR = "-100000"
|
||||||
|
|
||||||
private const val ADDRESS_TITLE = "Address"
|
private const val ADDRESS_TITLE = "Address"
|
||||||
private val JSON_MEDIA_TYPE = "application/json; charset=utf-8".toMediaTypeOrNull()
|
private val JSON_MEDIA_TYPE = "application/json; charset=utf-8".toMediaTypeOrNull()
|
||||||
|
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ class KavitaHelper {
|
|||||||
} catch (e: NumberFormatException) {
|
} catch (e: NumberFormatException) {
|
||||||
0f
|
0f
|
||||||
}
|
}
|
||||||
-volumeNum - 100000f
|
-volumeNum - VOLUME_NUMBER_OFFSET
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,4 +174,8 @@ class KavitaHelper {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val VOLUME_NUMBER_OFFSET = 100000f
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user