mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
small fix
This commit is contained in:
parent
9b4701fe91
commit
1a4cbcaea0
2 changed files with 24 additions and 7 deletions
|
@ -591,7 +591,7 @@ class ResultViewModel2 : ViewModel() {
|
|||
link,
|
||||
"$fileName ${link.name}",
|
||||
folder,
|
||||
if (link.url.contains(".srt")) ".srt" else "vtt",
|
||||
if (link.url.contains(".srt")) "srt" else "vtt",
|
||||
false,
|
||||
null, createNotificationCallback = {}
|
||||
)
|
||||
|
@ -719,7 +719,7 @@ class ResultViewModel2 : ViewModel() {
|
|||
)
|
||||
)
|
||||
}
|
||||
.map { ExtractorSubtitleLink(it.name, it.url, "") }
|
||||
.map { ExtractorSubtitleLink(it.name, it.url, "") }.take(3)
|
||||
.forEach { link ->
|
||||
val fileName = VideoDownloadManager.getFileName(context, meta)
|
||||
downloadSubtitle(context, link, fileName, folder)
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.hippo.unifile.UniRandomAccessFile
|
|||
import com.lagradost.cloudstream3.mvvm.logError
|
||||
import okhttp3.internal.closeQuietly
|
||||
import java.io.File
|
||||
import java.io.FileNotFoundException
|
||||
import java.io.InputStream
|
||||
import java.io.OutputStream
|
||||
|
||||
|
@ -65,6 +66,10 @@ class MediaFile(
|
|||
private val external: Boolean = true,
|
||||
absolutePath: String,
|
||||
) : SafeFile {
|
||||
override fun toString(): String {
|
||||
return sanitizedAbsolutePath
|
||||
}
|
||||
|
||||
// this is the path relative to the download directory so "/hello/text.txt" = "hello/text.txt" is in fact "Download/hello/text.txt"
|
||||
private val sanitizedAbsolutePath: String =
|
||||
replaceDuplicateFileSeparators(absolutePath)
|
||||
|
@ -246,8 +251,20 @@ class MediaFile(
|
|||
|
||||
override fun length(): Long? {
|
||||
if (isDir) return null
|
||||
val length = query()?.length ?: return null
|
||||
val query = query()
|
||||
val length = query?.length ?: return null
|
||||
if (length <= 0) {
|
||||
try {
|
||||
contentResolver.openFileDescriptor(query.uri, "r")
|
||||
.use {
|
||||
it?.statSize
|
||||
}?.let {
|
||||
return it
|
||||
}
|
||||
} catch (e: FileNotFoundException) {
|
||||
return null
|
||||
}
|
||||
|
||||
val inputStream: InputStream = openInputStream() ?: return null
|
||||
return try {
|
||||
inputStream.available().toLong()
|
||||
|
|
Loading…
Reference in a new issue