OnTube 1.0.0
dotnet add package OnTube --version 1.0.0
NuGet\Install-Package OnTube -Version 1.0.0
<PackageReference Include="OnTube" Version="1.0.0" />
paket add OnTube --version 1.0.0
#r "nuget: OnTube, 1.0.0"
// Install OnTube as a Cake Addin #addin nuget:?package=OnTube&version=1.0.0 // Install OnTube as a Cake Tool #tool nuget:?package=OnTube&version=1.0.0
Ontube
<p align="center"> <img src='Images/ontube.png' alt='Icon'> </p>
OnTube is a library that provides an interface to easily convert YouTube videos to audio files and download them with any resolution. Behind a layer of abstraction, this library works by scraping raw page data and exploiting reverse-engineered internal endpoints.
Extension packages:
- OnTube.Converter — provides the ability to download and convert videos using FFmpeg.
You are free by using this project or its source code, for any purpose that will improve this package for future.
Installation
OnTube is available on NuGet. Install the provider package. See the in the docs for additional downloads.
dotnet add package OnTube
Usage
OnTube exposes its functionality through a single entry point — the OntubeAudioConverter
class.
Create an instance of this class and use the provided operations on Videos
and Audio
properties to send requests.
Videos
To download the video from YouTube.
using OnTube;
var youtube = new OntubeAudioConverter();
// You can specify the video URL
var videoUrl = "https://www.youtube.com/watch?v=BcmUqwC_2Uc";
// You can specify the Folder path for example in D
var folderPath = @"D:\music";
//You can specify the file name as you like
var fileName = "song1";
//Finally, you can specify the resolution of video
int quality = 360;
var downloadedVideo = await youtube.DownloadVideoAsync(videoUrl, folderPath, fileName, quality);
//check if every thing is going well
if (downloadedVideo.IsSuccess != false)
{
Console.WriteLine($"Audio file saved at: {downloadedVideo.Data}");
}
else
{
Console.WriteLine($"{downloadedVideo.Message}");
}
Downloading video streams
Every YouTube video has a number of streams available, differing in containers, video quality, bitrate, framerate, and other parameters.
Warning: Muxed streams contain both audio and video, but these streams are limited in quality (up to 720p30). Some videos when you download them in a low quality you got a video without sound so, try to download with high quality.
Audios
To convert the YT video to audio.
using OnTube;
var youtube = new OntubeAudioConverter();
// You can specify the video URL
var videoUrl = "https://www.youtube.com/watch?v=BcmUqwC_2Uc";
// You can specify the Folder path for example in D
var folderPath = @"D:\music";
//You can specify the file name as you like
var fileName = "song1";
var convertedAudio = await youtube.ConvertToAudioAsync(videoUrl, folderPath, fileName);
//check if every thing is going well
if (convertedAudio.IsSuccess != false)
{
Console.WriteLine($"Audio file saved at: {convertedAudio.Data}");
}
else
{
Console.WriteLine($"{convertedAudio.Message}");
}
Once the audio is obtained, you can find it in the purposed folder with a format of type mp3.
In the end don't hesitate to share your ability in developing this packge.
😁 Contributing
Pull requests are welcome but before that please open an issue first to discuss what you want to change. please follow me for more C# blogs linkedin
📎 License
This project is licensed under the MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- NReco.VideoConverter (>= 1.2.1)
- YoutubeExplode (>= 6.3.13)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 138 | 4/28/2024 |