You Tube API – recall Video Meta files with .NET

image.png

 

A loooong time ago I’ve blogged about how to access to You Tube with the Google Data APIs. After all that time there are several new ways how to recall files. Google offers You Tube a “simple” surface. If you prefer to do low-Level HTTP calls it is also possible.

Aim: I want the files to this You Tube video – but I already have the URL:

http://www.youtube.com/watch?v=ItqQ2EZziB8 (different to my former Blogpost where I was searching stuff)

download the library with NuGet

For comfortable excess I recommend you Google Data APIs. You will find this on NuGet as well:

All you need is the Google.GData.Client and the Google.GData.YouTube package:

image

Code

(because my Testclient is a console application and I need the functionality from the System.Web Assembly I changed the whole Frameworkt to .NET 4.0)

Uri youTubeLink = new Uri("http://www.youtube.com/watch?v=ItqQ2EZziB8");
            var parameters = System.Web.HttpUtility.ParseQueryString(youTubeLink.Query);
            var videoId = parameters["v"];

            Uri youTubeApi = new Uri(string.Format("http://gdata.youtube.com/feeds/api/videos/{0}", videoId));
            YouTubeRequestSettings settings = new YouTubeRequestSettings(null, null);

            YouTubeRequest request = new YouTubeRequest(settings);
            var result = request.Retrieve<Video>(youTubeApi);

            Console.WriteLine(result.Title);
            Console.WriteLine(result.Description);
            Console.WriteLine(result.ViewCount);

            Console.ReadLine();

Declaration

In line 3 I take the “v” parameter for the video. In line 5 I apply empty YouTubeRequestSettings – with this I’m able to call every official service but I can’t leave comments or upload videos.

Afterwards the Video will be picked up with the request.Retrieve. Now I have several Meta information’s about the Video.

No “Retrive” Method?

During the development process I’ve recognized a strange problem – under the Request-Object I had no Retrieve or Get Method. I’m not sure what the problem is. At least the You Tube Request class is from the Google.YouTube namespace – maybe I got the wrong class.

More Informations on the YouTube API.NET side.

Result of my codes:

image

[Code on Google Code]

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

About the author

Written by Code Inside Team

Learn more about our team.

Comment on this post

Recent Posts

  • image1528-570x194_thumb.png
    Introduction to Redis on Windows & Redis usage with .NET

      Redis belongs to the NoSQL data banks and you will find it in the group of Key-Value Stores. Redis is often named “Blazing Fast” and according to the Stackoverflow Thread it is used to be two time (while writing) and three times (while reading) quicker than MongoDB. Even if the comparison is a little ...

  • Automated Security Analyser for ASP.NET websites

    Evil Hackers are lurking everywhere and many Web-applications are delicately and share “too much” with the attacker. A quick (first!) overview offers the Tool “ASafaWeb”. All the website does is making a few requests and writing an Analyses including problem solving’s. There are no permanent disadvantages (bad requests/ DoS attacks and so on). Example: KnowYourStack.com ...

  • image1489-570x194.png
    „Sign in with Twitter“ for your own ASP.NET WebApp

      “Sign in with Twitter” is a popular practice to authenticate the users on your website. One advantage compared to an own registration is the lower inhibition for the user. But on the other hand Twitter doesn’t fess up with all the information’s and you will get into a kind of addiction. At the end ...

  • image1485-570x194_thumb.png
    CodePlex is going to be updated

      CodePlex the Microsoft Open Source Project Hosting Plattform hasn’t changed that much in the last few years and for a few times I thought Microsoft stopped the whole developing process. But now I found out that there is still life in the project. Maybe it is because of the success of GitHub or because ...

  • image1474_thumb.png
    What does Adobe in the flash-free web? Magazine-Style Layouts with CSS Regions!

      Adobe is well known for Photoshop and Flash but of course there is a lot more. According to the “Future Post” from Google Adobe declared one of their big subjects on a Blogpost. I’m talking about the W3C Working Draft to CSS Regions. Adobe cooperates with the WebKit Team and W3C on this. What ...

Support us