• This repository has been archived on 28/Sep/2020
  • Stars
    star
    813
  • Rank 56,088 (Top 2 %)
  • Language
    C#
  • Created over 12 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A .NET library, that allows to download videos from YouTube and/or extract their audio track (currently only for flash videos).

YoutubeExtractor

Flattr this

Overview

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

Target platforms

  • .NET Framework 3.5 and higher
  • Windows Phone 8
  • WinRT
  • Xamarin.Android
  • Xamarin.iOS

Note that Windows Phone 8, WinRT, Xamarin.Android and Xamarin.iOS only support the extraction of the download URLs

NuGet

YoutubeExtractor at NuGet

Install-Package YoutubeExtractor

License

YoutubeExtractor has two licenses;

The YouTube URL-extraction code is licensed under the MIT License

The audio extraction code that is originally from FlvExtract is licenced under the GNU General Public License version 2 (GPLv2)

Files that are GPLv2 licensed are explicitly marked with the GPLv2 header at the top of the file. All other files are implicitly MIT licensed.

Credits

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

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);
    
/*
 * If the video has a decrypted signature, decipher it
 */
if (video.RequiresDecryption)
{
    DownloadUrlResolver.DecryptDownloadUrl(video);
}

/*
 * 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.DownloadProgressChanged += (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();
    
/*
 * If the video has a decrypted signature, decipher it
 */
if (video.RequiresDecryption)
{
    DownloadUrlResolver.DecryptDownloadUrl(video);
}

/*
 * 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 progress events. We treat the download progress as 85% of the progress and the extraction progress only as 15% of the progress,
// because the download will take much longer than the audio extraction.
audioDownloader.DownloadProgressChanged += (sender, args) => Console.WriteLine(args.ProgressPercentage * 0.85);
audioDownloader.AudioExtractionProgressChanged += (sender, args) => Console.WriteLine(85 + args.ProgressPercentage * 0.15);

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

More Repositories

1

Espera

Espera is a media player that plays your music, YouTube videos, SoundCloud songs and has a special "party mode".
C#
233
star
2

Lager

A cross-platform settings storage for .NET
C#
59
star
3

FlagConsole

A .NET library, that helps to build text-based console application interfaces. It provides controls like panel, textfield, list view, menu and label. It also offers drawing capabilitys for rectangles, lines and ellipses/circles.
C#
53
star
4

FlagSync

FlagSync is a synchronization and backup tool, written in C#, that allows you to synchronize or backup your files with local folders (or an extern harddrive or flashdrive) and FTP-Servers, as well as synchronize your non-iPod MP3-Player with iTunes.
C#
38
star
5

FlagFtp

FlagFtp is a FTP library for .NET, that supports various operations, such as retrieving file lists, write and read from/to files, retrieving file and directory infos, etc...
C#
32
star
6

ClickOnceToSquirrelMigrator

A helper library for the migration from ClickOnce to Squirrel.Windows
C#
30
star
7

Espera.Mobile

C#
16
star
8

UnofficialGitterApp

An unofficial Android app for http://gitter.im
C#
14
star
9

Rareform

This is my personal common library, for .NET, written in C#. It contains classes and methods that I need in nearly every application I write. Feel free to use and contribute.
C#
12
star
10

ReactiveMarrow

This library extends Reactive Extensions with a few helpers
C#
11
star
11

SaneInAppBillingHandler

A sane wrapper over the Xamarin.InAppBilling library
C#
5
star
12

Espera.Network

Network classes and helpers for the Espera remote control API
C#
4
star
13

FlvExtract

A portable (PCL) .NET library that extracts the audio and/or video tracks from FLV files
C#
3
star
14

flagbug.github.com

My blog
CSS
1
star