Skip to content

Repository files navigation

YoutubeExplode

BuildTestsNuGetNuGet

YoutubeExplode is a library that provides an interface to query metadata of YouTube videos, playlists and channels, as well as to resolve and download video streams and closed caption tracks. Behind a layer of abstraction, the library parses raw page content and uses reverse-engineered AJAX requests to retrieve information. As it doesn't use the official API, there's also no need for an API key and there are no usage quotas.

Screenshots

Download

Features

  • Retrieves information about videos, playlists, channels, media streams and closed caption tracks
  • Handles all types of videos, including legacy, signed, restricted, non-embeddable and unlisted videos
  • Works with media streams of all types -- muxed, embedded adaptive, dash adaptive
  • Downloads videos by exposing their media content as a stream
  • Parses and downloads closed caption tracks
  • All metadata properties are exposed using strong types and enums
  • Provides static methods to validate IDs and to parse IDs from URLs
  • Fully asynchronous API
  • Targets .NET Framework 4.5+, .NET Core 1.0+ and .NET Standard 1.1+
  • No need for an API key and no usage quotas

Usage

YoutubeExplode has a single entry point, the YoutubeClient class -- all available integration API can be accessed by calling methods of this class.

A lot of helper methods are provided as extensions for models, make sure to include corresponding using statements to see them.

Media streams come in 3 forms -- Muxed (video & audio), Audio (audio only) and Video (video only). Highest qualities are not available in muxed streams so you'll have to download separate streams and multiplex them yourself using tools like ffmpeg.

Parse ID from URL
varurl="https://www.youtube.com/watch?v=bnsUkE8i0tU";varid=YoutubeClient.ParseVideoId(url);// "bnsUkE8i0tU"
Get video info
varclient=newYoutubeClient();varvideo=awaitclient.GetVideoAsync("bnsUkE8i0tU");vartitle=video.Title;// "Infected Mushroom - Spitfire [Monstercat Release]"varauthor=video.Author;// "Monstercat"varduration=video.Duration;// 00:07:14
Download video
varclient=newYoutubeClient();varstreamInfoSet=awaitclient.GetVideoMediaStreamInfosAsync("bnsUkE8i0tU");varstreamInfo=streamInfoSet.Muxed.WithHighestVideoQuality();varext=streamInfo.Container.GetFileExtension();awaitclient.DownloadMediaStreamAsync(streamInfo,$"downloaded_video.{ext}");
Extract closed captions
varclient=newYoutubeClient();vartrackInfos=awaitclient.GetVideoClosedCaptionTrackInfosAsync("_QdPW8JrYzQ");vartrackInfo=trackInfos.First(t =>t.Language.Code=="en");vartrack=awaitclient.GetClosedCaptionTrackAsync(trackInfo);varcaption=track.GetByTime(TimeSpan.FromSeconds(61));vartext=caption.Text;// "And the game was afoot."
Get playlist info
varclient=newYoutubeClient();varplaylist=awaitclient.GetPlaylistAsync("PLQLqnnnfa_fAkUmMFw5xh8Kv0S5voEjC9");vartitle=playlist.Title;// "Igorrr - Hallelujah"varauthor=playlist.Author;// "randomusername604"varvideo=playlist.Videos.First();varvideoTitle=video.Title;// "Igorrr - Tout Petit Moineau"varvideoAuthor=video.Author;// "Igorrr Official"

Libraries used

About

The ultimate dirty YouTube library

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages