A lightweight & simple .NET library to extract data from Youtube. The purpose of this project is to make it easier for developers to extract data from YouTube or any sources.
- Youtube
- Youtube Music
Youtube Search
using YoutubeSearchApi.Net.Models.Youtube;
using YoutubeSearchApi.Net.Services;
public static async Task AsyncMain()
{
using (var httpClient = new HttpClient())
{
YoutubeSearchClient client = new YoutubeSearchClient(httpClient);
var responseObject = await client.SearchAsync("black suit");
foreach (YoutubeVideo video in responseObject.Results)
{
Console.WriteLine(video.ToString());
Console.WriteLine("");
}
}
}
public static void Main(string[] args)
{
AsyncMain().GetAwaiter().GetResult();
}
Youtube Music Search
using YoutubeSearchApi.Net.Models.Youtube;
using YoutubeSearchApi.Net.Services;
public static async Task AsyncMain()
{
using (var httpClient = new HttpClient())
{
YoutubeMusicSearchClient client = new YoutubeMusicSearchClient(httpClient);
var responseObject = await client.SearchAsync("simple ringtone");
foreach (YoutubeVideo video in responseObject.Results)
{
Console.WriteLine(video.ToString());
Console.WriteLine("");
}
}
}
public static void Main(string[] args)
{
AsyncMain().GetAwaiter().GetResult();
}
services.AddHttpClient<YoutubeSearchClient>();
services.AddHttpClient<YoutubeMusicSearchClient>();
// MyController.cs
private readonly YoutubeSearchClient ytClient;
private readonly YoutubeMusicSearchClient ytmClient;
public MyController(YoutubeSearchClient ytClient, YoutubeMusicSearchClient ytmClient)
{
this.ytClient = ytClient;
this.ytmClient = ytmClient;
}
Issues and Pull requests are very welcome. Feel free to open issues and pull requests.