mirror of
https://github.com/mihonapp/mihon.git
synced 2025-07-29 19:05:54 +02:00
Compare commits
4 Commits
399e689969
...
9be2e514d9
Author | SHA1 | Date | |
---|---|---|---|
9be2e514d9 | |||
71a7362aaa | |||
415124d20e | |||
ffcba7b2dc |
@ -1,6 +1,7 @@
|
||||
package eu.kanade.tachiyomi.ui.reader.loader
|
||||
|
||||
import android.content.Context
|
||||
import android.os.ParcelFileDescriptor.AutoCloseInputStream
|
||||
import com.github.junrar.exception.UnsupportedRarV5Exception
|
||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||
import eu.kanade.tachiyomi.data.download.DownloadProvider
|
||||
@ -105,7 +106,8 @@ class ChapterLoader(
|
||||
is Format.Directory -> DirectoryPageLoader(format.file)
|
||||
is Format.Zip -> ZipPageLoader(tempFileManager.createTempFile(format.file))
|
||||
is Format.SevenZip -> try {
|
||||
SevenZipPageLoader(tempFileManager.createTempFile(format.file)) {
|
||||
val file = context.contentResolver.openFileDescriptor(format.file.uri, "r")
|
||||
SevenZipPageLoader(AutoCloseInputStream(file)) {
|
||||
GlobalScope.launchUI {
|
||||
context.toast(context.stringResource(MR.strings.loader_7zip_slow_archives, it))
|
||||
}
|
||||
|
@ -4,17 +4,17 @@ import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||
import eu.kanade.tachiyomi.util.storage.SevenZUtil.getImages
|
||||
import org.apache.commons.compress.archivers.sevenz.SevenZFile
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
|
||||
/**
|
||||
* Loader used to load a chapter from a .7z or .cb7 file.
|
||||
*/
|
||||
internal class SevenZipPageLoader(
|
||||
private val file: File,
|
||||
private val file: FileInputStream,
|
||||
private val notifySlowArchive: (method: String) -> Unit,
|
||||
) : PageLoader() {
|
||||
|
||||
private val zip by lazy { SevenZFile(file) }
|
||||
private val zip by lazy { SevenZFile(file.channel) }
|
||||
|
||||
override var isLocal: Boolean = true
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package tachiyomi.source.local
|
||||
|
||||
import android.content.Context
|
||||
import android.os.ParcelFileDescriptor.AutoCloseInputStream
|
||||
import com.hippo.unifile.UniFile
|
||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
@ -343,9 +344,9 @@ actual class LocalSource(
|
||||
}
|
||||
}
|
||||
is Format.SevenZip -> {
|
||||
SevenZFile(tempFileManager.createTempFile(format.file)).use { archive ->
|
||||
val file = context.contentResolver.openFileDescriptor(format.file.uri, "r")
|
||||
SevenZFile(AutoCloseInputStream(file).channel).use { archive ->
|
||||
val entry = archive.getImages {}.firstOrNull()
|
||||
|
||||
entry?.let { coverManager.update(manga, it.inputStream()) }
|
||||
}
|
||||
}
|
||||
|
@ -14,13 +14,13 @@ sealed interface Format {
|
||||
|
||||
companion object {
|
||||
|
||||
fun valueOf(file: UniFile) = with(file) {
|
||||
when {
|
||||
isDirectory -> Directory(this)
|
||||
extension.equals("zip", true) || extension.equals("cbz", true) -> Zip(this)
|
||||
extension.equals("7z", true) || extension.equals("cb7", true) -> SevenZip(this)
|
||||
extension.equals("rar", true) || extension.equals("cbr", true) -> Rar(this)
|
||||
extension.equals("epub", true) -> Epub(this)
|
||||
fun valueOf(file: UniFile): Format {
|
||||
if (file.isDirectory) return Directory(file)
|
||||
return when (file.extension?.lowercase()) {
|
||||
"zip", "cbz" -> Zip(file)
|
||||
"7z", "cb7" -> SevenZip(file)
|
||||
"rar", "cbr" -> Rar(file)
|
||||
"epub" -> Epub(file)
|
||||
else -> throw UnknownFormatException()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user