-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sort clip links & fix selected clip quality detection (#900)
- Loading branch information
Showing
6 changed files
with
49 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using TwitchDownloaderCore.TwitchObjects.Gql; | ||
|
||
namespace TwitchDownloaderCore.Tools | ||
{ | ||
public class ClipQualityComparer : IComparer<VideoQuality> | ||
{ | ||
public int Compare(VideoQuality x, VideoQuality y) | ||
{ | ||
if (x is null) | ||
{ | ||
if (y is null) return 0; | ||
return -1; | ||
} | ||
|
||
if (y is null) return 1; | ||
|
||
if (int.TryParse(x.quality, out var xQuality) | int.TryParse(y.quality, out var yQuality)) | ||
{ | ||
if (xQuality < yQuality) return 1; | ||
if (xQuality > yQuality) return -1; | ||
|
||
if (x.frameRate < y.frameRate) return 1; | ||
if (x.frameRate > y.frameRate) return -1; | ||
return 0; | ||
} | ||
|
||
return Math.Clamp(string.Compare(x.quality, y.quality, StringComparison.Ordinal), -1, 1) * -1; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletions
6
TwitchDownloaderCore/TwitchObjects/Gql/GqlClipTokenResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters