private TwitchVideoQuality TryFindQuality(List <TwitchVideoQuality> qualities, VideoQuality shouldQuality) { if (shouldQuality == VideoQuality.Source) { return(qualities.First()); } if (shouldQuality == Core.Enums.VideoQuality.AudioOnly) { return(qualities.Find(x => x.QualityString == TwitchVideoQuality.GetQualityString(TwitchVideoQuality.QUALITY_AUDIO))); } int fpsShould = shouldQuality.GetFps(); int resolutionYShould = shouldQuality.GetResolutionY(); //sometimes fps is near value, like 61 or 59 instead 60 return(qualities.Find(x => x.Fps.HasValue && Math.Abs(x.Fps.Value - fpsShould) < 3 && x.ResolutionY.HasValue && x.ResolutionY.Value == resolutionYShould)); }