Tuesday, January 24, 2012

Watch History Comes to the API

There’s a new entry in the growing list of video feeds supported by the YouTube Data API: the watch history feed. This feed allows authenticated API users to retrieve their own YouTube viewing histories—retrieving the watch history of any other user is not allowed. The information in this new feed corresponds to the viewing history exposed on the YouTube website.

The feed could enable interesting new functionality in your applications. If your site displays a list of recommended videos for an authenticated user to watch, you might consider excluding those videos that have been already viewed, for instance. Or you might want to include a video that you discover the user has been watching over and over again. Knowing the sorts of videos that a user watches makes it easier for your application to algorithmically suggest other videos that might interest your users.

As with any functionality related to the YouTube API, the best place to ask questions about the new watch history feed is the YouTube API developer forum.

Cheers,
—Jeff Posnick, YouTube API Team

Thursday, December 29, 2011

Building Professional Video Sites with YouTube APIs

Using video on your website can add greater depth and richness for your audience. However, to do encoding, hosting and streaming right it takes some time and skill. If you’re lacking in either, here are some suggestions for sites that make it easy to help you setup video-based websites.




VidCaster is a video content management system, whose goal is to make building a website with video as easy as possible.

VidCaster makes use of custom URLs, video sitemaps, metadata, and thumbnails to integrate well with search engines. They provide lots of features to customize your video site, like uploading a logo, picking a theme and choosing custom colors, and you can even upload custom CSS. Using their video management interface, you can publish, unpublish and delete videos. VidCaster can even distribute the videos from your video site to third-party sites such as YouTube and Twitter, and they can also integrate analytics from third-party sources.

VidCaster uses OAuth2 with the YouTube API to manage the user’s YouTube account, using both SUP (Simple Update Protocol) and polling to make sure a user’s video site is always in sync with their YouTube channel. Companies that use VidCaster include AirBnB, Hackers and Founders, and Dirtcast.



By integrating closely with YouTube’s data API, VidCaster makes it easy for users to take advantage of YouTube’s video service from within their own custom video site.



Moviecom.tv tries to make it easy for businesses to build video sites about their company.

Like VidCaster, Moviecom.tv provides users with a variety of features to customize their video site. They too show videos hosted on YouTube, but their integration with YouTube doesn’t yet include all the features that VidCaster does — for instance, Moviecom.tv can show YouTube videos using the iframe player, but they haven’t yet integrated with YouTube’s data API. This is something they plan on doing early in 2012. Moviecom.tv also touts their mobile application which takes the friction out of recording and uploading video to the right place.

And they’re doing well at it — they were recently named a Red Herring Global 100 Winner. Internet World, City Index, and Staples are all example sites created using their platform:



Companies like VidCaster and Moviecom.tv are a welcome part of the online video ecosystem. As Moviecom.tv CEO Gillian O'Neil once noted, Moviecom.tv isn’t competing with YouTube. By enabling third-party video sites to embed YouTube videos, YouTube isn’t trying to get a bigger piece of the pie. They’re making the pie bigger.

Cheers,
—Shannon -jj Behrens, YouTube API Team

Wednesday, December 28, 2011

Understanding Playback Restrictions

Have you ever tried to show a user a YouTube video embedded on your site only to find out that they don’t have access to view it? For instance, if you try to play the video below, it’ll say “This video contains content from test_yt_owner, who has blocked it on copyright grounds.” There are many reasons why video playback can be restricted. The user might be in a country where the video is blocked, or the video’s content owner might have decided to block access to the video from all mobile applications.



While we strive to make YouTube content available everywhere, we believe it's important to give YouTube content owners the ability to control where their videos are viewed, which sometimes means you can't view videos in a certain country or on a certain device.

With enhanced content controls comes increased complexity. The only foolproof way to determine if a user has access to watch a video is to ask them to try watching it. So, if you’re writing an application and you’d like to prevent users from seeing videos that they don’t have the ability to watch, here are a list of things to check:

1. yt:accessControl

Videos that are available for embedding on third-party applications will have the following:

<yt:accesscontrol action='embed' permission='allowed' />
If you’d like to only search for videos that are embeddable, add format=5 to your query.

Just as a video can be embeddable or not, it can also be syndicatable or not:
<yt:accesscontrol action='syndicate' permission='allowed' />
A video that is embeddable but not syndicatable will play on YouTube.com or on other sites that embed the YouTube player, but may not play on devices such as mobile phones or TVs. If you’d like to learn more about retrieving videos suitable for playback on mobile devices, see the developer’s guide.

2. Geo Restrictions

Some videos may be restricted in certain countries. This restriction applies to where the viewer is located, not where your third-party server is located. For instance, if a video is blocked in the US, it will have the following:
<media:restriction type='country'
relationship='deny'>US</media:restriction>
When you make a query, you can add a restriction parameter to filter videos that will not be playable by a client with a specific IP or from a specific country.

3. yt:state

It’s also important to check the yt:state of the video in the API response. Even if yt:accessControl indicates that syndication is allowed, yt:state might override it. For example, a video that has limited syndication would have the following:
<app:control>
<yt:state name='restricted' reasoncode='limitedSyndication'>
Syndication of this video was restricted by its owner.
</yt:state>
</app:control>
You might also see the message, “Syndication of this video was restricted by the content owner.” Hence, even if the uploader allows syndication, the content owner could override that and disallow syndication. For example, this could happen if someone uploads a video that contains a soundtrack that is owned by another content owner.

4. Rentals

Some YouTube videos are rentals. You can tell that they are rentals because they have a media:price tag:
<media:price type='rent' price='1.99' currency='USD' yt:duration='PT2592000S' />
Note that the media:price tag is only included in the response if you use a developer key in the query. If you are building a non-browser based YouTube application where it would be impossible for the user to rent a video, you might want to filter out the rentals. You can do that by passing the parameter paid-content=false.

5. Other Restrictions not Currently Exposed via the API

There are even more subtle restrictions that occasionally come into play. Not all of these are currently queryable via the API. For instance, some videos are only playable on a certain set of domains. As I mentioned above, the only foolproof way to know if a user has access to watch a video is to have them try watching it.

Going back to the video above, you might be wondering why it won’t play. If you look at its video entry:

http://gdata.youtube.com/feeds/api/videos/1kIsylLeHHU?v=2&prettyprint=true

you’ll see that it’s blocked in all countries:
<media:restriction type='country' relationship='deny'>
BD BE BF...
</media:restriction>
Furthermore, both syndication and embedding are disallowed:
<yt:accesscontrol action='embed' permission='denied' />
<yt:accesscontrol action='syndicate' permission='denied' />
Hopefully this short blog post on video playback restrictions will help you write applications that have a better understanding of what videos users can and can’t watch. If you have any questions, you can ask them on our forum.

Cheers,
—Shannon -jj Behrens, YouTube API Team

Friday, December 16, 2011

YouTube Direct Keeps Growing

YouTube Direct, our open source platform for obtaining and moderating user-generated videos (and photos!), was first announced over two years ago. Since that time, the project has continued to grow, and we’re happy to announce the latest round of additional features.

Most notably, we’ve released a completely rewritten YouTube Direct upload client for iOS devices (seen below). You can find it in its own open source project, and it complements the existing upload client for Android devices. As with the Android client, we see the iOS code as a reference implementation and a starting point for developers who want to build their own branded applications that submit video or photos that could be moderated using YouTube Direct.





The biggest change in the 3.0 release of the YouTube Direct server code has to do with multitenancy. As explained in this guide, YouTube Direct administrators can now deploy their code to App Engine once, and have App Engine serve many different logical instances of YouTube Direct, each with their own submission queues and moderators. While not every YouTube Direct deployment will benefit from this new functionality, we see it being particularly useful for agencies and other organizations that might have multiple individual clients, each interested in keeping track of their own YouTube Direct submissions.

YouTube Direct powers a wide variety of video submission initiatives: sites as diverse as the New York Times’ Reflections on 9/11 project, DrugFree.org’s “You are not alone” and Google Developers
own “Share your story” page are running by YouTube Direct behind the scenes.

As always, please let us know about any specific issues you encounter with YouTube Direct or either of the mobile clients in the issue trackers associated with each open source project. If you have any general questions about YouTube Direct, we’d be happy to answer them in our YouTube API developer’s forum.

Cheers,
—Jeff Posnick, YouTube API Team

Wednesday, December 7, 2011

A Friendly Update

As you might have recently read, there’s an upcoming change that affects any “friends” you might have associated with your YouTube account. Your existing “friend” connections will be automatically converted into Address Book contacts, and when you visit YouTube.com you will be given the option of creating subscriptions to any or all of those accounts.

If you’re a developer, you might ask yourself how this impacts your existing code that uses the YouTube Data API. One specific feed that’s exposed via the API is no longer relevant: the friends activity feed. The users of your application may have converted their old friends to corresponding subscriptions, and in that case you can make use of a new feed in our staging environment that contains activity updates from the accounts you’re subscribed to:

 https://gdata.youtube.com/feeds/api/users/default/subtivity

As of right now on our staging server, and around December 14 in production, we will automatically translate requests to the existing friends activity feed’s URL into requests to the new subscriptions activity feed, rather than just returning an empty friends activity feed. While this translation will take place transparently behind the scenes, we encourage all developers who are using the friends activity feed to explicitly update their code to point to the new subscription activity feed as a best practice.

There are also API calls related to YouTube contact management that would accept either an email address (in a <gd:email> element) or a YouTube username (in a <yt:username> element). As a side effect of this migration, you can only use <yt:username> for these calls, which is what the API’s documentation has recommended doing all along. An attempt to use <gd:email> will lead to a HTTP 400 error response.

Thanks for bearing with us through these changes. If you have any questions or concerns, please let us know in our developer forum.

Cheers,
—Jeff Posnick, YouTube API Team

Monday, October 31, 2011

Insight Report Enhancements


YouTube Insight reports provide video owners with statistics about their viewership above and beyond public view count information. They’re a crucial tool when you want to find out more about the demographic or regional breakdown of your videos’ viewership, or what sites are embedding your videos. The YouTube API has provided a way for developers to retrieve YouTube Insight reports in a comma-separated value format for some time now, but there are some recent additions to the Insight retrieval process that we wanted to highlight.

First, we wanted to mention that the API allows developers to access Insight reports for an entire channel’s worth of videos, not just a single video. The appropriate base URL to use for downloading a channel report can be found when requesting the profile corresponding to the user who’s authenticated with the YouTube API, as described in our developer’s guide. The element looks something like:

<link rel='http://gdata.youtube.com/schemas/2007#insight.views' type='text/html' href='http://insight.youtube.com/video-analytics/csvreports?query=PlVJ88-zqkI&type=...'/>

It can be identified by the rel='http://gdata.youtube.com/schemas/2007#insight.views' attribute. As with single-video Insight retrieval, these reports are only available to the corresponding owner, so authenticating as the correct user is a must.

Current users of the Insight API know that we previously supported a rather restrictive set of custom date ranges for reports. We’re happy to announce that these restrictions have been relaxed—we now support date ranges that span 31 days (up from 28) and, more significantly, you can specify any arbitrary start date for your report going back to March 1, 2009. Please see our documentation for more information on formatting your custom date range parameters to take advantage of this historical data.

As always, we’re waiting to hear from you in our developer forum with any questions or comments.

Cheers,
—Jeffrey Posnick, YouTube API Team

Thursday, October 27, 2011

Upcoming YouTube API Events

It was a pleasure meeting YouTube developers at the recent GDD, DevFest and GTUG sessions in São Paulo, Buenos Aires, Moscow, Prague, Paris and Warsaw. We would like to let you know that our around-the-world API tour continues and we hope to meet you at one of our upcoming YouTube API presentations. Here is the list of currently planned YouTube sessions:
We will also be speaking at local GTUGs; for the most up to date information please check the event schedule of a GTUG near you. As always, upcoming event information can be found on our Google Developer Events Calendar available at http://code.google.com/events/.

Cheers,
--Jarek Wilkiewicz, YouTube API Team