forked from recloudstream/cloudstream
shit not working due to android storage fuckery
This commit is contained in:
parent
45ea1a8d8e
commit
572aa6de3e
14 changed files with 134 additions and 95 deletions
|
@ -201,7 +201,7 @@ dependencies {
|
||||||
implementation 'me.xdrop:fuzzywuzzy:1.4.0'
|
implementation 'me.xdrop:fuzzywuzzy:1.4.0'
|
||||||
|
|
||||||
// aria2c downloader
|
// aria2c downloader
|
||||||
implementation 'com.github.LagradOst:Aria2cButton:v0.0.3'
|
implementation 'com.github.LagradOst:Aria2cButton:v0.0.4'
|
||||||
}
|
}
|
||||||
|
|
||||||
task androidSourcesJar(type: Jar) {
|
task androidSourcesJar(type: Jar) {
|
||||||
|
|
|
@ -137,9 +137,9 @@ object CommonActivity {
|
||||||
Aria2Starter.start(
|
Aria2Starter.start(
|
||||||
act,
|
act,
|
||||||
Aria2Settings(
|
Aria2Settings(
|
||||||
UUID.randomUUID().toString(),
|
"1337", //UUID.randomUUID().toString()
|
||||||
4337,
|
4337,
|
||||||
act.filesDir.path,
|
"/storage/emulated/0/Download",// act.filesDir.path,
|
||||||
"${act.filesDir.path}/session"
|
"${act.filesDir.path}/session"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
|
import com.google.android.material.button.MaterialButton
|
||||||
import com.lagradost.cloudstream3.R
|
import com.lagradost.cloudstream3.R
|
||||||
import com.lagradost.fetchbutton.aria2c.DownloadStatusTell
|
import com.lagradost.fetchbutton.aria2c.DownloadStatusTell
|
||||||
import com.lagradost.fetchbutton.aria2c.Metadata
|
import com.lagradost.fetchbutton.aria2c.Metadata
|
||||||
|
@ -14,10 +15,22 @@ class DownloadButton(context: Context, attributeSet: AttributeSet) :
|
||||||
|
|
||||||
var progressText: TextView? = null
|
var progressText: TextView? = null
|
||||||
var mainText: TextView? = null
|
var mainText: TextView? = null
|
||||||
override fun onAttachedToWindow() {
|
var bigButton: MaterialButton? = null
|
||||||
super.onAttachedToWindow()
|
|
||||||
|
override fun onInflate() {
|
||||||
|
overrideLayout = R.layout.download_button_layout
|
||||||
|
super.onInflate()
|
||||||
progressText = findViewById(R.id.result_movie_download_text_precentage)
|
progressText = findViewById(R.id.result_movie_download_text_precentage)
|
||||||
mainText = findViewById(R.id.result_movie_download_text)
|
mainText = findViewById(R.id.result_movie_download_text)
|
||||||
|
bigButton = findViewById(R.id.download_big_button)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setOnClickListener(l: OnClickListener?) {
|
||||||
|
bigButton?.setOnClickListener(l)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setOnLongClickListener(l: OnLongClickListener?) {
|
||||||
|
bigButton?.setOnLongClickListener(l)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setStatus(status: DownloadStatusTell?) {
|
override fun setStatus(status: DownloadStatusTell?) {
|
||||||
|
|
|
@ -1,12 +1,17 @@
|
||||||
package com.lagradost.cloudstream3.ui.result
|
package com.lagradost.cloudstream3.ui.result
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.widget.Toast
|
||||||
|
import com.lagradost.cloudstream3.CommonActivity.showToast
|
||||||
import com.lagradost.cloudstream3.R
|
import com.lagradost.cloudstream3.R
|
||||||
import com.lagradost.cloudstream3.ui.download.DOWNLOAD_ACTION_DOWNLOAD
|
import com.lagradost.cloudstream3.ui.download.DOWNLOAD_ACTION_DOWNLOAD
|
||||||
|
import com.lagradost.cloudstream3.ui.download.DOWNLOAD_ACTION_LONG_CLICK
|
||||||
import com.lagradost.cloudstream3.ui.download.DownloadEpisodeClickEvent
|
import com.lagradost.cloudstream3.ui.download.DownloadEpisodeClickEvent
|
||||||
import com.lagradost.cloudstream3.ui.player.DownloadFileGenerator
|
import com.lagradost.cloudstream3.ui.player.DownloadFileGenerator
|
||||||
import com.lagradost.cloudstream3.utils.ExtractorUri
|
import com.lagradost.cloudstream3.utils.ExtractorUri
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.popupMenuNoIcons
|
import com.lagradost.cloudstream3.utils.UIHelper.popupMenuNoIcons
|
||||||
|
import com.lagradost.fetchbutton.aria2c.Aria2Starter
|
||||||
import com.lagradost.fetchbutton.aria2c.DownloadStatusTell
|
import com.lagradost.fetchbutton.aria2c.DownloadStatusTell
|
||||||
import com.lagradost.fetchbutton.ui.PieFetchButton
|
import com.lagradost.fetchbutton.ui.PieFetchButton
|
||||||
|
|
||||||
|
@ -39,9 +44,17 @@ object DownloadHelper {
|
||||||
downloadClickCallback: (DownloadEpisodeClickEvent) -> Unit
|
downloadClickCallback: (DownloadEpisodeClickEvent) -> Unit
|
||||||
) {
|
) {
|
||||||
setPersistentId(card.id.toLong())
|
setPersistentId(card.id.toLong())
|
||||||
|
val play = if (card.episode <= 0) R.string.play_movie_button else R.string.play_episode
|
||||||
|
|
||||||
setOnClickListener { view ->
|
setOnLongClickListener { //Aria2Starter.saveActivity.get()
|
||||||
if (view !is PieFetchButton) return@setOnClickListener
|
downloadClickCallback.invoke(DownloadEpisodeClickEvent(DOWNLOAD_ACTION_LONG_CLICK, card))
|
||||||
|
//showToast(it.context as? Activity, R.string.download, Toast.LENGTH_SHORT)
|
||||||
|
return@setOnLongClickListener true
|
||||||
|
}
|
||||||
|
|
||||||
|
setOnClickListener {
|
||||||
|
val view = this
|
||||||
|
//if (view !is PieFetchButton) return@setOnClickListener
|
||||||
when (view.currentStatus) {
|
when (view.currentStatus) {
|
||||||
null, DownloadStatusTell.Removed -> {
|
null, DownloadStatusTell.Removed -> {
|
||||||
view.setStatus(DownloadStatusTell.Waiting)
|
view.setStatus(DownloadStatusTell.Waiting)
|
||||||
|
@ -56,7 +69,7 @@ object DownloadHelper {
|
||||||
view.popupMenuNoIcons(
|
view.popupMenuNoIcons(
|
||||||
listOf(
|
listOf(
|
||||||
1 to R.string.resume,
|
1 to R.string.resume,
|
||||||
2 to R.string.play_episode,
|
2 to play,
|
||||||
3 to R.string.delete
|
3 to R.string.delete
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
|
@ -69,29 +82,21 @@ object DownloadHelper {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
2 -> {
|
2 -> play(card)
|
||||||
play(card)
|
3 -> view.deleteAllFiles()
|
||||||
}
|
|
||||||
3 -> {
|
|
||||||
view.deleteAllFiles()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DownloadStatusTell.Complete -> {
|
DownloadStatusTell.Complete -> {
|
||||||
view.popupMenuNoIcons(
|
view.popupMenuNoIcons(
|
||||||
listOf(
|
listOf(
|
||||||
2 to R.string.play_episode,
|
2 to play,
|
||||||
3 to R.string.delete
|
3 to R.string.delete
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
when (itemId) {
|
when (itemId) {
|
||||||
2 -> {
|
2 -> play(card)
|
||||||
play(card)
|
3 -> view.deleteAllFiles()
|
||||||
}
|
|
||||||
3 -> {
|
|
||||||
view.deleteAllFiles()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,20 +104,14 @@ object DownloadHelper {
|
||||||
view.popupMenuNoIcons(
|
view.popupMenuNoIcons(
|
||||||
listOf(
|
listOf(
|
||||||
4 to R.string.pause,
|
4 to R.string.pause,
|
||||||
2 to R.string.play_episode,
|
2 to play,
|
||||||
3 to R.string.delete
|
3 to R.string.delete
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
when (itemId) {
|
when (itemId) {
|
||||||
4 -> {
|
4 -> view.pauseDownload()
|
||||||
view.pauseDownload()
|
2 -> play(card)
|
||||||
}
|
3 -> view.deleteAllFiles()
|
||||||
2 -> {
|
|
||||||
play(card)
|
|
||||||
}
|
|
||||||
3 -> {
|
|
||||||
view.deleteAllFiles()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,28 +34,32 @@ import com.lagradost.cloudstream3.TvType
|
||||||
import com.lagradost.cloudstream3.mvvm.*
|
import com.lagradost.cloudstream3.mvvm.*
|
||||||
import com.lagradost.cloudstream3.syncproviders.providers.Kitsu
|
import com.lagradost.cloudstream3.syncproviders.providers.Kitsu
|
||||||
import com.lagradost.cloudstream3.ui.WatchType
|
import com.lagradost.cloudstream3.ui.WatchType
|
||||||
|
import com.lagradost.cloudstream3.ui.download.DOWNLOAD_ACTION_DOWNLOAD
|
||||||
|
import com.lagradost.cloudstream3.ui.download.DOWNLOAD_ACTION_LONG_CLICK
|
||||||
import com.lagradost.cloudstream3.ui.quicksearch.QuickSearchFragment
|
import com.lagradost.cloudstream3.ui.quicksearch.QuickSearchFragment
|
||||||
import com.lagradost.cloudstream3.ui.result.DownloadHelper.setUp
|
import com.lagradost.cloudstream3.ui.result.DownloadHelper.setUp
|
||||||
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTrueTvSettings
|
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTrueTvSettings
|
||||||
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings
|
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings
|
||||||
import com.lagradost.cloudstream3.utils.*
|
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.getNameFull
|
import com.lagradost.cloudstream3.utils.AppUtils.getNameFull
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.html
|
import com.lagradost.cloudstream3.utils.AppUtils.html
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.loadCache
|
import com.lagradost.cloudstream3.utils.AppUtils.loadCache
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.openBrowser
|
import com.lagradost.cloudstream3.utils.AppUtils.openBrowser
|
||||||
|
import com.lagradost.cloudstream3.utils.DataStoreHelper
|
||||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.getViewPos
|
import com.lagradost.cloudstream3.utils.DataStoreHelper.getViewPos
|
||||||
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||||
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialog
|
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialog
|
||||||
|
import com.lagradost.cloudstream3.utils.UIHelper
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute
|
import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
|
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar
|
import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard
|
import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard
|
||||||
import kotlinx.android.synthetic.main.download_button.*
|
|
||||||
import kotlinx.android.synthetic.main.fragment_result.*
|
import kotlinx.android.synthetic.main.fragment_result.*
|
||||||
import kotlinx.android.synthetic.main.fragment_result.result_cast_items
|
import kotlinx.android.synthetic.main.fragment_result.result_cast_items
|
||||||
import kotlinx.android.synthetic.main.fragment_result.result_cast_text
|
import kotlinx.android.synthetic.main.fragment_result.result_cast_text
|
||||||
import kotlinx.android.synthetic.main.fragment_result.result_coming_soon
|
import kotlinx.android.synthetic.main.fragment_result.result_coming_soon
|
||||||
import kotlinx.android.synthetic.main.fragment_result.result_data_holder
|
import kotlinx.android.synthetic.main.fragment_result.result_data_holder
|
||||||
import kotlinx.android.synthetic.main.fragment_result.result_description
|
import kotlinx.android.synthetic.main.fragment_result.result_description
|
||||||
|
import kotlinx.android.synthetic.main.fragment_result.result_download_movie
|
||||||
import kotlinx.android.synthetic.main.fragment_result.result_episode_loading
|
import kotlinx.android.synthetic.main.fragment_result.result_episode_loading
|
||||||
import kotlinx.android.synthetic.main.fragment_result.result_episodes
|
import kotlinx.android.synthetic.main.fragment_result.result_episodes
|
||||||
import kotlinx.android.synthetic.main.fragment_result.result_error_text
|
import kotlinx.android.synthetic.main.fragment_result.result_error_text
|
||||||
|
@ -334,7 +338,13 @@ open class ResultFragment : ResultTrailerPlayer() {
|
||||||
|
|
||||||
|
|
||||||
result_download_movie?.setUp(ep) {
|
result_download_movie?.setUp(ep) {
|
||||||
viewModel.download(it.data)
|
when (it.action) {
|
||||||
|
DOWNLOAD_ACTION_DOWNLOAD -> viewModel.download(activity, it.data)
|
||||||
|
DOWNLOAD_ACTION_LONG_CLICK -> viewModel.handleAction(
|
||||||
|
activity,
|
||||||
|
EpisodeClickEvent(ACTION_DOWNLOAD_MIRROR, ep)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
result_download_movie?.isVisible = true
|
result_download_movie?.isVisible = true
|
||||||
/*main {
|
/*main {
|
||||||
|
@ -509,7 +519,13 @@ open class ResultFragment : ResultTrailerPlayer() {
|
||||||
viewModel.handleAction(activity, episodeClick)
|
viewModel.handleAction(activity, episodeClick)
|
||||||
},
|
},
|
||||||
{ clickEvent ->
|
{ clickEvent ->
|
||||||
viewModel.download(clickEvent.data)
|
when (clickEvent.action) {
|
||||||
|
DOWNLOAD_ACTION_DOWNLOAD -> viewModel.download(activity, clickEvent.data)
|
||||||
|
DOWNLOAD_ACTION_LONG_CLICK -> viewModel.handleAction(
|
||||||
|
activity,
|
||||||
|
EpisodeClickEvent(ACTION_DOWNLOAD_MIRROR, clickEvent.data)
|
||||||
|
)
|
||||||
|
}
|
||||||
//handleDownloadClick(activity, downloadClickEvent)
|
//handleDownloadClick(activity, downloadClickEvent)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -56,10 +56,12 @@ import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.navigate
|
import com.lagradost.cloudstream3.utils.UIHelper.navigate
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.requestRW
|
import com.lagradost.cloudstream3.utils.UIHelper.requestRW
|
||||||
import com.lagradost.cloudstream3.utils.VideoDownloadManager.getBasePath
|
import com.lagradost.cloudstream3.utils.VideoDownloadManager.getBasePath
|
||||||
|
import com.lagradost.cloudstream3.utils.VideoDownloadManager.gotoDir
|
||||||
import com.lagradost.fetchbutton.NotificationMetaData
|
import com.lagradost.fetchbutton.NotificationMetaData
|
||||||
import com.lagradost.fetchbutton.aria2c.Aria2Starter
|
import com.lagradost.fetchbutton.aria2c.Aria2Starter
|
||||||
import com.lagradost.fetchbutton.aria2c.UriRequest
|
import com.lagradost.fetchbutton.aria2c.UriRequest
|
||||||
import com.lagradost.fetchbutton.aria2c.newUriRequest
|
import com.lagradost.fetchbutton.aria2c.newUriRequest
|
||||||
|
import com.lagradost.fetchbutton.utils.Coroutines.mainThread
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.lang.Math.abs
|
import java.lang.Math.abs
|
||||||
|
@ -534,24 +536,16 @@ class ResultViewModel2 : ViewModel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun downloadSubtitle(
|
private fun downloadSubtitle(
|
||||||
context: Context?,
|
|
||||||
link: ExtractorSubtitleLink,
|
link: ExtractorSubtitleLink,
|
||||||
fileName: String,
|
fileName: String,
|
||||||
folder: String
|
folder: String
|
||||||
) {
|
) {
|
||||||
ioSafe {
|
Aria2Starter.download(
|
||||||
VideoDownloadManager.downloadThing(
|
newUriRequest(
|
||||||
context ?: return@ioSafe,
|
null, link.url, fileName, folder, link.headers,
|
||||||
link,
|
USER_AGENT
|
||||||
"$fileName ${link.name}",
|
)
|
||||||
folder,
|
)
|
||||||
if (link.url.contains(".srt")) ".srt" else "vtt",
|
|
||||||
false,
|
|
||||||
null
|
|
||||||
) {
|
|
||||||
// no notification
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getFolder(currentType: TvType, titleName: String): String {
|
private fun getFolder(currentType: TvType, titleName: String): String {
|
||||||
|
@ -581,7 +575,6 @@ class ResultViewModel2 : ViewModel() {
|
||||||
val fileName = VideoDownloadManager.getFileName(ctx, meta)
|
val fileName = VideoDownloadManager.getFileName(ctx, meta)
|
||||||
val folder = getFolder(meta.type ?: return, meta.mainName)
|
val folder = getFolder(meta.type ?: return, meta.mainName)
|
||||||
downloadSubtitle(
|
downloadSubtitle(
|
||||||
ctx,
|
|
||||||
ExtractorSubtitleLink(link.name, link.url, ""),
|
ExtractorSubtitleLink(link.name, link.url, ""),
|
||||||
fileName,
|
fileName,
|
||||||
folder
|
folder
|
||||||
|
@ -611,10 +604,12 @@ class ResultViewModel2 : ViewModel() {
|
||||||
currentType
|
currentType
|
||||||
)
|
)
|
||||||
|
|
||||||
val topFolder = AcraApplication.context?.getBasePath()?.first?.filePath
|
val topFolder = VideoDownloadManager.getDownloadDir()?.filePath ?: throw RuntimeException("FUCK YOU")//AcraApplication.context?.getBasePath()?.first //?.second?.also { println("URIIIIII: $it") } ?: throw RuntimeException("FUCK YOU")
|
||||||
|
//?: VideoDownloadManager.getDownloadDir()?.filePath ?: return null
|
||||||
|
|
||||||
val folder =
|
val folder = topFolder//topFolder?.gotoDir(getFolder(currentType, currentHeaderName).replace(".", ""), true)?.uri?.toString() ?: throw RuntimeException("FUCK YOU")
|
||||||
topFolder + "/" + getFolder(currentType, currentHeaderName).replace(".", "")
|
//val folder =
|
||||||
|
// topFolder + "/" + getFolder(currentType, currentHeaderName).replace(".", "")
|
||||||
//val src = "$DOWNLOAD_NAVIGATE_TO/$parentId" // url ?: return@let
|
//val src = "$DOWNLOAD_NAVIGATE_TO/$parentId" // url ?: return@let
|
||||||
|
|
||||||
// SET VISUAL KEYS
|
// SET VISUAL KEYS
|
||||||
|
@ -667,8 +662,7 @@ class ResultViewModel2 : ViewModel() {
|
||||||
contentTitle = currentHeaderName,
|
contentTitle = currentHeaderName,
|
||||||
secondRow = rowTwo,
|
secondRow = rowTwo,
|
||||||
subText = null,
|
subText = null,
|
||||||
linkName = currentHeaderName,
|
linkName = null,
|
||||||
rowTwoExtra = null
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -680,9 +674,16 @@ class ResultViewModel2 : ViewModel() {
|
||||||
VideoDownloadManager.getFileName(
|
VideoDownloadManager.getFileName(
|
||||||
AcraApplication.context ?: return null,
|
AcraApplication.context ?: return null,
|
||||||
meta
|
meta
|
||||||
), ".mp4"
|
), "mp4"
|
||||||
), folder, link.headers, USER_AGENT,
|
), null,
|
||||||
notificationMetaData = notification
|
link.headers, USER_AGENT,
|
||||||
|
notificationMetaData = notification?.copy(
|
||||||
|
linkName = "${link.name} ${
|
||||||
|
Qualities.getStringByInt(
|
||||||
|
link.quality
|
||||||
|
)
|
||||||
|
}"
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -694,17 +695,24 @@ class ResultViewModel2 : ViewModel() {
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}.distinctBy { it.url }
|
}.distinctBy { it.url }.groupBy { link ->
|
||||||
//.map { ExtractorSubtitleLink(it.name, it.url, "") }
|
SubtitleHelper.fromLanguageToTwoLetters(
|
||||||
.map { link ->
|
link.name,
|
||||||
val fileName = VideoDownloadManager.getFileName(
|
true
|
||||||
AcraApplication.context ?: return null,
|
)
|
||||||
meta
|
}.map {
|
||||||
) + ".vtt"
|
it.value.map { link ->
|
||||||
|
val fileName = VideoDownloadManager.getDisplayName(
|
||||||
|
VideoDownloadManager.getFileName(
|
||||||
|
AcraApplication.context ?: return null,
|
||||||
|
meta
|
||||||
|
), "vtt"
|
||||||
|
)
|
||||||
|
|
||||||
newUriRequest(0, link.url, fileName, folder, link.headers, USER_AGENT)
|
newUriRequest(null, link.url, fileName, folder, link.headers, USER_AGENT)
|
||||||
//downloadSubtitle(context, link, fileName, folder)
|
//downloadSubtitle(context, link, fileName, folder)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return DownloadRequest(linkRequests, downloadSubsList)
|
return DownloadRequest(linkRequests, downloadSubsList)
|
||||||
|
|
||||||
|
@ -740,7 +748,7 @@ class ResultViewModel2 : ViewModel() {
|
||||||
|
|
||||||
data class DownloadRequest(
|
data class DownloadRequest(
|
||||||
val links: List<UriRequest>,
|
val links: List<UriRequest>,
|
||||||
val subs: List<UriRequest>,
|
val subs: List<List<UriRequest>>,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1093,16 +1101,24 @@ class ResultViewModel2 : ViewModel() {
|
||||||
handleEpisodeClickEvent(activity, click)
|
handleEpisodeClickEvent(activity, click)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun downloadFromRequest(req: DownloadRequest) {
|
private fun downloadFromRequest(activity: Activity?, req: DownloadRequest) {
|
||||||
Aria2Starter.download(req.links)
|
Aria2Starter.download(req.links)
|
||||||
for (sub in req.subs.take(5)) {
|
for (sub in req.subs.take(4)) { // download max 4 langs to not block real download
|
||||||
Aria2Starter.download(sub)
|
Aria2Starter.download(sub)
|
||||||
}
|
}
|
||||||
|
val linksFound = req.links.isNotEmpty()
|
||||||
|
mainThread {
|
||||||
|
showToast(
|
||||||
|
activity,
|
||||||
|
if (linksFound) R.string.download_started else R.string.no_links_found_toast,
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun download(card: ResultEpisode) = ioSafe {
|
fun download(activity: Activity?, card: ResultEpisode) = ioSafe {
|
||||||
getRequest(card)?.let { req ->
|
getRequest(card)?.let { req ->
|
||||||
downloadFromRequest(req)
|
downloadFromRequest(activity, req)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1242,13 +1258,8 @@ class ResultViewModel2 : ViewModel() {
|
||||||
listOf(result.links[index]),
|
listOf(result.links[index]),
|
||||||
result.subs,
|
result.subs,
|
||||||
) ?: return@ioSafe
|
) ?: return@ioSafe
|
||||||
downloadFromRequest(req)
|
downloadFromRequest(activity, req)
|
||||||
}
|
}
|
||||||
showToast(
|
|
||||||
activity,
|
|
||||||
R.string.download_started,
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ACTION_RELOAD_EPISODE -> {
|
ACTION_RELOAD_EPISODE -> {
|
||||||
|
|
|
@ -426,7 +426,7 @@ object VideoDownloadManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private const val reservedChars = "|\\?*<\":>+[]/\'"
|
private const val reservedChars = "|\\?*<\":>+[]/\'"
|
||||||
fun sanitizeFilename(name: String, removeSpaces: Boolean= false): String {
|
fun sanitizeFilename(name: String, removeSpaces: Boolean = false): String {
|
||||||
var tempName = name
|
var tempName = name
|
||||||
for (c in reservedChars) {
|
for (c in reservedChars) {
|
||||||
tempName = tempName.replace(c, ' ')
|
tempName = tempName.replace(c, ' ')
|
||||||
|
@ -941,7 +941,7 @@ object VideoDownloadManager {
|
||||||
* @param directoryName if null will use the current path.
|
* @param directoryName if null will use the current path.
|
||||||
* @return UniFile / null if createMissingDirectories = false and folder is not found.
|
* @return UniFile / null if createMissingDirectories = false and folder is not found.
|
||||||
* */
|
* */
|
||||||
private fun UniFile.gotoDir(
|
fun UniFile.gotoDir(
|
||||||
directoryName: String?,
|
directoryName: String?,
|
||||||
createMissingDirectories: Boolean = true
|
createMissingDirectories: Boolean = true
|
||||||
): UniFile? {
|
): UniFile? {
|
||||||
|
@ -1612,7 +1612,7 @@ object VideoDownloadManager {
|
||||||
.mapIndexed { index, any -> DownloadQueueResumePackage(index, any) }
|
.mapIndexed { index, any -> DownloadQueueResumePackage(index, any) }
|
||||||
.toTypedArray()
|
.toTypedArray()
|
||||||
setKey(KEY_RESUME_QUEUE_PACKAGES, dQueue)
|
setKey(KEY_RESUME_QUEUE_PACKAGES, dQueue)
|
||||||
} catch (t : Throwable) {
|
} catch (t: Throwable) {
|
||||||
logError(t)
|
logError(t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<com.lagradost.cloudstream3.ui.DownloadButton
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:id="@+id/result_download_movie"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
app:aria2c_layout="@layout/download_button_layout" />
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
style="@style/BlackButton"
|
style="@style/BlackButton"
|
||||||
|
android:id="@+id/download_big_button"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_marginStart="0dp"
|
android:layout_marginStart="0dp"
|
||||||
android:layout_marginEnd="0dp"
|
android:layout_marginEnd="0dp"
|
||||||
|
@ -20,9 +21,10 @@
|
||||||
android:layout_gravity="center">
|
android:layout_gravity="center">
|
||||||
|
|
||||||
<include
|
<include
|
||||||
|
android:layout_gravity="center"
|
||||||
layout="@layout/download_button_view"
|
layout="@layout/download_button_view"
|
||||||
android:layout_width="40dp"
|
android:layout_width="35dp"
|
||||||
android:layout_height="40dp" />
|
android:layout_height="35dp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/result_movie_download_text"
|
android:id="@+id/result_movie_download_text"
|
||||||
|
|
|
@ -569,8 +569,12 @@
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:layout_width="match_parent" />-->
|
android:layout_width="match_parent" />-->
|
||||||
|
<com.lagradost.cloudstream3.ui.DownloadButton
|
||||||
<include layout="@layout/download_button" />
|
android:id="@+id/result_download_movie"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
app:aria2c_layout="@layout/download_button_layout" />
|
||||||
|
|
||||||
<!--<androidx.core.widget.ContentLoadingProgressBar
|
<!--<androidx.core.widget.ContentLoadingProgressBar
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -418,8 +418,8 @@
|
||||||
|
|
||||||
</com.google.android.material.button.MaterialButton>
|
</com.google.android.material.button.MaterialButton>
|
||||||
|
|
||||||
<include
|
<com.lagradost.cloudstream3.ui.DownloadButton
|
||||||
layout="@layout/download_button"
|
android:id="@+id/result_download_movie"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:minWidth="250dp"
|
android:minWidth="250dp"
|
||||||
|
|
|
@ -99,6 +99,7 @@
|
||||||
android:background="?selectableItemBackgroundBorderless"
|
android:background="?selectableItemBackgroundBorderless"
|
||||||
android:id="@+id/result_episode_download"
|
android:id="@+id/result_episode_download"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
|
android:padding="10dp"
|
||||||
android:layout_width="50dp"
|
android:layout_width="50dp"
|
||||||
android:layout_height="50dp">
|
android:layout_height="50dp">
|
||||||
</com.lagradost.fetchbutton.ui.PieFetchButton>
|
</com.lagradost.fetchbutton.ui.PieFetchButton>
|
||||||
|
|
|
@ -109,6 +109,7 @@
|
||||||
android:background="?selectableItemBackgroundBorderless"
|
android:background="?selectableItemBackgroundBorderless"
|
||||||
android:id="@+id/result_episode_download"
|
android:id="@+id/result_episode_download"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
|
android:padding="5dp"
|
||||||
android:layout_width="50dp"
|
android:layout_width="50dp"
|
||||||
android:layout_height="50dp">
|
android:layout_height="50dp">
|
||||||
</com.lagradost.fetchbutton.ui.PieFetchButton>
|
</com.lagradost.fetchbutton.ui.PieFetchButton>
|
||||||
|
|
|
@ -69,6 +69,7 @@
|
||||||
<item name="aria2c_icon_color">?attr/white</item>
|
<item name="aria2c_icon_color">?attr/white</item>
|
||||||
<item name="aria2c_fill_color">?attr/white</item>
|
<item name="aria2c_fill_color">?attr/white</item>
|
||||||
<item name="aria2c_outline_color">?attr/white</item>
|
<item name="aria2c_outline_color">?attr/white</item>
|
||||||
|
<item name="aria2c_icon_scale">0.7</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="ListViewStyle" parent="Widget.AppCompat.ListView">
|
<style name="ListViewStyle" parent="Widget.AppCompat.ListView">
|
||||||
|
|
Loading…
Reference in a new issue