sortVideos

protected open fun List<Video>.sortVideos(): List<Video>(source)

Sorts the video list for a hoster. Override this according to the user's preference. This function is called by the app and should not be called in the extension.

Usage examples:

// Sorts by quality
override fun List<Video>.sortVideos(): List<Video> {
val quality = preferences.getString(PREF_QUALITY_KEY, PREF_QUALITY_DEFAULT)!!
return sortedWith(
compareBy { it.quality.contains(quality) }
).reversed()
}
// Sorts by quality and hardsub language
override fun List<Video>.sortVideos(): List<Video> {
val quality = preferences.getString(PREF_QUALITY_KEY, PREF_QUALITY_DEFAULT)!!
val lang = preferences.getString(PREF_LANG_KEY, PREF_LANG_DEFAULT)!!
return sortedWith(
compareBy(
{ it.quality.contains(quality) },
{ it.quality.contains(lang) },
),
).reversed()
}