Closed abhay991 closed 6 years ago
I didn't understand it clearly, but you wanna ask how to get video Information?
I'm getting it this way:
private async void button1_Click(object sender, EventArgs e)
{
var url = "YOUR YOUTUBE URL";
var id = YoutubeClient.ParseVideoId(url); // "YOUR YOUTUBE URL"
var client = new YoutubeClient();
var streamInfoSet = await client.GetVideoMediaStreamInfosAsync(id);
var video = await client.GetVideoAsync(id);
label1.Text = $"{video.Title}";
label2.Text = $"{video.Author}";
label3.Text = $"{video.Statistics.ViewCount}";
}
If I'm wrong, sorry.
It used to be like what you are suggesting, but the functionality was split up to make it more stable against YouTube's changes.
How YoutubeExplode is getting the stream infos or the video info is an implementation detail, and theoretically, it can change so that the requested endpoint will not be the same between the two. For example, upcoming changes to support #101 may require to use a different endpoint to resolve streams, rather than get_video_info
and as such you will still need to make two requests anyway.
To draw the bottom line, I have no plans for excessive optimization since it will be really hard to maintain later for me, so this is probably one of those things that are going to stay like that.
I asked this before as well but i wasn't clear i guess. I am thinking of reducing requests and i feel that GetVideoMediaStreamInfosAsync(id) method should be able to give either source (so we can grab duration and title) or if it's possible maybe give property for both. I don't think there is need of two request (cause i am processing say hundreds to thousands of requests daily). I guess giving source property in GetVideoMediaStreamInfosAsync would be great so we can customize it.