forked from recloudstream/cloudstream
fixed json pair and next episode
This commit is contained in:
parent
030f0e98c3
commit
9f9251108a
5 changed files with 44 additions and 33 deletions
|
@ -127,7 +127,7 @@ class SflixProvider(providerUrl: String, providerName: String) : MainAPI() {
|
|||
// Supported streams, they're identical
|
||||
val sourceIds = Jsoup.parse(episodes).select("a").mapNotNull { element ->
|
||||
val sourceId = element.attr("data-id") ?: return@mapNotNull null
|
||||
if(element.select("span")?.text()?.trim()?.isValidServer() == true) {
|
||||
if (element.select("span")?.text()?.trim()?.isValidServer() == true) {
|
||||
"$url.$sourceId".replace("/movie/", "/watch-movie/")
|
||||
} else {
|
||||
null
|
||||
|
@ -172,7 +172,7 @@ class SflixProvider(providerUrl: String, providerName: String) : MainAPI() {
|
|||
episodeTitle.removePrefix("Episode $episodeNum: "),
|
||||
season + 1,
|
||||
episodeNum,
|
||||
"$url:::$episodeData",
|
||||
Pair(url, episodeData).toJson(),
|
||||
fixUrl(episodePosterUrl)
|
||||
)
|
||||
)
|
||||
|
@ -220,7 +220,7 @@ class SflixProvider(providerUrl: String, providerName: String) : MainAPI() {
|
|||
// Supported streams, they're identical
|
||||
Jsoup.parse(episodes).select("a").mapNotNull { element ->
|
||||
val id = element?.attr("data-id") ?: return@mapNotNull null
|
||||
if(element.select("span")?.text()?.trim()?.isValidServer() == true) {
|
||||
if (element.select("span")?.text()?.trim()?.isValidServer() == true) {
|
||||
"$prefix.$id".replace("/tv/", "/watch-tv/")
|
||||
} else {
|
||||
null
|
||||
|
@ -249,9 +249,10 @@ class SflixProvider(providerUrl: String, providerName: String) : MainAPI() {
|
|||
mapped.sources1 to "source 2",
|
||||
mapped.sources2 to "source 3",
|
||||
mapped.sourcesBackup to "source backup"
|
||||
).forEach { subList ->
|
||||
subList.first?.forEach {
|
||||
it?.toExtractorLink(this, subList.second)?.forEach(callback)
|
||||
).forEach { (sources, sourceName) ->
|
||||
println("SOURCE:::: $sourceName $sources")
|
||||
sources?.forEach {
|
||||
it?.toExtractorLink(this, sourceName)?.forEach(callback)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,9 +50,10 @@ class DownloadFileGenerator(
|
|||
clearCache: Boolean,
|
||||
isCasting: Boolean,
|
||||
callback: (Pair<ExtractorLink?, ExtractorUri?>) -> Unit,
|
||||
subtitleCallback: (SubtitleData) -> Unit
|
||||
subtitleCallback: (SubtitleData) -> Unit,
|
||||
offset: Int,
|
||||
): Boolean {
|
||||
val meta = episodes[currentIndex]
|
||||
val meta = episodes[currentIndex + offset]
|
||||
callback(Pair(null, meta))
|
||||
|
||||
context?.let { ctx ->
|
||||
|
|
|
@ -20,6 +20,7 @@ interface IGenerator {
|
|||
clearCache: Boolean,
|
||||
isCasting: Boolean,
|
||||
callback: (Pair<ExtractorLink?, ExtractorUri?>) -> Unit,
|
||||
subtitleCallback: (SubtitleData) -> Unit
|
||||
subtitleCallback: (SubtitleData) -> Unit,
|
||||
offset : Int = 0,
|
||||
): Boolean
|
||||
}
|
|
@ -9,6 +9,7 @@ import com.lagradost.cloudstream3.mvvm.normalSafeApiCall
|
|||
import com.lagradost.cloudstream3.mvvm.safeApiCall
|
||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||
import com.lagradost.cloudstream3.utils.ExtractorUri
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class PlayerGeneratorViewModel : ViewModel() {
|
||||
|
@ -50,12 +51,13 @@ class PlayerGeneratorViewModel : ViewModel() {
|
|||
return generator?.hasNext()
|
||||
}
|
||||
|
||||
fun preLoadNextLinks() = viewModelScope.launch {
|
||||
safeApiCall {
|
||||
fun preLoadNextLinks() {
|
||||
currentJob?.cancel()
|
||||
currentJob = viewModelScope.launch {
|
||||
if (generator?.hasCache == true && generator?.hasNext() == true) {
|
||||
generator?.next()
|
||||
generator?.generateLinks(clearCache = false, isCasting = false, {}, {})
|
||||
generator?.prev()
|
||||
safeApiCall {
|
||||
generator?.generateLinks(clearCache = false, isCasting = false, {}, {}, offset = 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +88,11 @@ class PlayerGeneratorViewModel : ViewModel() {
|
|||
_currentSubs.postValue(subs)
|
||||
}
|
||||
|
||||
fun loadLinks(clearCache: Boolean = false, isCasting: Boolean = false) = viewModelScope.launch {
|
||||
private var currentJob: Job? = null
|
||||
|
||||
fun loadLinks(clearCache: Boolean = false, isCasting: Boolean = false) {
|
||||
currentJob?.cancel()
|
||||
currentJob = viewModelScope.launch {
|
||||
val currentLinks = mutableSetOf<Pair<ExtractorLink?, ExtractorUri?>>()
|
||||
val currentSubs = mutableSetOf<SubtitleData>()
|
||||
|
||||
|
@ -106,4 +112,5 @@ class PlayerGeneratorViewModel : ViewModel() {
|
|||
_currentLinks.postValue(currentLinks)
|
||||
_currentSubs.postValue(currentSubs)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -50,10 +50,11 @@ class RepoLinkGenerator(private val episodes: List<ResultEpisode>, private var c
|
|||
clearCache: Boolean,
|
||||
isCasting: Boolean,
|
||||
callback: (Pair<ExtractorLink?, ExtractorUri?>) -> Unit,
|
||||
subtitleCallback: (SubtitleData) -> Unit
|
||||
subtitleCallback: (SubtitleData) -> Unit,
|
||||
offset : Int,
|
||||
): Boolean {
|
||||
val index = currentIndex
|
||||
val current = episodes[index]
|
||||
val current = episodes[index + offset]
|
||||
|
||||
val currentLinkCache = if (clearCache) mutableSetOf() else linkCache[index].toMutableSet()
|
||||
val currentSubsCache = if (clearCache) mutableSetOf() else subsCache[index].toMutableSet()
|
||||
|
|
Loading…
Reference in a new issue