Reputation: 91
So I have is the address: https://www.youtube.com/watch?v=P1EtSBxm0S4 what I want is the youTube.Data.V3.Video class (I think)
Back in the V2 api, you could do something like this and get a Video object for YouTube ID.
YouTubeRequest request = new YouTubeRequest(settings);
Uri uri = new Uri("http://gdata.youtube.com/feeds/api/videos/P1EtSBxm0S4");
Google.YouTube.Video video = request.Retrieve<Video>(uri);
How do you do this in V3? The examples don't seem to cover it.
Upvotes: 3
Views: 2763
Reputation: 91
Maybe I should have been clearer that I am using the .NET API. Looking at it from the classes the API offers, the examples are... not intuitive as to going about it. At least for me. I think this is what I'm looking to do.
//you need to create the service object earlier
var request = youtubeService.Videos.List("snippet");
var EndOfURI = "P1EtSBxm0S4";
request.Id = EndOfURI;
var response = request.Execute();
if (response.Items.Count == 1)
{
Video video = response.Items[0];
//video.Snippet has most of what you want
}
Upvotes: 4
Reputation: 4185
Follow the doc at https://developers.google.com/youtube/v3/docs/videos/list and use the 'Try It!' section at the bottom.
Your request should look like https://www.googleapis.com/youtube/v3/videos?part=snippet%2CcontentDetails%2Cstatistics&id=P1EtSBxm0S4&key=YOUR_API_KEY
Upvotes: 0