From fbdd11b3e9325771fc82a9e670293f5fc4fe919d Mon Sep 17 00:00:00 2001 From: Bar Arnon Date: Sun, 2 May 2021 18:22:52 +0300 Subject: [PATCH] Update YoutubeExplode --- src/Service/Service.csproj | 2 +- src/Service/VideoQualityExtensions.cs | 38 --------------------------- src/Service/YoutubeFeed.cs | 11 ++++---- src/YouCast/MainWindow.xaml | 2 +- 4 files changed, 7 insertions(+), 46 deletions(-) delete mode 100644 src/Service/VideoQualityExtensions.cs diff --git a/src/Service/Service.csproj b/src/Service/Service.csproj index 58f1aa9..f147c6f 100644 --- a/src/Service/Service.csproj +++ b/src/Service/Service.csproj @@ -54,7 +54,7 @@ - + diff --git a/src/Service/VideoQualityExtensions.cs b/src/Service/VideoQualityExtensions.cs deleted file mode 100644 index e1399c9..0000000 --- a/src/Service/VideoQualityExtensions.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using YoutubeExplode.Videos.Streams; -using static YoutubeExplode.Videos.Streams.VideoQuality; - -namespace Service -{ - public static class VideoQualityExtensions - { - public static int GetResolution(this VideoQuality videoQuality) - { - switch (videoQuality) - { - case Low144: - return 144; - case Low240: - return 240; - case Medium360: - return 360; - case Medium480: - return 480; - case High720: - return 720; - case High1080: - return 1080; - case High1440: - return 1440; - case High2160: - return 2160; - case High3072: - return 3072; - case High4320: - return 4320; - default: - throw new ArgumentOutOfRangeException(nameof(videoQuality), videoQuality, message: null); - } - } - } -} \ No newline at end of file diff --git a/src/Service/YoutubeFeed.cs b/src/Service/YoutubeFeed.cs index 580327b..799ca3a 100644 --- a/src/Service/YoutubeFeed.cs +++ b/src/Service/YoutubeFeed.cs @@ -11,7 +11,6 @@ using Google.Apis.YouTube.v3.Data; using MoreLinq; using YoutubeExplode; -using YoutubeExplode.Videos; using Video = Google.Apis.YouTube.v3.Data.Video; using YouTubeService = Google.Apis.YouTube.v3.YouTubeService; @@ -150,10 +149,10 @@ async Task GetVideoUriAsync() { } - var streamManifest = await _youtubeClient.Videos.Streams.GetManifestAsync(new VideoId(videoId)); - var muxedStreamInfos = streamManifest.GetMuxed().ToList(); + var streamManifest = await _youtubeClient.Videos.Streams.GetManifestAsync(videoId); + var muxedStreamInfos = streamManifest.GetMuxedStreams().ToList(); var muxedStreamInfo = - muxedStreamInfos.FirstOrDefault(_ => _.VideoQuality.GetResolution() == resolution) ?? + muxedStreamInfos.FirstOrDefault(_ => _.VideoResolution.Height == resolution) ?? muxedStreamInfos.MaxBy(_ => _.VideoQuality); return muxedStreamInfo?.Url; @@ -166,8 +165,8 @@ public async Task GetAudioAsync(string videoId) async Task GetAudioUriAsync() { - var streamManifest = await _youtubeClient.Videos.Streams.GetManifestAsync(new VideoId(videoId)); - var audios = streamManifest.GetAudioOnly().ToList(); + var streamManifest = await _youtubeClient.Videos.Streams.GetManifestAsync(videoId); + var audios = streamManifest.GetAudioOnlyStreams().ToList(); return audios.Count > 0 ? audios.MaxBy(audio => audio.Bitrate).Url : null; diff --git a/src/YouCast/MainWindow.xaml b/src/YouCast/MainWindow.xaml index 8383642..d83bbcc 100644 --- a/src/YouCast/MainWindow.xaml +++ b/src/YouCast/MainWindow.xaml @@ -178,7 +178,7 @@