fuck downloads

This commit is contained in:
LagradOst 2021-07-05 02:55:07 +02:00
parent 728874fc03
commit 98185c0763
3 changed files with 22 additions and 4 deletions

View file

@ -625,12 +625,12 @@ activity?.startActivityForResult(vlcIntent, REQUEST_CODE)
if (castContext.castState == CastState.CONNECTED) { if (castContext.castState == CastState.CONNECTED) {
handleAction(EpisodeClickEvent(ACTION_CHROME_CAST_EPISODE, card)) handleAction(EpisodeClickEvent(ACTION_CHROME_CAST_EPISODE, card))
} else { } else {
handleAction(EpisodeClickEvent(ACTION_DOWNLOAD_EPISODE, card)) handleAction(EpisodeClickEvent(ACTION_PLAY_EPISODE_IN_PLAYER, card))
} }
} else { } else {
handleAction( handleAction(
EpisodeClickEvent( EpisodeClickEvent(
ACTION_DOWNLOAD_EPISODE, ACTION_PLAY_EPISODE_IN_PLAYER,
card card
) )
) //TODO REDO TO MAIN ) //TODO REDO TO MAIN

View file

@ -148,7 +148,7 @@ class SearchFragment : Fragment() {
allApi.providersActive = requireActivity().getApiSettings() allApi.providersActive = requireActivity().getApiSettings()
//searchViewModel.search("iron man") //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() (requireActivity() as AppCompatActivity).supportFragmentManager.beginTransaction()
.setCustomAnimations(R.anim.enter_anim, .setCustomAnimations(R.anim.enter_anim,

View file

@ -3,11 +3,13 @@ package com.lagradost.cloudstream3.utils
import android.app.NotificationChannel import android.app.NotificationChannel
import android.app.NotificationManager import android.app.NotificationManager
import android.app.PendingIntent import android.app.PendingIntent
import android.content.ContentValues
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.graphics.Bitmap import android.graphics.Bitmap
import android.os.Build import android.os.Build
import android.os.Environment import android.os.Environment
import android.provider.MediaStore
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat import androidx.core.app.NotificationManagerCompat
@ -329,9 +331,25 @@ object VideoDownloadManager {
link: ExtractorLink link: ExtractorLink
): Int { ): Int {
val name = sanitizeFilename(ep.name ?: "Episode ${ep.episode}") 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 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 RESUME, DON'T DELETE FILE, CONTINUE, RECREATE IF NOT FOUND
// IF NOT RESUME CREATE FILE // IF NOT RESUME CREATE FILE
val tempFile = DocumentFileCompat.fromSimplePath(context, basePath = path) val tempFile = DocumentFileCompat.fromSimplePath(context, basePath = path)