mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-29 09:39:03 +03:00
fix downloading to sdcard (again)
This commit is contained in:
parent
0e984df7df
commit
0316f3ab67
2 changed files with 13 additions and 6 deletions
|
@ -496,11 +496,13 @@ class AnimeDownloader(
|
|||
return video.videoUrl?.toHttpUrl()?.encodedPath?.endsWith(".m3u8") ?: false
|
||||
}
|
||||
|
||||
private fun hlsObservable(video: Video, source: AnimeHttpSource, tmpDir: UniFile, filename: String): Observable<UniFile> {
|
||||
private fun hlsObservable(video: Video, download: AnimeDownload, tmpDir: UniFile, filename: String): Observable<UniFile> {
|
||||
isFFmpegRunning = true
|
||||
val headers = video.headers ?: source.headers
|
||||
val headers = video.headers ?: download.source.headers
|
||||
val headerOptions = headers.joinToString("", "-headers '", "'") { "${it.first}: ${it.second}\r\n" }
|
||||
val ffmpegFilename = { "${tmpDir.filePath}/$filename.mp4".toFFmpegString(context) }
|
||||
val videoFile = tmpDir.findFile("$filename.mp4")
|
||||
?: tmpDir.createFile("$filename.mp4")!!
|
||||
val ffmpegFilename = { videoFile.uri.toFFmpegString(context) }
|
||||
val ffmpegOptions = FFmpegKitConfig.parseArguments(headerOptions + " -i '${video.videoUrl}' -c copy \"${ffmpegFilename()}\"")
|
||||
val ffprobeCommand = { file: String, ffprobeHeaders: String? ->
|
||||
FFmpegKitConfig.parseArguments("${ffprobeHeaders?.plus(" ") ?: ""}-v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 \"$file\"")
|
||||
|
@ -564,7 +566,7 @@ class AnimeDownloader(
|
|||
}
|
||||
|
||||
private fun newObservable(video: Video, download: AnimeDownload, tmpDir: UniFile, filename: String): Observable<UniFile> {
|
||||
return if (isHls(video)) hlsObservable(video, download.source, tmpDir, filename)
|
||||
return if (isHls(video)) hlsObservable(video, download, tmpDir, filename)
|
||||
else download.source.fetchVideo(video)
|
||||
.map { response ->
|
||||
val file = tmpDir.findFile("$filename.tmp") ?: tmpDir.createFile("$filename.tmp")
|
||||
|
|
|
@ -1,14 +1,19 @@
|
|||
package eu.kanade.tachiyomi.util.storage
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import com.arthenica.ffmpegkit.FFmpegKitConfig
|
||||
import java.io.File
|
||||
|
||||
fun String.toFFmpegString(context: Context): String {
|
||||
return File(this).getUriCompat(context).toFFmpegString(context)
|
||||
}
|
||||
|
||||
fun Uri.toFFmpegString(context: Context): String {
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
FFmpegKitConfig.getSafParameter(context, File(this).getUriCompat(context), "rw")
|
||||
FFmpegKitConfig.getSafParameter(context, this, "rw")
|
||||
} else {
|
||||
File(this).getUriCompat(context).path!!
|
||||
this.path!!
|
||||
}.replace("\"", "\\\"")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue