mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
fuck downloads
This commit is contained in:
parent
728874fc03
commit
98185c0763
3 changed files with 22 additions and 4 deletions
|
@ -625,12 +625,12 @@ activity?.startActivityForResult(vlcIntent, REQUEST_CODE)
|
|||
if (castContext.castState == CastState.CONNECTED) {
|
||||
handleAction(EpisodeClickEvent(ACTION_CHROME_CAST_EPISODE, card))
|
||||
} else {
|
||||
handleAction(EpisodeClickEvent(ACTION_DOWNLOAD_EPISODE, card))
|
||||
handleAction(EpisodeClickEvent(ACTION_PLAY_EPISODE_IN_PLAYER, card))
|
||||
}
|
||||
} else {
|
||||
handleAction(
|
||||
EpisodeClickEvent(
|
||||
ACTION_DOWNLOAD_EPISODE,
|
||||
ACTION_PLAY_EPISODE_IN_PLAYER,
|
||||
card
|
||||
)
|
||||
) //TODO REDO TO MAIN
|
||||
|
|
|
@ -148,7 +148,7 @@ class SearchFragment : Fragment() {
|
|||
allApi.providersActive = requireActivity().getApiSettings()
|
||||
|
||||
//searchViewModel.search("iron man")
|
||||
//(activity as AppCompatActivity).loadResult("https://shiro.is/overlord-dubbed", "overlord-dubbed", "Shiro")
|
||||
(activity as AppCompatActivity).loadResult("https://shiro.is/overlord-dubbed", "overlord-dubbed", "Shiro")
|
||||
/*
|
||||
(requireActivity() as AppCompatActivity).supportFragmentManager.beginTransaction()
|
||||
.setCustomAnimations(R.anim.enter_anim,
|
||||
|
|
|
@ -3,11 +3,13 @@ package com.lagradost.cloudstream3.utils
|
|||
import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.app.PendingIntent
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Bitmap
|
||||
import android.os.Build
|
||||
import android.os.Environment
|
||||
import android.provider.MediaStore
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.core.app.NotificationManagerCompat
|
||||
|
@ -329,9 +331,25 @@ object VideoDownloadManager {
|
|||
link: ExtractorLink
|
||||
): Int {
|
||||
val name = sanitizeFilename(ep.name ?: "Episode ${ep.episode}")
|
||||
val path = "${Environment.DIRECTORY_DOWNLOADS}/${if (folder == null) "" else "$folder/"}$name.mp4"
|
||||
val path = "${if (folder == null) "" else "$folder/"}$name.mp4" //${Environment.DIRECTORY_DOWNLOADS}/
|
||||
var resume = false
|
||||
|
||||
|
||||
val collection = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
MediaStore.Downloads.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY)
|
||||
|
||||
} else {
|
||||
TODO("VERSION.SDK_INT < Q")
|
||||
}
|
||||
|
||||
val newFile = ContentValues().apply {
|
||||
put(MediaStore.Downloads.DISPLAY_NAME, "$name.mp4")
|
||||
// put(MediaStore.Downloads.RELATIVE_PATH, if (folder == null) "" else "$folder")
|
||||
}
|
||||
val newFileUri = context.contentResolver.insert(collection, newFile) ?: throw Exception("FUCK YOU")
|
||||
val outputStream = context.contentResolver.openOutputStream(newFileUri, "w")
|
||||
?: throw Exception("ContentResolver couldn't open $newFileUri outputStream")
|
||||
return 0
|
||||
// IF RESUME, DON'T DELETE FILE, CONTINUE, RECREATE IF NOT FOUND
|
||||
// IF NOT RESUME CREATE FILE
|
||||
val tempFile = DocumentFileCompat.fromSimplePath(context, basePath = path)
|
||||
|
|
Loading…
Reference in a new issue