Thursday, February 16, 2012

[Gd] Video Uploads from Your Site’s Community

| More

YouTube API Blog: Video Uploads from Your Site’s Community

The following scenario comes up all the time when we talk to developers: a website with an active readership is interested in soliciting videos from its community. While YouTube is a great place to host these videos, it takes some forethought to design a system that makes uploading as straightforward as possible while still adhering to YouTube API Terms of Service and best practices.

One crucial consideration is which account the videos will be uploaded to on YouTube. It’s tempting to design a system in which all videos are uploaded to a single “master” YouTube account, but this is always the wrong approach. While using a master account means that each uploader doesn’t need to register for their own YouTube account, a high rate of uploads into a single YouTube account is a good way to run afoul of the YouTube API’s quota system. Additionally, each uploader to YouTube agrees to YouTube’s Terms of Service, which says that they have the right to upload that content, and that the content does not violate our Community Guidelines. By taking responsibility for other users’ content, you are essentially putting your own account and YouTube standing at risk.

The approach we recommend instead is using AuthSub or OAuth 2 (please don’t use ClientLogin!) to authenticate users and allow users to access their YouTube accounts. Then, you can use the browser-based upload flow to transmit the video from users’ local drives to YouTube’s servers. Uploads spread across end users’ accounts are less likely to trigger quota errors. And since videos end up in individual accounts, each account owner takes responsibility for ensuring that their uploads comply with YouTube’s community guidelines. Videos uploaded via your site will show up in a user’s channel just like any of their other videos.

After a video’s been uploaded, you will almost certainly want to display it on your own site or on a YouTube channel page, which raises the question of how to keep track of videos that have been uploaded through your site but which end up in users’ own accounts. One option for doing this programmatically is via the use of developer tags; another approach is to make use of a local database and keep track of the YouTube video id returned by the API following each upload. Once you’ve identified uploaded videos that you’d like to feature, you could, for instance, add them to a playlist and embed that playlist on your site, or feature the playlist on the channel page of your own YouTube account.

Designing a system that adheres to these best practices takes a little work, but avoiding the common pitfalls will pay off in the long run. For existing code that you could use as-is or adapt on your own site, take a look at the YouTube Direct project. It consists of code that uses AuthSub, browser-based uploads, developer tags, and playlists to allow the users of any website to contribute video uploads.

—Jeff Posnick, YouTube API Team

No comments: