Skip to content

YoutubeExtractor is a library for .NET, written in C#, to extract the download link from YouTube videos, download them, and/or extract their audio track. It is based on the youtubeFisher project (http://youtubefisher.codeplex.com/) and aims to create an API instead of a GUI application.

Notifications You must be signed in to change notification settings

Foovanadil/YoutubeExtractor

 
 

Repository files navigation

YoutubeExtractor

Overview

YoutubeExtractor is a reusable library for .NET, written in C#, that allows to download videos from YouTube and/or extract their audio track (currently only for flash videos).

Credits

Code for resolving the video download links

Code for extracting MP3 and AAC audio tracks out of flash files.

License

YouTubeExtractor is licenced under the GNU General Public License version 2 (GPLv2)

Dependencies

  • .NET Framework 3.5

NuGet

YoutubeExtractor is available on NuGet!

Projects that use this library

Example code

Get the download URLs

// Our test youtube link
string link = "insert youtube link";

/*
 * Get the available video formats.
 * We'll work with them in the video and audio download examples.
 */
IEnumerable<VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(link);

Download the video

/*
 * Select the first .mp4 video with 360p resolution
 */
VideoInfo video = videoInfos
    .First(info => info.VideoType == VideoType.Mp4 && info.Resolution == 360);

/*
 * Create the video downloader.
 * The first argument is the video to download.
 * The second argument is the path to save the video file.
 */
var videoDownloader = new VideoDownloader(video, Path.Combine("D:/Downloads", video.Title + video.VideoExtension));

// Register the ProgressChanged event and print the current progress
videoDownloader.ProgressChanged += (sender, args) => Console.WriteLine(args.ProgressPercentage);

/*
 * Execute the video downloader.
 * For GUI applications note, that this method runs synchronously.
 */
videoDownloader.Execute();

Download the audio track

/*
 * We want the first extractable video with the highest audio quality.
 */
VideoInfo video = videoInfos
    .Where(info => info.CanExtractAudio)
    .OrderByDescending(info => info.AudioBitrate)
    .First();

/*
 * Create the audio downloader.
 * The first argument is the video where the audio should be extracted from.
 * The second argument is the path to save the audio file.
 */
var audioDownloader = new AudioDownloader(video, Path.Combine("D:/Downloads", video.Title + video.AudioExtension));

// Register the ProgressChanged event and print the current progress
audioDownloader.ProgressChanged += (sender, args) => Console.WriteLine(args.ProgressPercentage);

/*
 * Execute the audio downloader.
 * For GUI applications note, that this method runs synchronously.
 */
audioDownloader.Execute();

About

YoutubeExtractor is a library for .NET, written in C#, to extract the download link from YouTube videos, download them, and/or extract their audio track. It is based on the youtubeFisher project (http://youtubefisher.codeplex.com/) and aims to create an API instead of a GUI application.

Resources

Stars

Watchers

Forks

Packages

No packages published