Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -162,7 +162,9 @@ class SefariaDirectImporter(
val catId = ensureCategoryPath(payload.categoriesHe)
val bookId = nextBookId.getAndIncrement()
val bookPath = buildBookPath(payload.categoriesHe, payload.heTitle)
val bookOrder = bookOrders[payload.enTitle]?.toFloat() ?: 999f
val bookOrder = (bookOrders[payload.enTitle]
?: bookOrders[payload.heTitle]
?: bookOrders[sanitizeFolder(payload.heTitle)])?.toFloat() ?: 999f
val normalizedPath = normalizedBookPath(payload.categoriesHe, payload.heTitle)
val isBaseBook = normalizedPath in baseBookKeys

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import co.touchlab.kermit.Logger
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.contentOrNull
import kotlinx.serialization.json.doubleOrNull
import kotlinx.serialization.json.intOrNull
import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonObject
Expand Down Expand Up @@ -38,7 +39,10 @@ internal fun parseTableOfContentsOrders(
fun processTocItem(item: JsonObject, categoryPath: List<String> = emptyList()) {
val title = item["title"]?.jsonPrimitive?.contentOrNull
val heTitle = item["heTitle"]?.jsonPrimitive?.contentOrNull
// Use order if available, otherwise fall back to base_text_order (for commentaries)
val order = item["order"]?.jsonPrimitive?.intOrNull
?: item["base_text_order"]?.jsonPrimitive?.intOrNull
?: item["base_text_order"]?.jsonPrimitive?.doubleOrNull?.toInt()
if (title != null && order != null) {
bookOrders[title] = order
}
Expand Down