From c62aadacfc47f558e89e5c492557ab053dc86023 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Fri, 21 Jul 2023 09:02:07 +0200 Subject: [PATCH] fix: improve filtering of DeArrow titles and thumbnails --- .../main/java/com/github/libretube/util/DeArrowUtil.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 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 81af0236b..a5882a2fe 100644 --- a/app/src/main/java/com/github/libretube/util/DeArrowUtil.kt +++ b/app/src/main/java/com/github/libretube/util/DeArrowUtil.kt @@ -19,10 +19,10 @@ object DeArrowUtil { } catch (e: Exception) { return null to null } - val newTitle = content.titles.maxByOrNull { it.votes }?.title - val newThumbnail = - content.thumbnails.filter { it.thumbnail != null }.maxByOrNull { it.votes } - ?.takeIf { !it.original }?.thumbnail + val newTitle = content.titles.firstOrNull { it.votes >= 0 || it.locked }?.title + val newThumbnail = content.thumbnails.firstOrNull { + it.thumbnail != null && !it.original && (it.votes >= 0 || it.locked) + }?.thumbnail return newTitle to newThumbnail }