HTML Logo by World Wide Web Consortium ( Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS. ocPortal 9 is superseded by Composr 10.

Head over to for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.

YouTube Channel Integration Block - Comments

Login / Search

 [ Join | More ]

YouTube Channel Integration Block by Jason Verhagen

Downloads: 1,216
Added: 12 August 2012
Rating: Item has a rating of 5 (Liked by Guest)

**IMPORTANT** If you have a previous version of this addon installed, see before upgrading this addon!

Integrate YouTube channels and playlists into your web site. Specify a YouTube channel name, username, or playlist and some other parameters and you can integrate YouTube videos and video info in your web site. The block can automatically update with new content as it is added t…

I will be looking at updating this addon in the very near future to use YouTube Data API v3 since YouTube Data API v2 is now deprecated.

I just wanted to post an update here that the updated addon is now live and more complete documentation is posted here: View topic: YouTube Channel Integration Block discussion -

Regarding the quota information in the previous comment, I was able to reduce the per/video quota usage from 9 units to 7 units. So a block that is set to grab 50 videos should have a maximum quota usage of 358 units (8 units + (7 units * 50 videos)) each time the block cache is regenerated (with the default block config settings, this would be no more than 24 times per day, per block usage instance). I will also mention that this quota usage is on a per block basis. Meaning, if you embed this block 10 times on your web site and each of the 10 blocks grabs 50 videos, then that would possibly be a maximum of 3580 units used each time the block cache is regenerated. The 'Time between updates' block configuration setting, the block cache parameter settings used, and how busy your web site is will determine the actual quota usage. Unless you are doing something crazy like using this block to create a very large video site or disabling the cache for the block on a really busy web site, the 50,000,000 units per day quota limit should suit the vast majority of web sites.

I am hoping to have this finished and tested sometime in the next 48 hours. I am making this as backward compatible as possible, but there will be a couple of things that will be lost or changed and some new things added. Also, the YouTube API v3 will require an API Key to make requests. I will post the steps to get your API Key at the bottom of this post so you can get a headstart on that.

1. The orderby block parameter no longer works. I am fetching the user upload playlist from the playlistItems.list API call and it does not support the orderby parameter.
2. The start-video block parameter usage is different. Previously, this mapped to the start-index API call parameter and let you call a second batch of videos from the API starting with the video number specified by start-video. i.e. if you needed more than 50 videos, you could specify a start-video of 51. The v3 API still limits the return to a maximum of 50 results and implements a next-page/prev-page mechanism for fetching additional videos. I won't be implementing that new mechanism in this addon, so you will be limited to using this block parameter within the first 50 videos. I will document and explain more about how to use this after I release the update.
3. The codename of the block update time configuration option is renamed to avoid any potential naming conflict in the future. If you are upgrading an existing YouTube Channel Integration block installation, this option will be reset to the default 60 minutes. If you changed the default previously, you will need to change it again.
4. Added API Key configuration option so the API key does not have to be specified in the block parameters.
5. The duration is now in a hh:mm:ss numeric format instead of mm:ss.
6. There is now a long description and a shortened description available. When adding the block to a page, you must decide whether you want all of the videos to have either a full description or a shortened version of the description (only if the description is very long). i.e. it is not something that can be specified on a per-video basis.
7. The star-rating images are no longer available from YouTube so I have now bundled them with the addon.
8. I have added the newer thumbnails: sddefault and maxresdefault. The start-frame, middle-frame, and last-frame thumbnails are no longer specified in the v3 API results, but they still appear to be available using the same URL format. For the thumbnail block parameter, it looks like thumbnail options 0, 1 and 2 are always available; it looks like 3, 4, and 5 are still available but not returned by the API call; and it looks like the two new thumbnail types (will be options 6 and 7) are not available for all videos. 
9. Some general code cleanup. Replaced tabs with spaces, continued with the heavy commenting of the code to make it easier for anybody that wants to hack it more to their liking, and changed the license from CC-BY to CC0 (public domain).

A couple of things I am still considering:
1. Add a block parameter to allow specifying a YouTube channel ID or playlist ID instead of a YouTube username. This would eliminate one API request and save three quota units each time the block generates the cached block.
2. Add an API key block parameter. If members of your site are allowed to use this block and you have your own API key specified as a config option, then all of your members' block usage would count toward your API key quota. Adding a block parameter would allow you to force members to get their own API key.

To get a YouTube API Key:
1. I believe you need a Google account (i.e. Gmail/Google+). If you do not have one, then you will probably need to get one.
2. Go here:
If you go to the Google Developers Console and don't see a blue Create Project button, then you either need to login to your Google account or sign up for an account.
3. Click the Create Project button.
4. Give it any name you want. Project ID can be left as-is. Then click the Create button. It may take a few moments for your project to be created and take you to the Project Dashboard.
5. Under the APIs & auth section of the menu, click APIs.
6. On the right hand side of the page, find and click the YouTube Data API.
7. Now click the Enable API button to enable this API for your project.
8. Under the APIs & auth section of the menu, click Credentials.
9. In the right panel of the page you should see a Create new Key button. Click it.
10. A Create a new key popup will appear. Click the Server key button.
11. A Create a server key and configure allowed IPs popup will appear. You can set IP addresses to the IP(s) used by your web server or just leave it blank. And then click the Create button.

You should now have a new key listed along with the API key string you will need.

Just some notes about the YouTube API quotas… There are two different quota limits imposed. One is on requests and one is on 'units'. Requests are limited to a maximum of 3000 requests per second. The other is based on 'units' and is currently set at 50,000,000 units per day. Each API request consists of various parts and each request and each part is assigned a unit value. The maximum unit quota usage this block should incur equals 8 units (3 units to get the uploads playlist from username and 5 units to get the basic playlist data) plus 9 units for each video that more data is gathered for. If you set up this block to grab the maximum 50 videos, it would incur 458 units (8 units + (9 units * 50 videos)) of usage against your daily quota of 50,000,000. If you are using this block addon to place your own channel videos on your own website, these limits should not pose any problems. If you are using this block addon to try to create a large video web site and want to include many videos from many different channels, then you will probably run into quota problems.

Last edit: by Jason Verhagen

There are too many online users to list.
Control functions:

Quick reply   Contract

Your name:
Your message: