Add VideoStreamInfoExtension. Closes #31

This commit is contained in:
Hexah 2020-06-06 16:07:51 +02:00
parent 6e4fe9d588
commit 0d0b8f2185
1 changed files with 17 additions and 6 deletions

View File

@ -32,10 +32,21 @@ abstract class VideoStreamInfo extends StreamInfo {
: super(tag, url, container, size, bitrate);
}
// TODO: Implement VideoStreamExtension
// https://github.com/Tyrrrz/YoutubeExplode/blob/136b72bf8ca00fea7d6a686694dd91a485ca2c83/YoutubeExplode/Videos/Streams/IVideoStreamInfo.cs#L37-L60
/*
/// Extensions for [VideoStreamInfo[
extension VideoStreamInfoExtension on VideoStreamInfo {
/// Extensions for Iterables of [VideoStreamInfo]
extension VideoStreamInfoExtension on Iterable<VideoStreamInfo> {
/// Gets all video qualities available in a collection of video streams.
Set<VideoQuality> getAllVideoQualities() =>
map((e) => e.videoQuality).toSet();
}*/
/// Gets video quality labels of all streams available in
/// a collection of video streams.
/// This could be longer than [getAllVideoQualities] since this gives also all
/// the different fps.
Set<String> getAllVideoQualitiesLabel() =>
map((e) => e.videoQualityLabel).toSet();
/// Gets the video stream with highest video quality.
List<VideoStreamInfo> sortByVideoQuality() => toList()
..sort((a, b) => b.framerate.compareTo(a.framerate))
..sort((a, b) => b.videoQuality.index.compareTo(a.videoQuality.index));
}