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

  • Git-Pull Request mergen for beginners

    My project “KnowYourStack.com” (the working title was BizzBingo – a detailed blogpost will follow soon) lays on GitHub and I’ve recognized a Problem where Daniel Lang helped me a lot. At the end he created a Fork for my Project and laid a Pull Request: The question is: How do I transfer the changes to ...

  • Carriage Return / new line in Textareas

      A little task: each new text line (Carriage Return/ if you press enter ) in a Textarea should be an element on a list – so what’s the easiest way? Actual a basic element in the web and the user make aware distributions – so it would be fair to dignify it. Little MVC ...

  • WebDev Playground: dabblet.com for HTML/CSS, jsfiddler.com for JS & HUrl.it for REST

      What was reserved for mighty Desktop Apps in the past is now coming closer to the web. I’ve going to present three tools to you which are very useful for web developer. At least all the tools are quite cool in there functionality. Playground for HTML/CSS If you need a quick Playground for CSS ...

  • image1452_thumb.png
    Javascript to Dart Translator

      Dart, a Google Javascript alternative was presented a few months ago and the web developer scene are a little bit unsure about the usability of Dart. To declare the language Google has translated the Javascript basics into Dart. The result is this “Translator”. In my opinion the name doesn’t find that well because it’s ...

  • image1366-570x194.png
    Twitter Bootstrap as UI-kit

      HTML and CSS are not foreign words for me but I regret, I’m not a Web designer – I see myself as a webdeveloper. But at least a dressy side is a must. But thank good there are some ready “Systems”. Twitter Bootstrap Twitter Bootstrap is a Toolkit for every kind of Web applications. ...

Support us