Merge pull request #4290 from FireMasterK/dearrow-sort

Sort videoIds before performing DeArrow fetch
This commit is contained in:
Bnyro 2023-07-22 22:25:15 +02:00 committed by GitHub
commit 1d554b9809
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -32,7 +32,11 @@ object DeArrowUtil {
suspend fun deArrowStreamItems(streamItems: List<StreamItem>): List<StreamItem> {
if (!PreferenceHelper.getBoolean(PreferenceKeys.DEARROW, false)) return streamItems
val videoIds = streamItems.mapNotNull { it.url?.toID() }.joinToString(",")
val videoIds = streamItems.mapNotNull { it.url?.toID() }
.sorted()
.toSet()
.joinToString(",")
val response = try {
RetrofitInstance.api.getDeArrowContent(videoIds)
} catch (e: Exception) {
@ -55,7 +59,11 @@ object DeArrowUtil {
if (!PreferenceHelper.getBoolean(PreferenceKeys.DEARROW, false)) return contentItems
val videoIds = contentItems.filter { it.type == "stream" }
.joinToString(",") { it.url.toID() }
.map { it.url.toID() }
.sorted()
.toSet()
.joinToString(",")
if (videoIds.isEmpty()) return contentItems
val response = try {