Mike
Mike

Reputation: 91

Youtube API v3, getting a video from a uri

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

Answers (2)

Mike
Mike

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

Related Questions