mirror of
https://github.com/gotson/komga.git
synced 2025-12-06 08:32:25 +01:00
parent
cd6b83d14d
commit
6553437e4a
7 changed files with 18 additions and 11 deletions
|
|
@ -39,8 +39,8 @@ import org.springframework.context.ApplicationEventPublisher
|
|||
import org.springframework.data.domain.Pageable
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.transaction.support.TransactionTemplate
|
||||
import org.springframework.web.util.UriUtils
|
||||
import java.io.File
|
||||
import java.net.URLDecoder
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZoneId
|
||||
import kotlin.io.path.deleteIfExists
|
||||
|
|
@ -489,7 +489,7 @@ class BookLifecycle(
|
|||
newProgression.locator.href
|
||||
.replaceAfter("#", "")
|
||||
.removeSuffix("#")
|
||||
.let { UriUtils.decode(it, Charsets.UTF_8) }
|
||||
.let { URLDecoder.decode(it, Charsets.UTF_8) }
|
||||
require(href in media.files.map { it.fileName }) { "Resource does not exist in book: $href" }
|
||||
requireNotNull(newProgression.locator.locations?.progression) { "location.progression is required" }
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import org.jsoup.Jsoup
|
|||
import org.jsoup.parser.Parser
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.web.util.UriUtils
|
||||
import java.net.URLDecoder
|
||||
import java.nio.file.Path
|
||||
import kotlin.io.path.Path
|
||||
import kotlin.io.path.deleteIfExists
|
||||
|
|
@ -91,7 +91,7 @@ class EpubExtractor(
|
|||
val pages =
|
||||
spine.map { page ->
|
||||
MediaFile(
|
||||
normalizeHref(epub.opfDir, UriUtils.decode(page.href, Charsets.UTF_8)),
|
||||
normalizeHref(epub.opfDir, URLDecoder.decode(page.href, Charsets.UTF_8)),
|
||||
page.mediaType,
|
||||
MediaFile.SubType.EPUB_PAGE,
|
||||
)
|
||||
|
|
@ -100,7 +100,7 @@ class EpubExtractor(
|
|||
val assets =
|
||||
epub.manifest.values.filterNot { spine.contains(it) }.map {
|
||||
MediaFile(
|
||||
normalizeHref(epub.opfDir, UriUtils.decode(it.href, Charsets.UTF_8)),
|
||||
normalizeHref(epub.opfDir, URLDecoder.decode(it.href, Charsets.UTF_8)),
|
||||
it.mediaType,
|
||||
MediaFile.SubType.EPUB_ASSET,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import org.gotson.komga.domain.model.EpubTocEntry
|
|||
import org.gotson.komga.infrastructure.util.getEntryBytes
|
||||
import org.jsoup.Jsoup
|
||||
import org.jsoup.nodes.Element
|
||||
import org.springframework.web.util.UriUtils
|
||||
import java.net.URLDecoder
|
||||
import java.nio.file.Path
|
||||
import kotlin.io.path.Path
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ private fun navLiElementToTocEntry(
|
|||
navDir: Path?,
|
||||
): EpubTocEntry? {
|
||||
val title = element.selectFirst(":root > a, span")?.text()
|
||||
val href = element.selectFirst(":root > a")?.attr("href")?.let { UriUtils.decode(it, Charsets.UTF_8) }
|
||||
val href = element.selectFirst(":root > a")?.attr("href")?.let { URLDecoder.decode(it, Charsets.UTF_8) }
|
||||
val children = element.select(":root > ol > li").mapNotNull { navLiElementToTocEntry(it, navDir) }
|
||||
if (title != null) return EpubTocEntry(title, href?.let { normalizeHref(navDir, it) }, children)
|
||||
return null
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import org.gotson.komga.domain.model.EpubTocEntry
|
|||
import org.gotson.komga.infrastructure.util.getEntryBytes
|
||||
import org.jsoup.Jsoup
|
||||
import org.jsoup.nodes.Element
|
||||
import org.springframework.web.util.UriUtils
|
||||
import java.net.URLDecoder
|
||||
import java.nio.file.Path
|
||||
import kotlin.io.path.Path
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ private fun ncxElementToTocEntry(
|
|||
ncxDir: Path?,
|
||||
): EpubTocEntry? {
|
||||
val title = element.selectFirst("navLabel > text")?.text()
|
||||
val href = element.selectFirst("content")?.attr("src")?.let { UriUtils.decode(it, Charsets.UTF_8) }
|
||||
val href = element.selectFirst("content")?.attr("src")?.let { URLDecoder.decode(it, Charsets.UTF_8) }
|
||||
val children = element.select(":root > ${navType.level2}").toList().mapNotNull { ncxElementToTocEntry(navType, it, ncxDir) }
|
||||
if (title != null) return EpubTocEntry(title, href?.let { normalizeHref(ncxDir, it) }, children)
|
||||
return null
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package org.gotson.komga.infrastructure.mediacontainer.epub
|
|||
|
||||
import org.gotson.komga.domain.model.EpubTocEntry
|
||||
import org.jsoup.nodes.Document
|
||||
import org.springframework.web.util.UriUtils
|
||||
import java.net.URLDecoder
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
import kotlin.io.path.invariantSeparatorsPathString
|
||||
|
|
@ -40,7 +40,7 @@ fun processOpfGuide(
|
|||
return guide.select("reference").map { ref ->
|
||||
EpubTocEntry(
|
||||
ref.attr("title"),
|
||||
ref.attr("href").ifBlank { null }?.let { normalizeHref(opfDir, UriUtils.decode(it, Charsets.UTF_8)) },
|
||||
ref.attr("href").ifBlank { null }?.let { normalizeHref(opfDir, URLDecoder.decode(it, Charsets.UTF_8)) },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ class NcxTest {
|
|||
),
|
||||
),
|
||||
EpubTocEntry("ACKNOWLEDGMENTS", "${prefix}Text/Mart_9780553897852_epub_ack_r1.htm"),
|
||||
EpubTocEntry("Omake 1: Ichika’s Q&A", "${prefix}Text/First Omake - Ichika’s Q&A.xhtml"),
|
||||
)
|
||||
|
||||
private fun getExpectedNcxPageList(prefix: String = "") =
|
||||
|
|
|
|||
|
|
@ -86,6 +86,12 @@
|
|||
</navLabel>
|
||||
<content src="Text/Mart_9780553897852_epub_ack_r1.htm"/>
|
||||
</navPoint>
|
||||
<navPoint id="navPoint-1" playOrder="1" class="chapter">
|
||||
<navLabel>
|
||||
<text>Omake 1: Ichika’s Q&A</text>
|
||||
</navLabel>
|
||||
<content src="Text/First%20Omake%20-%20Ichika’s%20Q%26A.xhtml"/>
|
||||
</navPoint>
|
||||
</navMap>
|
||||
<pageList>
|
||||
<pageTarget type="normal" id="id_cov" value="Cover Page">
|
||||
|
|
|
|||
Loading…
Reference in a new issue