How should I use Youtube API?

What are some strategies for integrating YouTube in a Rails 3 app?

  • I'm diving into Rails 3 for the first time to build a web app that involves users uploading video. I want to offload the costs of hosting and streaming video to YouTube, but I don't know the best way to move forward with this part of the functionality. I see two directions I can go in: Easier to manage approach: Let the users upload videos to their own YouTube account via my Rails app or through YouTube, and then give the users the option to "Upload" or "Specify Video URL" in the HTML form. The downside is users have to setup and manage their own YouTube accounts, which most people don't already do. Better usability approach: Create a single YouTube account, owned and maintained by me, and only give users the ability to upload video via my web app to that YouTube account. This makes it easier for users to upload video since they don't need a YouTube account, improving the usability of my app. The downside is, the YouTube account will have to be managed, the YouTube limits will be reached quicker (meaning I'll have to delete older videos often), among other downsides. With those two approaches in mind, how would you add YouTube support to your Rails 3 app that allows the user to login to their YouTube account thru my web app? How would you add YouTube support to your Rails 3 app that allows the user to upload video to their YouTube account once logged in (Easier To Manage Approach) or my account (Better Usability Approach)? Would you use an existing Gem or write your own Rails 3 code to interact directly with the YouTube API? Are there other video hosting services you would consider using besides YouTube? Thanks so much in advance for your wisdom!

  • Answer:

    There are basically two parts to your YouTube integration.  The first is the back end integration, which addresses user authentication, video search, and all the operations exposed by YouTube's Restful API layer.  The other half is front end, which addresses video streaming and  interaction with video objects in real time. The YouTubeIt gem (https://github.com/kylejginavan/youtube_it) is, by my research, the best available back end API wrapper.  It lets you do search, etc. quite easily and has a very robust data model in my experience.  It also has some basic functionality for generating HTML to include the player in your page.  It's under fairly active maintenance by developers and seems fairly mature.  In order to use YouTube's api, you will need to create a developer key for your account, at http://code.google.com/apis/youtube/dashboard. The front end API is available directly through YouTube, and involves initializing an SWFObject which points to a DOM container on the page.  SWFObject is a javascript library, and is the preferred way of creating links to flash movies.  It can be downloaded here: http://code.google.com/p/swfobject/.  For instructions on how to use the swfobject and the Youtube JavaScript API, check out https://developers.google.com/youtube/js_api_reference.

Tom Lubitz at Quora Visit the source

Was this solution helpful to you?

Other answers

We (http://barrelrun.com) are doing exactly this.  After having tried first to manage this all ourselves we decided to just go with Youtube.  I don't think your second option will work very well, you will have to implement some kind of security on top of this one account so that users can't see/manage each others videos. We implemented your first suggestion and yes it means they need a Youtube Account, but most users that use Youtube for their company have one already anyway.  We use OAuth to connect their barrelrun account to their YouTube account.  Once this connection is made, they basically manage their Youtube Account via our website.  They never have to go to youtube to upload, edit or delete videos, we all handle this using the YouTube APIs.

Mark Vilrokx

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.