[C#]How to rate youtube videos

10/21/2012 00:13 Naworia#1
Hello guys, in this tutorial I will show you how to rate specific youtube video with Google libraries for C#.

First you should submit an application to google.
So go to this link : [Only registered and activated users can see links. Click Here To Register...]
and create a project.

Note : I don't show you how to create project in google. So you can see some tutorials about it. It is really easy.

So as I said, we will use Google libraries to obtain some functions.
You can get these libraries from : [Only registered and activated users can see links. Click Here To Register...]

Add all libraries to your project and make this references:
Code:
using Google.GData.Client;
using Google.YouTube;
Put a button to your form. So when you click to button, it will rate video.
Add these codes to your button_click event:

Code:
YouTubeRequestSettings settings = new YouTubeRequestSettings("appname", "devkey", "account mail", "account pw");
YouTubeRequest request = new YouTubeRequest(settings);
We created our request object. We will use this to requesting datas to/from server.

What does need the object that named "request"? Video ID and rating count.
So we need specify video ID from video url.

Code:
Uri videoUrl = new Uri("http://gdata.youtube.com/feeds/api/videos/" + "videoID");
We will get videos from google server so we don't need full youtube url.

If you don't know that what is youtube video ID, it is like it:
Quote:
www.youtube.com/watch?v=XMb63nsvQMo

Red colored text is the ID.
Now we should create video object that holding the video informations.

Code:
Video video = request.Retrieve<Video>(videoUrl);
We just need to specify rating count. Do it like this:

Code:
video.Rating = 5
Ratings can be [1,2,3,4,5].

We did all we need. Except doing request to server.

Code:
request.Insert(video.RatingsUri, video);
Click to button that you created before, and done!

Please send message or come skype if you troubled with this tutorial.
10/22/2012 00:26 NoCheаtImPGM#2
I think it's can be so nice but please can you do a movie ?
Thanks in advance
10/22/2012 14:08 Naworia#3
I just will think it but i think i will not do.