Skip to content

Commit

Permalink
Use new array syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrrrz committed Jan 11, 2024
1 parent 76a780a commit 5603e06
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 16 deletions.
10 changes: 4 additions & 6 deletions YoutubeExplode.Tests/PlaylistSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ public async Task I_can_get_videos_included_in_a_playlist()
.Select(v => v.Id.Value)
.Should()
.Contain(
new[]
{
[
"uPZSSdkGQhM",
"fi0w57kr_jY",
"xLJt5A-NeQI",
Expand All @@ -123,7 +122,7 @@ public async Task I_can_get_videos_included_in_a_playlist()
"8Kg-8ZjgLAQ",
"E9zfpKsw6f8",
"eBCw9sC5D40"
}
]
);
}

Expand All @@ -142,8 +141,7 @@ public async Task I_can_get_videos_included_in_a_large_playlist()
.Select(v => v.Id.Value)
.Should()
.Contain(
new[]
{
[
"RBumgq5yVrA",
"kN0iD0pI3o0",
"YqB8Dm65X18",
Expand All @@ -153,7 +151,7 @@ public async Task I_can_get_videos_included_in_a_large_playlist()
"x-IR7PtA7RA",
"N-8E9mHxDy0",
"5ly88Ju1N6A"
}
]
);
}

Expand Down
4 changes: 2 additions & 2 deletions YoutubeExplode/Bridge/PlaylistVideoData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ internal class PlaylistVideoData(JsonElement content)
.GetPropertyOrNull("lengthText")
?.GetPropertyOrNull("simpleText")
?.GetStringOrNull()
?.ParseTimeSpanOrNull(new[] { @"m\:ss", @"mm\:ss", @"h\:mm\:ss", @"hh\:mm\:ss" })
?.ParseTimeSpanOrNull([@"m\:ss", @"mm\:ss", @"h\:mm\:ss", @"hh\:mm\:ss"])
?? content
.GetPropertyOrNull("lengthText")
?.GetPropertyOrNull("runs")
?.EnumerateArrayOrNull()
?.Select(j => j.GetPropertyOrNull("text")?.GetStringOrNull())
.WhereNotNull()
.ConcatToString()
.ParseTimeSpanOrNull(new[] { @"m\:ss", @"mm\:ss", @"h\:mm\:ss", @"hh\:mm\:ss" });
.ParseTimeSpanOrNull([@"m\:ss", @"mm\:ss", @"h\:mm\:ss", @"hh\:mm\:ss"]);

[Lazy]
public IReadOnlyList<ThumbnailData> Thumbnails =>
Expand Down
4 changes: 2 additions & 2 deletions YoutubeExplode/Bridge/SearchResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ internal class VideoData(JsonElement content)
.GetPropertyOrNull("lengthText")
?.GetPropertyOrNull("simpleText")
?.GetStringOrNull()
?.ParseTimeSpanOrNull(new[] { @"m\:ss", @"mm\:ss", @"h\:mm\:ss", @"hh\:mm\:ss" })
?.ParseTimeSpanOrNull([@"m\:ss", @"mm\:ss", @"h\:mm\:ss", @"hh\:mm\:ss"])
?? content
.GetPropertyOrNull("lengthText")
?.GetPropertyOrNull("runs")
?.EnumerateArrayOrNull()
?.Select(j => j.GetPropertyOrNull("text")?.GetStringOrNull())
.WhereNotNull()
.ConcatToString()
.ParseTimeSpanOrNull(new[] { @"m\:ss", @"mm\:ss", @"h\:mm\:ss", @"hh\:mm\:ss" });
.ParseTimeSpanOrNull([@"m\:ss", @"mm\:ss", @"h\:mm\:ss", @"hh\:mm\:ss"]);

[Lazy]
public IReadOnlyList<ThumbnailData> Thumbnails =>
Expand Down
5 changes: 2 additions & 3 deletions YoutubeExplode/Channels/ChannelClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,12 @@ public async ValueTask<Channel> GetAsync(
return new Channel(
"UCuVPpxrm2VAgpH3Ktln4HXg",
"Movies & TV",
new[]
{
[
new Thumbnail(
"https://www.gstatic.com/youtube/img/tvfilm/clapperboard_profile.png",
new Resolution(1024, 1024)
)
}
]
);
}

Expand Down
5 changes: 2 additions & 3 deletions YoutubeExplode/Common/Thumbnail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ public Thumbnail(string url, Resolution resolution)
public partial class Thumbnail
{
internal static IReadOnlyList<Thumbnail> GetDefaultSet(VideoId videoId) =>
new[]
{
[
new Thumbnail(
$"https://img.youtube.com/vi/{videoId}/default.jpg",
new Resolution(120, 90)
Expand All @@ -52,7 +51,7 @@ internal static IReadOnlyList<Thumbnail> GetDefaultSet(VideoId videoId) =>
$"https://img.youtube.com/vi/{videoId}/hqdefault.jpg",
new Resolution(480, 360)
)
};
];
}

/// <summary>
Expand Down

0 comments on commit 5603e06

Please sign in to comment.