Giter Club home page Giter Club logo

youtubeexplode's Introduction

YoutubeExplode

Build Tests NuGet NuGet

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.

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
  • Supports media stream seeking and segmentation to circumvent throttling
  • 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

Screenshots

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.

You can also use YoutubeExplode.Converter to take care of multiplexing for you.

Parse ID from URL

var url = "https://www.youtube.com/watch?v=bnsUkE8i0tU";
var id = YoutubeClient.ParseVideoId(url); // "bnsUkE8i0tU"

Get video info

var client = new YoutubeClient();
var video = await client.GetVideoAsync("bnsUkE8i0tU");

var title = video.Title; // "Infected Mushroom - Spitfire [Monstercat Release]"
var author = video.Author; // "Monstercat"
var duration = video.Duration; // 00:07:14

Download video

var client = new YoutubeClient();
var streamInfoSet = await client.GetVideoMediaStreamInfosAsync("bnsUkE8i0tU");

var streamInfo = streamInfoSet.Muxed.WithHighestVideoQuality();
var ext = streamInfo.Container.GetFileExtension();
await client.DownloadMediaStreamAsync(streamInfo, $"downloaded_video.{ext}");

Extract closed captions

var client = new YoutubeClient();
var trackInfos = await client.GetVideoClosedCaptionTrackInfosAsync("_QdPW8JrYzQ");

var trackInfo = trackInfos.First(t => t.Language.Code == "en");
var track = await client.GetClosedCaptionTrackAsync(trackInfo);

var caption = track.GetByTime(TimeSpan.FromSeconds(61));
var text = caption.Text; // "And the game was afoot."

Get playlist info

var client = new YoutubeClient();
var playlist = await client.GetPlaylistAsync("PLQLqnnnfa_fAkUmMFw5xh8Kv0S5voEjC9");

var title = playlist.Title; // "Igorrr - Hallelujah"
var author = playlist.Author; // "randomusername604"

var video = playlist.Videos.First();
var videoTitle = video.Title; // "Igorrr - Tout Petit Moineau"
var videoAuthor = video.Author; // "Igorrr Official"

Libraries used

youtubeexplode's People

Contributors

tyrrrz avatar brunozell avatar slowlogicboy avatar dominicmaas avatar shaked6540 avatar jerriep avatar foritus avatar dr-beat avatar jpspringall avatar knightking100 avatar mercenaryntx avatar

Watchers

James Cloos avatar radia avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.