Skip to content

Commit

Permalink
fix: sort filtered video by bitrate
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalygashkov committed May 1, 2024
1 parent 41525f7 commit 45653c0
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/track.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const createVideoQualityFilter = (videos) => {
if (!quality) return [getBestTrack(videos)];
const trackQuality = String(quality).includes('p') ? quality : `${quality}p`;
const results = videos.filter((track) => track.quality === trackQuality);
results.sort((a, b) => b.bitrate.bps - a.bitrate.bps);
return results.length ? results : [getBestTrack(videos)];
};
};
Expand Down

0 comments on commit 45653c0

Please sign in to comment.