From 5488c489d10754586b2ca00b8ba6462e9ec30127 Mon Sep 17 00:00:00 2001 From: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Date: Thu, 25 Jul 2024 22:33:59 +0300 Subject: [PATCH] Clean up --- YoutubeExplode.Tests/PlaylistSpecs.cs | 3 ++- YoutubeExplode/Bridge/IPlaylistData.cs | 2 +- YoutubeExplode/Bridge/PlaylistBrowseResponse.cs | 2 +- YoutubeExplode/Bridge/PlaylistNextResponse.cs | 2 +- YoutubeExplode/Playlists/Playlist.cs | 8 ++++---- YoutubeExplode/Playlists/PlaylistClient.cs | 4 ++-- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/YoutubeExplode.Tests/PlaylistSpecs.cs b/YoutubeExplode.Tests/PlaylistSpecs.cs index 57235cf9..629173df 100644 --- a/YoutubeExplode.Tests/PlaylistSpecs.cs +++ b/YoutubeExplode.Tests/PlaylistSpecs.cs @@ -31,7 +31,7 @@ public async Task I_can_get_the_metadata_of_a_playlist() playlist .Description.Should() .Contain("Digital Analytics Fundamentals course on Analytics Academy"); - playlist.VideosCount.Should().Be(22); + playlist.Count.Should().Be(22); playlist.Thumbnails.Should().NotBeEmpty(); } @@ -83,6 +83,7 @@ public async Task I_can_get_the_metadata_of_any_available_playlist(string playli playlist.Url.Should().NotBeNullOrWhiteSpace(); playlist.Title.Should().NotBeNullOrWhiteSpace(); playlist.Description.Should().NotBeNull(); + playlist.Count.Should().NotBe(0); playlist.Thumbnails.Should().NotBeEmpty(); } diff --git a/YoutubeExplode/Bridge/IPlaylistData.cs b/YoutubeExplode/Bridge/IPlaylistData.cs index b6394c08..46e30ae4 100644 --- a/YoutubeExplode/Bridge/IPlaylistData.cs +++ b/YoutubeExplode/Bridge/IPlaylistData.cs @@ -12,7 +12,7 @@ internal interface IPlaylistData string? Description { get; } - int? VideosCount { get; } + int? Count { get; } IReadOnlyList Thumbnails { get; } } diff --git a/YoutubeExplode/Bridge/PlaylistBrowseResponse.cs b/YoutubeExplode/Bridge/PlaylistBrowseResponse.cs index 878d03fc..bffabe76 100644 --- a/YoutubeExplode/Bridge/PlaylistBrowseResponse.cs +++ b/YoutubeExplode/Bridge/PlaylistBrowseResponse.cs @@ -102,7 +102,7 @@ internal partial class PlaylistBrowseResponse(JsonElement content) : IPlaylistDa ?.GetStringOrNull(); [Lazy] - public int? VideosCount => + public int? Count => SidebarPrimary ?.GetPropertyOrNull("stats") ?.EnumerateArrayOrNull() diff --git a/YoutubeExplode/Bridge/PlaylistNextResponse.cs b/YoutubeExplode/Bridge/PlaylistNextResponse.cs index 06bfe545..c402d3b7 100644 --- a/YoutubeExplode/Bridge/PlaylistNextResponse.cs +++ b/YoutubeExplode/Bridge/PlaylistNextResponse.cs @@ -35,7 +35,7 @@ internal partial class PlaylistNextResponse(JsonElement content) : IPlaylistData public string? Description => null; [Lazy] - public int? VideosCount => + public int? Count => ContentRoot ?.GetPropertyOrNull("totalVideosText") ?.GetPropertyOrNull("runs") diff --git a/YoutubeExplode/Playlists/Playlist.cs b/YoutubeExplode/Playlists/Playlist.cs index e53e1bce..61e21322 100644 --- a/YoutubeExplode/Playlists/Playlist.cs +++ b/YoutubeExplode/Playlists/Playlist.cs @@ -12,7 +12,7 @@ public class Playlist( string title, Author? author, string description, - int? videosCount, + int? count, IReadOnlyList thumbnails ) : IPlaylist { @@ -34,12 +34,12 @@ IReadOnlyList thumbnails public string Description { get; } = description; /// - /// Count of total videos. + /// Total count of videos included in the playlist. /// /// - /// May be null in case of playlists with infinite videos (e.g. mixes). + /// May be null in case of infinite playlists (e.g. auto-generated mixes). /// - public int? VideosCount { get; } = videosCount; + public int? Count { get; } = count; /// public IReadOnlyList Thumbnails { get; } = thumbnails; diff --git a/YoutubeExplode/Playlists/PlaylistClient.cs b/YoutubeExplode/Playlists/PlaylistClient.cs index 7d3c1d08..38c60085 100644 --- a/YoutubeExplode/Playlists/PlaylistClient.cs +++ b/YoutubeExplode/Playlists/PlaylistClient.cs @@ -42,7 +42,7 @@ channelId is not null && channelTitle is not null // System playlists have no description var description = response.Description ?? ""; - var videosCount = response.VideosCount; + var count = response.Count; var thumbnails = response .Thumbnails.Select(t => @@ -65,7 +65,7 @@ channelId is not null && channelTitle is not null }) .ToArray(); - return new Playlist(playlistId, title, author, description, videosCount, thumbnails); + return new Playlist(playlistId, title, author, description, count, thumbnails); } ///