mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
episode test
This commit is contained in:
parent
266a511cd7
commit
63e4e670c0
4 changed files with 205 additions and 152 deletions
|
@ -18,6 +18,7 @@ import com.lagradost.cloudstream3.ui.download.DownloadClickEvent
|
||||||
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTrueTvSettings
|
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTrueTvSettings
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.html
|
import com.lagradost.cloudstream3.utils.AppUtils.html
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.setImage
|
import com.lagradost.cloudstream3.utils.UIHelper.setImage
|
||||||
|
import com.lagradost.fetchbutton.aria2c.UriRequest
|
||||||
import com.lagradost.fetchbutton.aria2c.newUriRequest
|
import com.lagradost.fetchbutton.aria2c.newUriRequest
|
||||||
import kotlinx.android.synthetic.main.result_episode.view.*
|
import kotlinx.android.synthetic.main.result_episode.view.*
|
||||||
import kotlinx.android.synthetic.main.result_episode.view.episode_text
|
import kotlinx.android.synthetic.main.result_episode.view.episode_text
|
||||||
|
@ -52,7 +53,7 @@ data class EpisodeClickEvent(val action: Int, val data: ResultEpisode)
|
||||||
class EpisodeAdapter(
|
class EpisodeAdapter(
|
||||||
private val hasDownloadSupport: Boolean,
|
private val hasDownloadSupport: Boolean,
|
||||||
private val clickCallback: (EpisodeClickEvent) -> Unit,
|
private val clickCallback: (EpisodeClickEvent) -> Unit,
|
||||||
private val downloadClickCallback: (DownloadClickEvent) -> Unit,
|
private val downloadClickCallback: suspend ResultEpisode.() -> List<UriRequest>,
|
||||||
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||||
private var cardList: MutableList<ResultEpisode> = mutableListOf()
|
private var cardList: MutableList<ResultEpisode> = mutableListOf()
|
||||||
|
|
||||||
|
@ -125,7 +126,7 @@ class EpisodeAdapter(
|
||||||
itemView: View,
|
itemView: View,
|
||||||
private val hasDownloadSupport: Boolean,
|
private val hasDownloadSupport: Boolean,
|
||||||
private val clickCallback: (EpisodeClickEvent) -> Unit,
|
private val clickCallback: (EpisodeClickEvent) -> Unit,
|
||||||
private val downloadClickCallback: (DownloadClickEvent) -> Unit,
|
private val downloadClickCallback : suspend ResultEpisode.() -> List<UriRequest>,
|
||||||
) : RecyclerView.ViewHolder(itemView) {
|
) : RecyclerView.ViewHolder(itemView) {
|
||||||
//override var downloadButton = EasyDownloadButton()
|
//override var downloadButton = EasyDownloadButton()
|
||||||
|
|
||||||
|
@ -153,11 +154,7 @@ class EpisodeAdapter(
|
||||||
downloadButton.setPersistentId(card.id.toLong())
|
downloadButton.setPersistentId(card.id.toLong())
|
||||||
downloadButton.isVisible = hasDownloadSupport
|
downloadButton.isVisible = hasDownloadSupport
|
||||||
downloadButton.setDefaultClickListener {
|
downloadButton.setDefaultClickListener {
|
||||||
listOf(
|
downloadClickCallback.invoke(card)
|
||||||
newUriRequest(
|
|
||||||
card.id.toLong(), "https://speed.hetzner.de/100MB.bin", "Hello World",
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val name =
|
val name =
|
||||||
|
|
|
@ -36,8 +36,10 @@ 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_DOWNLOAD
|
||||||
import com.lagradost.cloudstream3.ui.download.DownloadButtonSetup.handleDownloadClick
|
import com.lagradost.cloudstream3.ui.download.DownloadButtonSetup.handleDownloadClick
|
||||||
|
import com.lagradost.cloudstream3.ui.download.DownloadViewModel
|
||||||
import com.lagradost.cloudstream3.ui.download.EasyDownloadButton
|
import com.lagradost.cloudstream3.ui.download.EasyDownloadButton
|
||||||
import com.lagradost.cloudstream3.ui.quicksearch.QuickSearchFragment
|
import com.lagradost.cloudstream3.ui.quicksearch.QuickSearchFragment
|
||||||
|
import com.lagradost.cloudstream3.ui.result.ResultViewModel2.Companion.getDownloadRequest
|
||||||
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.*
|
||||||
|
@ -506,8 +508,9 @@ open class ResultFragment : ResultTrailerPlayer() {
|
||||||
{ episodeClick ->
|
{ episodeClick ->
|
||||||
viewModel.handleAction(activity, episodeClick)
|
viewModel.handleAction(activity, episodeClick)
|
||||||
},
|
},
|
||||||
{ downloadClickEvent ->
|
{
|
||||||
handleDownloadClick(activity, downloadClickEvent)
|
viewModel.getRequest(this)?.links ?: emptyList()
|
||||||
|
//handleDownloadClick(activity, downloadClickEvent)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ import com.lagradost.cloudstream3.syncproviders.SyncAPI
|
||||||
import com.lagradost.cloudstream3.syncproviders.providers.Kitsu
|
import com.lagradost.cloudstream3.syncproviders.providers.Kitsu
|
||||||
import com.lagradost.cloudstream3.ui.APIRepository
|
import com.lagradost.cloudstream3.ui.APIRepository
|
||||||
import com.lagradost.cloudstream3.ui.WatchType
|
import com.lagradost.cloudstream3.ui.WatchType
|
||||||
import com.lagradost.cloudstream3.ui.download.DOWNLOAD_NAVIGATE_TO
|
|
||||||
import com.lagradost.cloudstream3.ui.player.GeneratorPlayer
|
import com.lagradost.cloudstream3.ui.player.GeneratorPlayer
|
||||||
import com.lagradost.cloudstream3.ui.player.IGenerator
|
import com.lagradost.cloudstream3.ui.player.IGenerator
|
||||||
import com.lagradost.cloudstream3.ui.player.RepoLinkGenerator
|
import com.lagradost.cloudstream3.ui.player.RepoLinkGenerator
|
||||||
|
@ -55,6 +54,10 @@ import com.lagradost.cloudstream3.utils.DataStoreHelper.setResultSeason
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.checkWrite
|
import com.lagradost.cloudstream3.utils.UIHelper.checkWrite
|
||||||
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.fetchbutton.aria2c.Aria2Starter
|
||||||
|
import com.lagradost.fetchbutton.aria2c.UriRequest
|
||||||
|
import com.lagradost.fetchbutton.aria2c.newUriRequest
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.lang.Math.abs
|
import java.lang.Math.abs
|
||||||
|
@ -584,8 +587,7 @@ class ResultViewModel2 : ViewModel() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun startDownload(
|
fun getDownloadRequest(
|
||||||
context: Context?,
|
|
||||||
episode: ResultEpisode,
|
episode: ResultEpisode,
|
||||||
currentIsMovie: Boolean,
|
currentIsMovie: Boolean,
|
||||||
currentHeaderName: String,
|
currentHeaderName: String,
|
||||||
|
@ -596,93 +598,139 @@ class ResultViewModel2 : ViewModel() {
|
||||||
url: String,
|
url: String,
|
||||||
links: List<ExtractorLink>,
|
links: List<ExtractorLink>,
|
||||||
subs: List<SubtitleData>?
|
subs: List<SubtitleData>?
|
||||||
) {
|
): DownloadRequest? {
|
||||||
try {
|
val meta =
|
||||||
if (context == null) return
|
getMeta(
|
||||||
|
episode,
|
||||||
val meta =
|
currentHeaderName,
|
||||||
getMeta(
|
apiName,
|
||||||
episode,
|
currentPoster,
|
||||||
currentHeaderName,
|
currentIsMovie,
|
||||||
apiName,
|
currentType
|
||||||
currentPoster,
|
|
||||||
currentIsMovie,
|
|
||||||
currentType
|
|
||||||
)
|
|
||||||
|
|
||||||
val folder = getFolder(currentType, currentHeaderName)
|
|
||||||
|
|
||||||
val src = "$DOWNLOAD_NAVIGATE_TO/$parentId" // url ?: return@let
|
|
||||||
|
|
||||||
// SET VISUAL KEYS
|
|
||||||
AcraApplication.setKey(
|
|
||||||
DOWNLOAD_HEADER_CACHE,
|
|
||||||
parentId.toString(),
|
|
||||||
VideoDownloadHelper.DownloadHeaderCached(
|
|
||||||
apiName,
|
|
||||||
url,
|
|
||||||
currentType,
|
|
||||||
currentHeaderName,
|
|
||||||
currentPoster,
|
|
||||||
parentId,
|
|
||||||
System.currentTimeMillis(),
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
AcraApplication.setKey(
|
val topFolder = AcraApplication.context?.getBasePath()?.first?.filePath
|
||||||
DataStore.getFolderName(
|
|
||||||
DOWNLOAD_EPISODE_CACHE,
|
|
||||||
parentId.toString()
|
|
||||||
), // 3 deep folder for faster acess
|
|
||||||
episode.id.toString(),
|
|
||||||
VideoDownloadHelper.DownloadEpisodeCached(
|
|
||||||
episode.name,
|
|
||||||
episode.poster,
|
|
||||||
episode.episode,
|
|
||||||
episode.season,
|
|
||||||
episode.id,
|
|
||||||
parentId,
|
|
||||||
episode.rating,
|
|
||||||
episode.description,
|
|
||||||
System.currentTimeMillis(),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
// DOWNLOAD VIDEO
|
val folder =
|
||||||
VideoDownloadManager.downloadEpisodeUsingWorker(
|
topFolder + "/" + getFolder(currentType, currentHeaderName).replace(".", "")
|
||||||
context,
|
//val src = "$DOWNLOAD_NAVIGATE_TO/$parentId" // url ?: return@let
|
||||||
src,//url ?: return,
|
|
||||||
folder,
|
|
||||||
meta,
|
|
||||||
links
|
|
||||||
)
|
|
||||||
|
|
||||||
// 1. Checks if the lang should be downloaded
|
// SET VISUAL KEYS
|
||||||
// 2. Makes it into the download format
|
AcraApplication.setKey(
|
||||||
// 3. Downloads it as a .vtt file
|
DOWNLOAD_HEADER_CACHE,
|
||||||
val downloadList = SubtitlesFragment.getDownloadSubsLanguageISO639_1()
|
parentId.toString(),
|
||||||
subs?.let { subsList ->
|
VideoDownloadHelper.DownloadHeaderCached(
|
||||||
subsList.filter {
|
apiName,
|
||||||
downloadList.contains(
|
url,
|
||||||
SubtitleHelper.fromLanguageToTwoLetters(
|
currentType,
|
||||||
it.name,
|
currentHeaderName,
|
||||||
true
|
currentPoster,
|
||||||
)
|
parentId,
|
||||||
)
|
System.currentTimeMillis(),
|
||||||
}
|
)
|
||||||
.map { ExtractorSubtitleLink(it.name, it.url, "") }
|
)
|
||||||
.forEach { link ->
|
|
||||||
val fileName = VideoDownloadManager.getFileName(context, meta)
|
AcraApplication.setKey(
|
||||||
downloadSubtitle(context, link, fileName, folder)
|
DataStore.getFolderName(
|
||||||
}
|
DOWNLOAD_EPISODE_CACHE,
|
||||||
}
|
parentId.toString()
|
||||||
} catch (e: Exception) {
|
), // 3 deep folder for faster acess
|
||||||
logError(e)
|
episode.id.toString(),
|
||||||
|
VideoDownloadHelper.DownloadEpisodeCached(
|
||||||
|
episode.name,
|
||||||
|
episode.poster,
|
||||||
|
episode.episode,
|
||||||
|
episode.season,
|
||||||
|
episode.id,
|
||||||
|
parentId,
|
||||||
|
episode.rating,
|
||||||
|
episode.description,
|
||||||
|
System.currentTimeMillis(),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
val linkRequests = links.filter { link -> !link.isM3u8 }.map { link ->
|
||||||
|
newUriRequest(
|
||||||
|
episode.id.toLong(), link.url,
|
||||||
|
VideoDownloadManager.getDisplayName(
|
||||||
|
VideoDownloadManager.getFileName(
|
||||||
|
AcraApplication.context ?: return null,
|
||||||
|
meta
|
||||||
|
), ".mp4"
|
||||||
|
), folder, link.headers, USER_AGENT
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val downloadList = SubtitlesFragment.getDownloadSubsLanguageISO639_1()
|
||||||
|
val downloadSubsList = (subs ?: emptyList()).filter {
|
||||||
|
downloadList.contains(
|
||||||
|
SubtitleHelper.fromLanguageToTwoLetters(
|
||||||
|
it.name,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
.map { ExtractorSubtitleLink(it.name, it.url, "") }
|
||||||
|
.map { link ->
|
||||||
|
val fileName = VideoDownloadManager.getFileName(
|
||||||
|
AcraApplication.context ?: return null,
|
||||||
|
meta
|
||||||
|
)
|
||||||
|
newUriRequest(0, link.url, fileName, folder, link.headers, USER_AGENT)
|
||||||
|
//downloadSubtitle(context, link, fileName, folder)
|
||||||
|
}
|
||||||
|
|
||||||
|
return DownloadRequest(linkRequests, downloadSubsList)
|
||||||
|
|
||||||
|
// DOWNLOAD VIDEO
|
||||||
|
//VideoDownloadManager.downloadEpisodeUsingWorker(
|
||||||
|
// context,
|
||||||
|
// src,//url ?: return,
|
||||||
|
// folder,
|
||||||
|
// meta,
|
||||||
|
// links
|
||||||
|
//)
|
||||||
|
|
||||||
|
// 1. Checks if the lang should be downloaded
|
||||||
|
// 2. Makes it into the download format
|
||||||
|
// 3. Downloads it as a .vtt file
|
||||||
|
//val downloadList = SubtitlesFragment.getDownloadSubsLanguageISO639_1()
|
||||||
|
//subs?.let { subsList ->
|
||||||
|
// subsList.filter {
|
||||||
|
// downloadList.contains(
|
||||||
|
// SubtitleHelper.fromLanguageToTwoLetters(
|
||||||
|
// it.name,
|
||||||
|
// true
|
||||||
|
// )
|
||||||
|
// )
|
||||||
|
// }
|
||||||
|
// .map { ExtractorSubtitleLink(it.name, it.url, "") }
|
||||||
|
// .forEach { link ->
|
||||||
|
// val fileName = VideoDownloadManager.getFileName(context, meta)
|
||||||
|
// downloadSubtitle(context, link, fileName, folder)
|
||||||
|
// }
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data class DownloadRequest(
|
||||||
|
val links: List<UriRequest>,
|
||||||
|
val subs: List<UriRequest>,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
/*suspend fun download(episode: ResultEpisode): DownloadRequest {
|
||||||
|
val generator = RepoLinkGenerator(listOf(episode))
|
||||||
|
val currentLinks = mutableSetOf<ExtractorLink>()
|
||||||
|
val currentSubs = mutableSetOf<SubtitleData>()
|
||||||
|
generator.generateLinks(clearCache = false, isCasting = false, callback = {
|
||||||
|
it.first?.let { link ->
|
||||||
|
currentLinks.add(link)
|
||||||
|
}
|
||||||
|
}, subtitleCallback = { sub ->
|
||||||
|
currentSubs.add(sub)
|
||||||
|
})
|
||||||
|
}*/
|
||||||
|
|
||||||
suspend fun downloadEpisode(
|
suspend fun downloadEpisode(
|
||||||
activity: Activity?,
|
|
||||||
episode: ResultEpisode,
|
episode: ResultEpisode,
|
||||||
currentIsMovie: Boolean,
|
currentIsMovie: Boolean,
|
||||||
currentHeaderName: String,
|
currentHeaderName: String,
|
||||||
|
@ -691,52 +739,49 @@ class ResultViewModel2 : ViewModel() {
|
||||||
apiName: String,
|
apiName: String,
|
||||||
parentId: Int,
|
parentId: Int,
|
||||||
url: String,
|
url: String,
|
||||||
) {
|
): DownloadRequest? {
|
||||||
ioSafe {
|
val generator = RepoLinkGenerator(listOf(episode))
|
||||||
val generator = RepoLinkGenerator(listOf(episode))
|
val currentLinks = mutableSetOf<ExtractorLink>()
|
||||||
val currentLinks = mutableSetOf<ExtractorLink>()
|
val currentSubs = mutableSetOf<SubtitleData>()
|
||||||
val currentSubs = mutableSetOf<SubtitleData>()
|
generator.generateLinks(clearCache = false, isCasting = false, callback = {
|
||||||
generator.generateLinks(clearCache = false, isCasting = false, callback = {
|
it.first?.let { link ->
|
||||||
it.first?.let { link ->
|
currentLinks.add(link)
|
||||||
currentLinks.add(link)
|
|
||||||
}
|
|
||||||
}, subtitleCallback = { sub ->
|
|
||||||
currentSubs.add(sub)
|
|
||||||
})
|
|
||||||
|
|
||||||
if (currentLinks.isEmpty()) {
|
|
||||||
main {
|
|
||||||
showToast(
|
|
||||||
activity,
|
|
||||||
R.string.no_links_found_toast,
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return@ioSafe
|
|
||||||
} else {
|
|
||||||
main {
|
|
||||||
showToast(
|
|
||||||
activity,
|
|
||||||
R.string.download_started,
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}, subtitleCallback = { sub ->
|
||||||
|
currentSubs.add(sub)
|
||||||
|
})
|
||||||
|
|
||||||
startDownload(
|
//if (currentLinks.isEmpty()) {
|
||||||
activity,
|
// main {
|
||||||
episode,
|
// showToast(
|
||||||
currentIsMovie,
|
// activity,
|
||||||
currentHeaderName,
|
// R.string.no_links_found_toast,
|
||||||
currentType,
|
// Toast.LENGTH_SHORT
|
||||||
currentPoster,
|
// )
|
||||||
apiName,
|
// }
|
||||||
parentId,
|
// return@ioSafe
|
||||||
url,
|
//} else {
|
||||||
sortUrls(currentLinks),
|
// main {
|
||||||
sortSubs(currentSubs),
|
// showToast(
|
||||||
)
|
// activity,
|
||||||
}
|
// R.string.download_started,
|
||||||
|
// Toast.LENGTH_SHORT
|
||||||
|
// )
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
return getDownloadRequest(
|
||||||
|
episode,
|
||||||
|
currentIsMovie,
|
||||||
|
currentHeaderName,
|
||||||
|
currentType,
|
||||||
|
currentPoster,
|
||||||
|
apiName,
|
||||||
|
parentId,
|
||||||
|
url,
|
||||||
|
sortUrls(currentLinks),
|
||||||
|
sortSubs(currentSubs),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getMeta(
|
private fun getMeta(
|
||||||
|
@ -1021,6 +1066,20 @@ class ResultViewModel2 : ViewModel() {
|
||||||
handleEpisodeClickEvent(activity, click)
|
handleEpisodeClickEvent(activity, click)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun getRequest(card: ResultEpisode): DownloadRequest? {
|
||||||
|
val response = currentResponse ?: return null
|
||||||
|
return downloadEpisode(
|
||||||
|
card,
|
||||||
|
response.isMovie(),
|
||||||
|
response.name,
|
||||||
|
response.type,
|
||||||
|
response.posterUrl,
|
||||||
|
response.apiName,
|
||||||
|
response.getId(),
|
||||||
|
response.url
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
private suspend fun handleEpisodeClickEvent(activity: Activity?, click: EpisodeClickEvent) {
|
private suspend fun handleEpisodeClickEvent(activity: Activity?, click: EpisodeClickEvent) {
|
||||||
when (click.action) {
|
when (click.action) {
|
||||||
ACTION_SHOW_OPTIONS -> {
|
ACTION_SHOW_OPTIONS -> {
|
||||||
|
@ -1117,18 +1176,11 @@ class ResultViewModel2 : ViewModel() {
|
||||||
showToast(activity, R.string.play_episode_toast, Toast.LENGTH_SHORT)
|
showToast(activity, R.string.play_episode_toast, Toast.LENGTH_SHORT)
|
||||||
}
|
}
|
||||||
ACTION_DOWNLOAD_EPISODE -> {
|
ACTION_DOWNLOAD_EPISODE -> {
|
||||||
val response = currentResponse ?: return
|
ioSafe {
|
||||||
downloadEpisode(
|
val response = currentResponse ?: return@ioSafe
|
||||||
activity,
|
val req = getRequest(click.data) ?: return@ioSafe
|
||||||
click.data,
|
Aria2Starter.client?.downloadFailQueue(req.links) { _, _ -> }
|
||||||
response.isMovie(),
|
}
|
||||||
response.name,
|
|
||||||
response.type,
|
|
||||||
response.posterUrl,
|
|
||||||
response.apiName,
|
|
||||||
response.getId(),
|
|
||||||
response.url
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
ACTION_DOWNLOAD_MIRROR -> {
|
ACTION_DOWNLOAD_MIRROR -> {
|
||||||
val response = currentResponse ?: return
|
val response = currentResponse ?: return
|
||||||
|
@ -1138,8 +1190,7 @@ class ResultViewModel2 : ViewModel() {
|
||||||
txt(R.string.episode_action_download_mirror)
|
txt(R.string.episode_action_download_mirror)
|
||||||
) { (result, index) ->
|
) { (result, index) ->
|
||||||
ioSafe {
|
ioSafe {
|
||||||
startDownload(
|
val req = getDownloadRequest(
|
||||||
activity,
|
|
||||||
click.data,
|
click.data,
|
||||||
response.isMovie(),
|
response.isMovie(),
|
||||||
response.name,
|
response.name,
|
||||||
|
@ -1150,7 +1201,8 @@ class ResultViewModel2 : ViewModel() {
|
||||||
response.url,
|
response.url,
|
||||||
listOf(result.links[index]),
|
listOf(result.links[index]),
|
||||||
result.subs,
|
result.subs,
|
||||||
)
|
) ?: return@ioSafe
|
||||||
|
Aria2Starter.client?.downloadFailQueue(req.links) { _, _ -> }
|
||||||
}
|
}
|
||||||
showToast(
|
showToast(
|
||||||
activity,
|
activity,
|
||||||
|
@ -1592,7 +1644,8 @@ class ResultViewModel2 : ViewModel() {
|
||||||
val idIndex = ep.key.id
|
val idIndex = ep.key.id
|
||||||
for ((index, i) in ep.value.withIndex()) {
|
for ((index, i) in ep.value.withIndex()) {
|
||||||
val episode = i.episode ?: (index + 1)
|
val episode = i.episode ?: (index + 1)
|
||||||
val id = mainId + episode + idIndex * 1_000_000 + (i.season?.times(10_000) ?: 0)
|
val id =
|
||||||
|
mainId + episode + idIndex * 1_000_000 + (i.season?.times(10_000) ?: 0)
|
||||||
if (!existingEpisodes.contains(id)) {
|
if (!existingEpisodes.contains(id)) {
|
||||||
existingEpisodes.add(id)
|
existingEpisodes.add(id)
|
||||||
val seasonData = loadResponse.seasonNames.getSeason(i.season)
|
val seasonData = loadResponse.seasonNames.getSeason(i.season)
|
||||||
|
|
|
@ -995,7 +995,7 @@ object VideoDownloadManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getDisplayName(name: String, extension: String): String {
|
fun getDisplayName(name: String, extension: String): String {
|
||||||
return "$name.$extension"
|
return "$name.$extension"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue