Use custom mime discovery in downloader

This commit is contained in:
len
2017-02-02 20:21:38 +01:00
parent 56e7a1e2a0
commit 89940677cc
2 changed files with 18 additions and 21 deletions

View File

@@ -14,10 +14,7 @@ import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.source.online.fetchAllImageUrlsFromPageList
import eu.kanade.tachiyomi.util.DynamicConcurrentMergeOperator
import eu.kanade.tachiyomi.util.RetryWithDelay
import eu.kanade.tachiyomi.util.plusAssign
import eu.kanade.tachiyomi.util.saveTo
import eu.kanade.tachiyomi.util.*
import okhttp3.Response
import rx.Observable
import rx.android.schedulers.AndroidSchedulers
@@ -26,7 +23,6 @@ import rx.subjects.BehaviorSubject
import rx.subscriptions.CompositeSubscription
import timber.log.Timber
import uy.kohesive.injekt.injectLazy
import java.net.URLConnection
/**
* This class is the one in charge of downloading chapters.
@@ -407,9 +403,7 @@ class Downloader(private val context: Context, private val provider: DownloadPro
// Else guess from the uri.
?: context.contentResolver.getType(file.uri)
// Else read magic numbers.
?: file.openInputStream().buffered().use {
URLConnection.guessContentTypeFromStream(it)
}
?: DiskUtil.findImageMime { file.openInputStream() }
return MimeTypeMap.getSingleton().getExtensionFromMimeType(mime) ?: "jpg"
}