From 531e98dc37323a6cb54bcdb6af80d5d86e785c80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sven=20Kova=C4=8Di=C4=87?= Date: Wed, 25 Feb 2026 11:58:05 +0100 Subject: [PATCH] Refactor content length handling in StreamClient Allow downloading videos of unknown content length. That is necessary in scenarios when we the videos are being streamed. --- YoutubeExplode/Videos/Streams/StreamClient.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/YoutubeExplode/Videos/Streams/StreamClient.cs b/YoutubeExplode/Videos/Streams/StreamClient.cs index 634dadd5..65f71784 100644 --- a/YoutubeExplode/Videos/Streams/StreamClient.cs +++ b/YoutubeExplode/Videos/Streams/StreamClient.cs @@ -113,8 +113,7 @@ private async IAsyncEnumerable GetStreamInfosAsync( } var contentLength = await TryGetContentLengthAsync(streamData, url, cancellationToken); - if (contentLength is null) - continue; + var fileSize = contentLength is null ? new FileSize() : new FileSize(contentLength.Value); var container = streamData.Container?.Pipe(s => new Container(s)) @@ -151,7 +150,7 @@ streamData.VideoWidth is not null && streamData.VideoHeight is not null var streamInfo = new MuxedStreamInfo( url, container, - new FileSize(contentLength.Value), + fileSize, bitrate, streamData.AudioCodec, audioLanguage, @@ -169,7 +168,7 @@ streamData.VideoWidth is not null && streamData.VideoHeight is not null var streamInfo = new VideoOnlyStreamInfo( url, container, - new FileSize(contentLength.Value), + fileSize, bitrate, streamData.VideoCodec, videoQuality, @@ -185,7 +184,7 @@ streamData.VideoWidth is not null && streamData.VideoHeight is not null var streamInfo = new AudioOnlyStreamInfo( url, container, - new FileSize(contentLength.Value), + fileSize, bitrate, streamData.AudioCodec, audioLanguage,