Sort & format subtitle download options (#88)

Sorts the subtitle download options by community rating and downloads.

Also abbreviates the download count if it's large (eg 5133->5.1k).
This commit is contained in:
damontecres 2025-10-28 13:07:30 -04:00 committed by GitHub
parent af0e853c21
commit 1db48334ab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 32 additions and 5 deletions

View file

@ -42,6 +42,7 @@ import com.github.damontecres.wholphin.ui.components.EditTextBox
import com.github.damontecres.wholphin.ui.components.ErrorMessage
import com.github.damontecres.wholphin.ui.ifElse
import com.github.damontecres.wholphin.ui.tryRequestFocus
import com.github.damontecres.wholphin.util.abbreviateNumber
import org.jellyfin.sdk.model.api.RemoteSubtitleInfo
@Composable
@ -200,7 +201,7 @@ fun convertRemoteSubtitles(
if (op.forced == true) {
add("Forced")
}
add("${op.downloadCount ?: 0} downloads")
add("${abbreviateNumber(op.downloadCount ?: 0)} downloads")
}
Text(
text = strings.joinToString(" - "),

View file

@ -836,10 +836,17 @@ class PlaybackViewModel
try {
currentItemPlayback.value?.itemId?.let {
Timber.v("Searching for remote subtitles for %s", it)
val results by api.subtitleApi.searchRemoteSubtitles(
itemId = it,
language = language,
)
val results =
api.subtitleApi
.searchRemoteSubtitles(
itemId = it,
language = language,
).content
.sortedWith(
compareByDescending<RemoteSubtitleInfo> { it.communityRating }
.thenByDescending { it.downloadCount },
)
subtitleSearch.setValueOnMain(SubtitleSearch.Success(results))
}
} catch (ex: Exception) {