Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion YoutubeExplode/Search/SearchClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Net.Http;
using System.Runtime.CompilerServices;
using System.Threading;
using YoutubeExplode.Channels;
using YoutubeExplode.Common;
using YoutubeExplode.Exceptions;
using YoutubeExplode.Utils.Extensions;
Expand Down Expand Up @@ -70,6 +71,13 @@ public async IAsyncEnumerable<Batch<ISearchResult>> GetResultBatchesAsync(
videoData.ChannelId
?? throw new YoutubeExplodeException("Failed to extract the video channel ID.");

// Some videos have invalid channel IDs (e.g. just "UC"). Such videos appear to generally
// be unplayable anyway, so it's safe to skip them.
Comment thread
Tyrrrz marked this conversation as resolved.
// https://github.com/Tyrrrz/YoutubeExplode/issues/944
var parsedVideoChannelId = ChannelId.TryParse(videoChannelId);
if (parsedVideoChannelId is null)
continue;
Comment thread
Tyrrrz marked this conversation as resolved.

var videoThumbnails = videoData
.Thumbnails.Select(t =>
{
Expand Down Expand Up @@ -101,7 +109,7 @@ public async IAsyncEnumerable<Batch<ISearchResult>> GetResultBatchesAsync(
var video = new VideoSearchResult(
videoId,
videoTitle,
new Author(videoChannelId, videoChannelTitle),
new Author(parsedVideoChannelId.Value, videoChannelTitle),
videoData.Duration,
videoThumbnails
);
Expand Down
Loading