Sort internal playlists after stream updates

This commit is contained in:
Zair Leon
2026-11-16 18:31:55 -06:00
parent 323d86a002
commit 45e2cab1e9
5 changed files with 49 additions and 12 deletions
+17
View File
@@ -0,0 +1,17 @@
import { Collection } from '@freearhey/core'
import { Stream } from '../models'
// Keep internal playlists in the same order as playlist:format without
// performing its URL normalization, deduplication or network probing.
export function sortStreams(streams: Collection<Stream>): Collection<Stream> {
return streams.sortBy(
[
(stream: Stream) => stream.title,
(stream: Stream) => (stream.isGeoBlocked ? -1 : 0),
(stream: Stream) => (stream.isNot247 ? -1 : 0),
(stream: Stream) => stream.getVerticalResolution(),
(stream: Stream) => stream.url
],
['asc', 'desc', 'desc', 'desc', 'asc']
)
}