How to Implement a YouTube Video List into Sitefinity

How to Implement a YouTube Video List into Sitefinity

May 12, 2009 0 Comments

The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.


YouTube, which is owned by Google, offers an RSS Feed of video content from their website. Software developers can subscribe to these feeds, which include feeds by keyword, a user's playlist, and most watched videos. Although there are many feeds you can use, this article will show to how to retrieve a user's playlist and a list of videos based on a search. Then, bind them to a RadGrid.

Getting Started

**Sample code for this article can be found here.. **

First, you must obtain a ClientID and a Developer Key from Google:

Then, you must download the sample .NET project:

The project is called Google Data API Setup(

Once the sample project is downloaded, open it up in Visual Studio. In its current form, it is .NET 2.0 project. VS 208 will ask you to convert it to .NET 3.5. Here is the location of the project on your local machine:

<install path for Google Data API SDK>\Sources\Samples\YouTubeSample (by default it is
C:\Program Files\Google\Google Data API SDK\Sources\Samples\YouTubeSample)

The sample project has code necessary to use interact with YouTube plus the necessary assemblies from Google. You will also need to create a YouTube account and add a few videos to your favorites. Once your project is open in Visual Studio, you are ready to begin programming.

Out of the Box Bound Feeds

If you build the project, you will asked to login to Google. You must login to Google to upload videos, add comments and other features which involve you making changes on the YouTube site. To simply view a feed list, however, does not require logging into YouTube. The files in the project will show you how to bind other feeds to a RadGrid.


In this example, we will use YouTube's AuthSub authentication. This uses a unique Developer Key and a ClientID to login to YouTube, so essentially every user would login as you without having your user name and password. Once the user logs on, the system creates a session variable to keep the user logged into YouTube.

Since you will need to authenticate for many types of feeds, you should create a method that returns a YouTubeRequest object, which encapsulates this information and passes it to other objects, in your application. Here are the steps:

1. Create a new user control called YouTubeRadGrid.ascx
2. In the code behind, add this method:

    private static YouTubeRequest AuthenticateMe() 
        string clientID = "My_Client_ID"
        string developerKey = "My_Developer_Key"
        YouTubeRequestSettings settings = new YouTubeRequestSettings("example app", clientID, developerKey, HttpContext.Current.Session["token"as string); 
        YouTubeRequest request = new YouTubeRequest(settings); 
        return request; 

Get your Favorite Videos

After you have created your user account, selected some videos, and added them to your favorite list, you can now share them with users. You'll need to create a method in the YouTubeRadGrid.ascx.cs file to pull this data. Here is the code:

private static Feed<Video> GetMyFavoriteVideos() 
        YouTubeRequest request = AuthenticateMe(); 
        string username = "UserName"
        Feed<Video> feed = request.GetFavoriteFeed(username); 
        return feed; 

Replace the User Name string with your YouTube user name. This method returns a Feed<Video>, which will be the fields that a RadGrid can bind to show videos. The Video class is all the fields that a YouTube video can contain.

Get Videos Based on a Search

This method will also return Feed<Video> objects and will show a list of videos with the word puppy:

private static Feed<Video> GetSearchVideos() 
        YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri); 
        //order results by the number of views (most viewed first) 
        query.OrderBy = "viewCount"
        // search for puppies and include restricted content in the search results 
        // query.SafeSearch could also be set to YouTubeQuery.SafeSearchValues.Moderate 
        query.Query = "puppy"
        query.SafeSearch = YouTubeQuery.SafeSearchValues.Moderate; 
        YouTubeRequest request = AuthenticateMe(); 
        Feed<Video> videoFeed = request.Get<Video>(query); 
        return videoFeed; 

Binding the RadGrid

Place two RadGrids onto the page and subscribe to the NeedDataSource event for each of  them. Here is the code:

    protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) 
        Feed<Video> feed = GetSearchVideos(); 
        RadGrid1.DataSource = feed.Entries; 
    protected void RadGrid2_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) 
        Feed<Video> feed = GetMyFavoriteVideos(); 
        RadGrid2.DataSource = feed.Entries; 

End Result

At the end, the the puppy RadGrid looks like this:

Other Feeds

Google also offers several other feeds that you can subscribe to and later bind. For more info, please read this Developer Guide.


The Progress Team

View all posts from The Progress Team on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.

Comments are disabled in preview mode.
Latest Stories in
Your Inbox
More From Progress
The New Mobile Development Landscape
Download Whitepaper
IDC Spotlight Sitefinity Thumbnail
Choosing the Right Digital Experience Platform to Improve Business Outcomes
Download Whitepaper
The Fastest Way to Build Mobile Apps With Cloud Data
Watch Webinar