Skip to content

Commit

Permalink
merge youtubeExplode v6.2.13
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm360 committed Apr 30, 2023
2 parents 4c8119e + a8318c0 commit 5026db1
Show file tree
Hide file tree
Showing 18 changed files with 48 additions and 223 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ https://github.com/Etherna/YoutubeExplode/releases

# Changelog

## v6.2.13 (27-Apr-2023)

- Improved support for older target frameworks via polyfills.

## v6.2.12 (31-Mar-2023)

- Fixed an issue where calling `VideoClient.GetAsync(...)` failed with `Could not extract video upload date` on certain videos.
Expand Down
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Behind a layer of abstraction, this library works by scraping raw page data and exploiting reverse-engineered internal endpoints.

> 📝 Want to learn more about how YouTube works under the hood?
> See [Reverse-Engineering YouTube: Revisited](https://tyrrrz.me/blog/reverse-engineering-youtube-revisited).
> [Read this article](https://tyrrrz.me/blog/reverse-engineering-youtube-revisited).
## Install

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

<ItemGroup>
<PackageReference Include="CliWrap" Version="3.6.0" />
<PackageReference Include="FluentAssertions" Version="6.10.0" />
<PackageReference Include="Gress" Version="2.0.1" />
<PackageReference Include="FluentAssertions" Version="6.11.0" />
<PackageReference Include="Gress" Version="2.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" PrivateAssets="all" />
Expand Down
39 changes: 25 additions & 14 deletions YoutubeDownloader.Converter/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ This package relies on [FFmpeg](https://ffmpeg.org) under the hood.

- 📦 [NuGet](https://nuget.org/packages/YoutubeExplode.Converter): `dotnet add package YoutubeExplode.Converter`

> **Warning**:
> This package requires the [FFmpeg CLI](https://ffmpeg.org) to work, which can be downloaded [here](https://ffbinaries.com/downloads).
> Ensure that it's located in your application's probe directory or on the system's `PATH`, or provide a custom location yourself using one of the available method overloads.
## Usage

**YoutubeExplode.Converter** exposes its functionality by enhancing **YoutubeExplode**'s clients with additional extension methods.
To use them, simply add the corresponding namespace and follow the examples below.

> **Warning**:
> This package requires the [FFmpeg](https://ffmpeg.org) executable to work, which can be downloaded [here](https://ffbinaries.com/downloads).
> Ensure that it's located in your application's probe directory or on the system's `PATH`, or provide a custom location directly using various overloads.
### Downloading videos

You can download a video directly through one of the extension methods provided on `VideoClient`.
You can download a video directly to a file through one of the extension methods provided on `VideoClient`.
For example, to download a video in the specified format using the highest quality streams, simply call `DownloadAsync(...)` with the video ID and the destination path:

```csharp
Expand All @@ -40,9 +40,8 @@ Under the hood, this resolves the video's media streams, downloads the best cand
> If the specified output format is a known audio-only container (e.g. `mp3` or `ogg`) then only the audio stream is downloaded.
> **Warning**:
> Stream muxing is a resource-intensive process.
> You can improve the execution speed by making sure that both the input streams and the output file use the same format, which eliminates the need for transcoding.
> Currently, YouTube provides adaptive streams only in `mp4` and `webm` containers, with the highest quality video streams (e.g. 4K) only available in `webm`.
> Stream muxing is a resource-intensive process, especially when transcoding is involved.
> To avoid transcoding, consider specifying either `mp4` or `webm` for the output format, as these are the containers that YouTube uses for most of its streams.
### Customizing the conversion process

Expand Down Expand Up @@ -77,11 +76,23 @@ var youtube = new YoutubeClient();
var videoUrl = "https://youtube.com/watch?v=u_yIGGhubZs";
var streamManifest = await youtube.Videos.Streams.GetManifestAsync(videoUrl);

// Select streams (1080p60 / highest bitrate audio)
var audioStreamInfo = streamManifest.GetAudioStreams().GetWithHighestBitrate();
var videoStreamInfo = streamManifest.GetVideoStreams().First(s => s.VideoQuality.Label == "1080p60");
var streamInfos = new IStreamInfo[] { audioStreamInfo, videoStreamInfo };
// Select best audio stream (highest bitrate)
var audioStreamInfo = streamManifest
.GetAudioStreams()
.Where(s => s.Container == Container.Mp4)
.GetWithHighestBitrate();

// Download and process them into one file
// Select best video stream (1080p60 in this example)
var videoStreamInfo = streamManifest
.GetVideoStreams()
.Where(s => s.Container == Container.Mp4)
.First(s => s.VideoQuality.Label == "1080p60");

// Download and mux streams into a single file
var streamInfos = new IStreamInfo[] { audioStreamInfo, videoStreamInfo };
await youtube.Videos.DownloadAsync(streamInfos, new ConversionRequestBuilder("video.mp4").Build());
```
```

> **Warning**:
> Stream muxing is a resource-intensive process, especially when transcoding is involved.
> To avoid transcoding, consider prioritizing streams that are already encoded in the desired format (e.g. `mp4` or `webm`).
14 changes: 0 additions & 14 deletions YoutubeDownloader.Converter/Utils/Polyfills.Collections.cs

This file was deleted.

12 changes: 0 additions & 12 deletions YoutubeDownloader.Converter/Utils/Polyfills.Regex.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net5.0;netstandard2.1;netstandard2.0;net461;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.1;net461;net5.0</TargetFrameworks>
<IsPackable>true</IsPackable>
<PackageId>Etherna.$(AssemblyName)</PackageId>
</PropertyGroup>
Expand All @@ -14,10 +14,6 @@
<PackageProjectUrl>https://github.com/Etherna/youtube-downloader</PackageProjectUrl>
</PropertyGroup>

<ItemGroup>
<None Include="Readme.md" Pack="true" PackagePath="" Visible="false" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="CliWrap" Version="3.6.0" />
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
Expand All @@ -26,7 +22,7 @@
</PackageReference>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="all" />
<PackageReference Include="PolySharp" Version="1.12.1" PrivateAssets="all" />
<PackageReference Include="PolyShim" Version="1.2.0" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions YoutubeDownloader.DemoWpf/YoutubeDownloader.DemoWpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MaterialDesignColors" Version="2.1.1" />
<PackageReference Include="MaterialDesignThemes" Version="4.7.1" />
<PackageReference Include="MaterialDesignColors" Version="2.1.2" />
<PackageReference Include="MaterialDesignThemes" Version="4.8.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion YoutubeDownloader.Tests/YoutubeDownloader.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.10.0" />
<PackageReference Include="FluentAssertions" Version="6.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" PrivateAssets="all" />
Expand Down
2 changes: 1 addition & 1 deletion YoutubeDownloader/Bridge/PlayerSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ internal partial class PlayerSource

var operations = new List<ICipherOperation>();

foreach (var statement in CipherCallsite.Split(";"))
foreach (var statement in CipherCallsite.Split(';'))
{
var calledFuncName = Regex.Match(statement, @"\w+\.(\w+)\(\w+,\d+\)").Groups[1].Value;
if (string.IsNullOrWhiteSpace(calledFuncName))
Expand Down
29 changes: 0 additions & 29 deletions YoutubeDownloader/Utils/Polyfills.Collections.cs

This file was deleted.

29 changes: 0 additions & 29 deletions YoutubeDownloader/Utils/Polyfills.HashCode.cs

This file was deleted.

60 changes: 0 additions & 60 deletions YoutubeDownloader/Utils/Polyfills.Http.cs

This file was deleted.

12 changes: 0 additions & 12 deletions YoutubeDownloader/Utils/Polyfills.Regex.cs

This file was deleted.

13 changes: 0 additions & 13 deletions YoutubeDownloader/Utils/Polyfills.Streams.cs

This file was deleted.

9 changes: 0 additions & 9 deletions YoutubeDownloader/Utils/Polyfills.Strings.cs

This file was deleted.

2 changes: 1 addition & 1 deletion YoutubeDownloader/Utils/UriEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ private static IEnumerable<KeyValuePair<string, string>> EnumerateQueryParameter
? url.SubstringAfter("?")
: url;

foreach (var parameter in query.Split("&"))
foreach (var parameter in query.Split('&'))
{
var key = WebUtility.UrlDecode(parameter.SubstringUntil("="));
var value = WebUtility.UrlDecode(parameter.SubstringAfter("="));
Expand Down
Loading

0 comments on commit 5026db1

Please sign in to comment.