How to get Channel info from channel url of Youtube using Youtube Expoder
Youtube Expoder
Hi user to we gona show to you how to use Youtube expoder in asp,net c# and having use this we get the information of any youtubr chane
like channel name ,description total like ,total subscribe ,total Unlike and more
1>Fiest create new asp.net c# apllication
2>take one page with any name
3> first all youtube need to do download youtube expoder from nuget package manager or from visual studi Tool>Nuget package manager>package manager console
or Tool>Nuget package manager>package manager setting when you download this in your project soluation please rebuild your aaplication
4 now take one textbox in which you fill chanel Id and take one button
for display the message we take table and that table we display chanel info
like that
Now work in code behind
take using YoutubeExplode; name space if want to know abot namespace please click on this
Go to design view take page Async="true"
Like this<%@ Page Language="C#" AutoEventWireup="true" Async="true" CodeBehind="WebForm6.aspx.cs" Inherits="YT.WebForm6" %>
Now work on button click event
protected void btngetdetails_Click(object sender, EventArgs e)
{
BindChannel();
}
private void BindChannel()
{
if (txtenterchanellurl.Text.Trim()!="") //here we are cheking there is null value in txtenterchanellurl if if null we dont do any action youcan show the message to user please enter channel url or else
{
// From gere we calling YoutubeClient.ParseChannelId to get the Channel id from channel url ParseChannelId search the channel id from url and validate the Id is channel id or not
var id = YoutubeClient.ParseChannelId(txtenterchanellurl.Text.Trim());
BindChanellDetaislAsync(id);
}
}
private async void BindChanellDetaislAsync(string id)
{
// This section are generating the youtube client service
var client = new YoutubeClient();
//here we geting the channel info to call GetChannelAsync method
var ChannelDetails = await client.GetChannelAsync(id.ToString());
lblchannelId.Text = ChannelDetails.Id.ToString();
lbltitle.Text= ChannelDetails.Title.ToString();
logoid.ImageUrl= ChannelDetails.LogoUrl;
}
i hope this article will help you if you have any query relate to this please ask us
0 Comments
Post a Comment