Skip to content

Commit

Permalink
Update YoutubeExplode
Browse files Browse the repository at this point in the history
  • Loading branch information
i3arnon committed May 2, 2021
1 parent 0e70622 commit fbdd11b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/Service/Service.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<PackageReference Include="morelinq" Version="[2.9.0]" />
<PackageReference Include="Newtonsoft.Json" Version="[12.0.2]" />
<PackageReference Include="System.ValueTuple" Version="[4.5.0]" />
<PackageReference Include="YoutubeExplode" Version="5.1.9" />
<PackageReference Include="YoutubeExplode" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
<Compile Include="**\*.cs" Exclude="obj\**" />
Expand Down
38 changes: 0 additions & 38 deletions src/Service/VideoQualityExtensions.cs

This file was deleted.

11 changes: 5 additions & 6 deletions src/Service/YoutubeFeed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -150,10 +149,10 @@ async Task<string> 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;
Expand All @@ -166,8 +165,8 @@ public async Task GetAudioAsync(string videoId)

async Task<string> 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;
Expand Down
2 changes: 1 addition & 1 deletion src/YouCast/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
<Button
x:Name="YoucastLink"
Style="{StaticResource LinkButton}"
Click="YoucastLink_OnClick" Content="YouCast v2.18."/>
Click="YoucastLink_OnClick" Content="YouCast v2.19."/>
<Label VerticalAlignment="Center" Content="Made by"/>
<Button
x:Name="TwitterLink"
Expand Down

0 comments on commit fbdd11b

Please sign in to comment.