forked from recloudstream/cloudstream
small trailer fix
This commit is contained in:
parent
7c4f177e47
commit
c11f0c101b
1 changed files with 32 additions and 32 deletions
|
@ -1977,8 +1977,9 @@ class ResultViewModel2 : ViewModel() {
|
||||||
limit: Int = 0
|
limit: Int = 0
|
||||||
): List<ExtractedTrailerData> =
|
): List<ExtractedTrailerData> =
|
||||||
coroutineScope {
|
coroutineScope {
|
||||||
var currentCount = 0
|
val returnlist = ArrayList<ExtractedTrailerData>()
|
||||||
return@coroutineScope loadResponse.trailers.amap { trailerData ->
|
loadResponse.trailers.windowed(limit, limit, true).takeWhile { list ->
|
||||||
|
list.amap { trailerData ->
|
||||||
try {
|
try {
|
||||||
val links = arrayListOf<ExtractorLink>()
|
val links = arrayListOf<ExtractorLink>()
|
||||||
val subs = arrayListOf<SubtitleFile>()
|
val subs = arrayListOf<SubtitleFile>()
|
||||||
|
@ -2000,19 +2001,18 @@ class ResultViewModel2 : ViewModel() {
|
||||||
) to arrayListOf()
|
) to arrayListOf()
|
||||||
} else {
|
} else {
|
||||||
links to subs
|
links to subs
|
||||||
}.also { (extractor, _) ->
|
|
||||||
if (extractor.isNotEmpty() && limit != 0) {
|
|
||||||
currentCount++
|
|
||||||
if (currentCount >= limit) {
|
|
||||||
cancel()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
logError(e)
|
logError(e)
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
}.filterNotNull().map { (links, subs) -> ExtractedTrailerData(links, subs) }
|
}.filterNotNull().map { (links, subs) -> ExtractedTrailerData(links, subs) }.let {
|
||||||
|
returnlist.addAll(it)
|
||||||
|
}
|
||||||
|
|
||||||
|
returnlist.size < limit
|
||||||
|
}
|
||||||
|
return@coroutineScope returnlist
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue