Skip to content

Commit 01a09c9

Browse files
CopilotTyrrrz
andauthored
Apply WhereNotNullOrWhiteSpace and Clamp from PowerKit
Agent-Logs-Url: https://github.com/Tyrrrz/YoutubeExplode/sessions/f3f87da8-cc96-49a0-ac22-283a67f732dd Co-authored-by: Tyrrrz <[email protected]>
1 parent 71a7b9f commit 01a09c9

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

YoutubeExplode.Converter/FFmpeg.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,9 @@ private static PipeTarget CreateProgressRouter(IProgress<double> progress)
135135
+ TimeSpan.FromSeconds(seconds);
136136

137137
progress.Report(
138-
Math.Clamp(
139-
processedDuration.TotalMilliseconds / totalDuration.Value.TotalMilliseconds,
140-
0,
141-
1
142-
)
138+
(
139+
processedDuration.TotalMilliseconds / totalDuration.Value.TotalMilliseconds
140+
).Clamp(0, 1)
143141
);
144142
}
145143
});

YoutubeExplode/Bridge/VideoWatchPage.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ along with ([\d,\.]+) other people"
9292
.GetElementsByTagName("script")
9393
.Select(e => e.Text())
9494
.Select(s => Regex.Match(s, @"ytplayer\.config\s*=\s*(\{.*\})").Groups[1].Value)
95-
.FirstOrDefault(s => !string.IsNullOrWhiteSpace(s))
95+
.WhereNotNullOrWhiteSpace()
96+
.FirstOrDefault()
9697
?.Pipe(Json.Extract)
9798
.Pipe(Json.TryParse);
9899

@@ -104,7 +105,8 @@ along with ([\d,\.]+) other people"
104105
.Select(s =>
105106
Regex.Match(s, @"var\s+ytInitialPlayerResponse\s*=\s*(\{.*\})").Groups[1].Value
106107
)
107-
.FirstOrDefault(s => !string.IsNullOrWhiteSpace(s))
108+
.WhereNotNullOrWhiteSpace()
109+
.FirstOrDefault()
108110
?.Pipe(Json.Extract)
109111
.Pipe(Json.TryParse)
110112
?.Pipe(j => new PlayerResponse(j))

0 commit comments

Comments
 (0)