Skip to content

Commit

Permalink
Handle paid videos in search (#775)
Browse files Browse the repository at this point in the history
  • Loading branch information
pvogt authored Feb 21, 2024
1 parent cb35878 commit 1b5b33e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions YoutubeExplode.Tests/TestData/VideoIds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ internal static class VideoIds
public const string AgeRestrictedSexual = "SkRSXFQerZs";
public const string AgeRestrictedEmbedRestricted = "hySoCSoH-g8";
public const string RequiresPurchase = "p3dDcKOFXQg";
public const string RequiresPurchaseDistributed = "qs3NZHVM_Ik";
public const string LiveStream = "jfKfPfyJRdk";
public const string LiveStreamRecording = "rsAAeyAr-9Y";
public const string WithBrokenTitle = "4ZJWv6t-PfY";
Expand Down
1 change: 1 addition & 0 deletions YoutubeExplode.Tests/VideoSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public async Task I_can_try_to_get_the_metadata_of_a_video_and_get_an_error_if_i
[Theory]
[InlineData(VideoIds.Normal)]
[InlineData(VideoIds.Unlisted)]
[InlineData(VideoIds.RequiresPurchaseDistributed)]
[InlineData(VideoIds.EmbedRestrictedByYouTube)]
[InlineData(VideoIds.EmbedRestrictedByAuthor)]
[InlineData(VideoIds.AgeRestrictedViolent)]
Expand Down
7 changes: 7 additions & 0 deletions YoutubeExplode/Bridge/SearchResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ internal class VideoData(JsonElement content)
[Lazy]
public string? ChannelId =>
AuthorDetails
?.GetPropertyOrNull("navigationEndpoint")
?.GetPropertyOrNull("browseEndpoint")
?.GetPropertyOrNull("browseId")
?.GetStringOrNull()
?? content
.GetPropertyOrNull("channelThumbnailSupportedRenderers")
?.GetPropertyOrNull("channelThumbnailWithLinkRenderer")
?.GetPropertyOrNull("navigationEndpoint")
?.GetPropertyOrNull("browseEndpoint")
?.GetPropertyOrNull("browseId")
Expand Down

0 comments on commit 1b5b33e

Please sign in to comment.