|
|
|
@ -117,7 +117,7 @@ class DownloadManager @AssistedInject constructor(
|
|
|
|
val data = if (manga.chapters.isNullOrEmpty()) repo.getDetails(manga) else manga
|
|
|
|
val data = if (manga.chapters.isNullOrEmpty()) repo.getDetails(manga) else manga
|
|
|
|
output = CbzMangaOutput.get(destination, data)
|
|
|
|
output = CbzMangaOutput.get(destination, data)
|
|
|
|
val coverUrl = data.largeCoverUrl ?: data.coverUrl
|
|
|
|
val coverUrl = data.largeCoverUrl ?: data.coverUrl
|
|
|
|
downloadFile(coverUrl, data.publicUrl, destination, tempFileName, repo.source).let { file ->
|
|
|
|
downloadFile(coverUrl, destination, tempFileName, repo.source).let { file ->
|
|
|
|
output.addCover(file, MimeTypeMap.getFileExtensionFromUrl(coverUrl))
|
|
|
|
output.addCover(file, MimeTypeMap.getFileExtensionFromUrl(coverUrl))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
val chapters = checkNotNull(
|
|
|
|
val chapters = checkNotNull(
|
|
|
|
@ -139,7 +139,7 @@ class DownloadManager @AssistedInject constructor(
|
|
|
|
runFailsafe(outState, pausingHandle) {
|
|
|
|
runFailsafe(outState, pausingHandle) {
|
|
|
|
val url = repo.getPageUrl(page)
|
|
|
|
val url = repo.getPageUrl(page)
|
|
|
|
val file = cache.get(url)
|
|
|
|
val file = cache.get(url)
|
|
|
|
?: downloadFile(url, page.referer, destination, tempFileName, repo.source)
|
|
|
|
?: downloadFile(url, destination, tempFileName, repo.source)
|
|
|
|
output.addPage(
|
|
|
|
output.addPage(
|
|
|
|
chapter = chapter,
|
|
|
|
chapter = chapter,
|
|
|
|
file = file,
|
|
|
|
file = file,
|
|
|
|
@ -211,14 +211,12 @@ class DownloadManager @AssistedInject constructor(
|
|
|
|
|
|
|
|
|
|
|
|
private suspend fun downloadFile(
|
|
|
|
private suspend fun downloadFile(
|
|
|
|
url: String,
|
|
|
|
url: String,
|
|
|
|
referer: String,
|
|
|
|
|
|
|
|
destination: File,
|
|
|
|
destination: File,
|
|
|
|
tempFileName: String,
|
|
|
|
tempFileName: String,
|
|
|
|
source: MangaSource,
|
|
|
|
source: MangaSource,
|
|
|
|
): File {
|
|
|
|
): File {
|
|
|
|
val request = Request.Builder()
|
|
|
|
val request = Request.Builder()
|
|
|
|
.url(url)
|
|
|
|
.url(url)
|
|
|
|
.header(CommonHeaders.REFERER, referer)
|
|
|
|
|
|
|
|
.tag(MangaSource::class.java, source)
|
|
|
|
.tag(MangaSource::class.java, source)
|
|
|
|
.cacheControl(CommonHeaders.CACHE_CONTROL_DISABLED)
|
|
|
|
.cacheControl(CommonHeaders.CACHE_CONTROL_DISABLED)
|
|
|
|
.get()
|
|
|
|
.get()
|
|
|
|
|