Skip to content

Commit

Permalink
Increase readability with ternary operator
Browse files Browse the repository at this point in the history
  • Loading branch information
ScrubN committed Feb 6, 2024
1 parent dac8051 commit 6d13c7f
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions TwitchDownloaderCore/Extensions/M3U8Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,35 +110,26 @@ public static string GetResolutionFramerateString(this M3U8.Stream stream)

if (streamInfo.Resolution == default)
{
if (stream.IsSource())
{
return "Source";
}

return "";
return stream.IsSource()
? "Source"
: "";
}

var frameHeight = streamInfo.Resolution.Height;

if (streamInfo.Framerate == default)
{
if (stream.IsSource())
{
return $"{frameHeight}p (Source)";
}

return $"{frameHeight}p";
return stream.IsSource()
? $"{frameHeight}p (Source)"
: $"{frameHeight}p";
}

// Some M3U8 responses have framerate values up to 2fps more/less than the typical framerate.
var frameRate = (uint)(Math.Round(streamInfo.Framerate / 10) * 10);

if (stream.IsSource())
{
return $"{frameHeight}p{frameRate} (Source)";
}

return $"{frameHeight}p{frameRate}";
return stream.IsSource()
? $"{frameHeight}p{frameRate} (Source)"
: $"{frameHeight}p{frameRate}";
}

/// <summary>
Expand Down

0 comments on commit 6d13c7f

Please sign in to comment.