From e6e70a597d544ea1010d94e48616787f9e1f21b1 Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Sat, 22 Jul 2023 17:26:47 +0100 Subject: [PATCH] Sort videoIds before performing DeArrow fetch. --- .../java/com/github/libretube/util/DeArrowUtil.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/github/libretube/util/DeArrowUtil.kt b/app/src/main/java/com/github/libretube/util/DeArrowUtil.kt index a5882a2fe..0a56860c1 100644 --- a/app/src/main/java/com/github/libretube/util/DeArrowUtil.kt +++ b/app/src/main/java/com/github/libretube/util/DeArrowUtil.kt @@ -32,7 +32,11 @@ object DeArrowUtil { suspend fun deArrowStreamItems(streamItems: List): List { 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 {