GithubHelp home page GithubHelp logo

kylejginavan / youtube_it Goto Github PK

View Code? Open in Web Editor NEW
596.0 596.0 223.0 201.46 MB

An object-oriented Ruby wrapper for the YouTube GData API

Home Page: http://groups.google.com/group/ruby-youtube-library

Ruby 100.00%

youtube_it's Introduction

DONATION

YOUTUBE_IT is developed by many contributors who are passioned about opensource projects 
and selflessly donate their time and work. Following that spirit your donations to this project 
will be destined to the Tuquito Libre Foundation(http://fundacion.tuquito.org.ar) for developing 
technology projects intended to close the digital gap in Latin America.

<img src=http://www.pledgie.com/campaigns/16746.png?skin_name=chrome>

DESCRIPTION

youtube_it is the most complete Ruby client for the YouTube GData API. It provides an easy
way to access the latest and most complete access to YouTube's video API.
In comparison with the earlier Youtube interfaces, this new API and
library offers much-improved flexibility around executing complex search
queries to obtain well-targeted video search results.  In addition, standard video management 
including but not limited to uploading, deleting, updating, like, dislike, ratings and
comments.

INSTALLATION & SETUP:

* Create a youtube account.
* Create a developer key here http://code.google.com/apis/youtube/dashboard.
* sudo gem install youtube_it

Note: youtube_it supports ClientLogin(YouTube account), OAuth or AuthSub authentication methods.

Example Rails 3 App

You can get an example how you can use youtube_it with Rails 3 here: github.com/chebyte/youtube_it_rails_app_example

DEMO

You can see to youtube_it in action here: youtube-it.heroku.com

ESTABLISHING A CLIENT

Important: The Account Authentication API for OAuth 1.0, AuthSub and Client Login has been officially deprecated as of April 20, 2012. It will continue to work as per our deprecation policy(developers.google.com/accounts/terms), but we encourage you to migrate to OAuth 2.0 authentication as soon as possible. If you are building a new application, you should use OAuth 2.0 authentication.

Creating a client:

$ require 'youtube_it'
$ client = YouTubeIt::Client.new

Client with developer key:

$ client = YouTubeIt::Client.new(:dev_key => "developer_key")

Client with youtube account and developer key:

$ client = YouTubeIt::Client.new(:username => "youtube_username", :password =>  "youtube_passwd", :dev_key => "developer_key")

Client with AuthSub:

$ client = YouTubeIt::AuthSubClient.new(:token => "token" , :dev_key => "developer_key")

Client with OAuth:

$ client = YouTubeIt::OAuthClient.new("consumer_key", "consumer_secret", "youtube_username", "developer_key")
$ client.authorize_from_access("access_token", "access_secret")

Client with OAuth2:

$ client = YouTubeIt::OAuth2Client.new(client_access_token: "access_token", client_refresh_token: "refresh_token", client_id: "client_id", client_secret: "client_secret", dev_key: "dev_key", expires_at: "expiration time")

If your access token is still valid (be careful, access tokens may only be valid for about 1 hour), you can use the client directly. If you want to refresh the access token using the refresh token just do:

$ client.refresh_access_token!

PROFILES

you can use multiple profiles in the same account like that

$ profiles = client.profiles(['username1','username2']) 
$ profiles['username1'].username, "username1"

VIDEO QUERIES

Note: Each type of client enables searching capabilities.

Basic Queries:

$ client.videos_by(:query => "penguin")
$ client.videos_by(:query => "penguin", :page => 2, :per_page => 15)
$ client.videos_by(:query => "penguin", :restriction => "DE")
$ client.videos_by(:query => "penguin",  :author => "liz")
$ client.videos_by(:tags => ['tiger', 'leopard'])
$ client.videos_by(:categories => [:news, :sports])
$ client.videos_by(:categories => [:news, :sports], :tags => ['soccer', 'football'])
$ client.videos_by(:user => 'liz')
$ client.videos_by(:favorites, :user => 'liz')
$ client.video_by("FQK1URcxmb4")
$ client.video_by("https://www.youtube.com/watch?v=QsbmrCtiEUU")  
$ client.video_by_user("chebyte","FQK1URcxmb4")

Standard Queries:

$ client.videos_by(:most_viewed)
$ client.videos_by(:most_linked, :page => 3)
$ client.videos_by(:top_rated, :time => :today)
$ client.get_all_videos(:top_rated, :time => :today)
$ client.videos_by(:top_rated,  :region => "RU", :category => "News")

Advanced Queries (with boolean operators OR (either), AND (include), NOT (exclude)):

$ client.videos_by(:categories => { :either => [:news, :sports], :exclude => [:comedy] }, :tags => { :include => ['football'], :exclude => ['soccer'] })

Custom Query Params

You can use custom query params like that:

  $ client.videos_by(:query => "penguin", :safe_search => "strict")
  $ client.videos_by(:query => "penguin", :duration => "long")
  $ client.videos_by(:query => "penguin", :hd => "true")
  $ client.videos_by(:query => "penguin", :region => "AR")

you can see more options here https://developers.google.com/youtube/2.0/reference#yt_format

Fields Parameter(experimental features):

Return videos more than 1000 views
$ client.videos_by(:fields => {:view_count => "1000"})

Filter by date
$ client.videos_by(:fields => {:published  => (Date.today)})
$ client.videos_by(:fields => {:recorded   => (Date.today)})  

Filter by date with range
$ client.videos_by(:fields => {:published  => ((Date.today - 30)..(Date.today))})
$ client.videos_by(:fields => {:recorded   => ((Date.today - 30)..(Date.today))})

Note: These queries do not find private videos! Use these methods instead:

$ client.my_video("FQK1URcxmb4")
$ client.my_videos(:query => "penguin")

VIDEO MANAGEMENT

Note: YouTube account, OAuth or AuthSub enables video management.

Upload Video:

$ client.video_upload(File.open("test.mov"), :title => "test",:description => 'some description', :category => 'People',:keywords => %w[cool blah test])

Upload Remote Video:

$ client.video_upload("http://url/myvideo.mp4", :title => "test",:description => 'some description', :category => 'People',:keywords => %w[cool blah test])

Upload Video With A Developer Tag (Note the tags are not immediately available):

$ client.video_upload(File.open("test.mov"), :title => "test",:description => 'some description', :category => 'People',:keywords => %w[cool blah test], :dev_tag => 'tagdev')

Upload Video from url:

$ client.video_upload("http://media.railscasts.com/assets/episodes/videos/412-fast-rails-commands.mp4", :title => "test",:description => 'some description', :category => 'People',:keywords => %w[cool blah test])

Upload Private Video:

$ client.video_upload(File.open("test.mov"), :title => "test",:description => 'some description', :category => 'People',:keywords => %w[cool blah test], :private => true)

Update Video:

$ client.video_update("FQK1URcxmb4", :title => "new test",:description => 'new description', :category => 'People',:keywords => %w[cool blah test])

Delete Video:

$ client.video_delete("FQK1URcxmb4")

My Videos:

$ client.my_videos

My Video:

$ client.my_video(video_id)

Profile Details:

$ client.profile(user) #default: current user

List Comments:

$ client.comments(video_id)

Add A Comment:

$ client.add_comment(video_id, "test comment!")

Add A Reply Comment:

$ client.add_comment(video_id, "test reply!", :reply_to => another_comment)

Delete A Comment:

$ client.delete_comment(video_id, comment_id)

List Favorites:

$ client.favorites(user) # default: current user

Add Favorite:

$ client.add_favorite(video_id)

Delete Favorite:

$ client.delete_favorite(favorite_entry_id)

Like A Video:

$ client.like_video(video_id)

Dislike A Video:

$ client.dislike_video(video_id)

List Subscriptions:

$ client.subscriptions(user) # default: current user

Subscribe To A Channel:

$ client.subscribe_channel(channel_name)

Unsubscribe To A Channel:

$ client.unsubscribe_channel(subscription_id)

List New Subscription Videos:

$ client.new_subscription_videos(user) # default: current user

List Playlists:

$ client.playlists(user, order_by) # default: current user, position

for example you can get the videos of your playlist ordered by title

$ client.playlists(user, "title")

you can see more about options for order_by here: https://developers.google.com/youtube/2.0/reference#orderbysp

Select Playlist:

$ client.playlist(playlist_id)

Select All Videos From A Playlist:

$ playlist = client.playlist(playlist_id)
$ playlist.videos

Create Playlist:

$ playlist = client.add_playlist(:title => "new playlist", :description => "playlist description")

Delete Playlist:

$ client.delete_playlist(playlist_id)

Add Video To Playlist:

$ client.add_video_to_playlist(playlist_id, video_id, position)

Remove Video From Playlist:

$ client.delete_video_from_playlist(playlist_id, playlist_entry_id)

Update Position Video From Playlist:

$ client.update_position_video_from_playlist(playlist_id, playlist_entry_id, position)

Select All Videos From your Watch Later Playlist:

$ watcher_later = client.watcherlater(user) #default: current user
$ watcher_later.videos

Add Video To Watcher Later Playlist:

$ client.add_video_to_watchlater(video_id)

Remove Video From Watch Later Playlist:

$ client.delete_video_from_watchlater(watchlater_entry_id)

List Related Videos

$ video = client.video_by("https://www.youtube.com/watch?v=QsbmrCtiEUU&feature=player_embedded")
$ video.related.videos

Add Response Video

$ video.add_response(original_video_id, response_video_id)

Delete Response Video

$ video.delete_response(original_video_id, response_video_id)

List Response Videos

$ video = client.video_by("https://www.youtube.com/watch?v=QsbmrCtiEUU&feature=player_embedded")
$ video.responses.videos

BATCH VIDEOS

you can list many videos at the same time

$ client.videos(['video_id_1', 'video_id_2',...])

ACCESS CONTROL LIST

You can give permissions in your videos, for example denied comments, rate, etc...
you can read more there http://code.google.com/apis/youtube/2.0/reference.html#youtube_data_api_tag_yt:accessControl
you have available the followings options:
  • :rate, :comment, :commentVote, :videoRespond, :list, :embed, :syndicate

    with just two values:

  • allowed or denied

Example

client = YouTubeIt::Client.new(:username => "youtube_username", :password =>  "youtube_passwd", :dev_key => "developer_key")
  • upload video with denied comments

    client.video_upload(File.open(“test.mov”), :title => “test”,:description => ‘some description’, :category => ‘People’,:keywords => %w[cool blah test], :comment => “denied”)

Partial Updates

You can send a single PATCH request to add, replace and/or delete specific fields for a particular resource.

client.video_partial_update(video.unique_id, :list => 'denied', :embed => 'allowed')

User Activity

You can get user activity with the followings params:

$ client.activity(user) #default current user

Video Upload From Browser:

When uploading a video from your browser you need make a form upload with the followings params:

$ upload_token(params, nexturl)

params => params like :title => “title”, :description => “description”, :category => “People”, :keywords => [“test”] nexturl => redirect to this url after upload

Controller

def upload
  @upload_info = YouTubeIt::Client.new.upload_token(params, videos_url)
end

View (upload.html.erb)

<% form_tag @upload_info[:url], :multipart => true do %>
  <%= hidden_field_tag :token, @upload_info[:token] %>
  <%= label_tag :file %>
  <%= file_field_tag :file %>
  <%= submit_tag "Upload video" %>
<% end %>

WIDESCREEN VIDEOS

If the videos has support for widescreen:

$ video.embed_html_with_width(1280)

Note: you can specify width or just use the default of 1280.

USING HTML5

Now you can embed videos without use flash using html5, usefull for mobiles that not support flash but has html5 browser

You can specify these options

$ video.embed_html5({:class => 'video-player', :id => 'my-video', :width => '425', :height => '350', :frameborder => '1', :url_params => {:option_one => "value", :option_two => "value"},
fullscreen: true, :sandbox => "value"})

or just use with default options

$ video.embed_html5 #default: width: 425, height: 350, frameborder: 0

LOGGING

YouTubeIt passes all logs through the logger variable on the class itself. In Rails context, assign the Rails logger to that variable to collect the messages (don’t forget to set the level to debug):

$ YouTubeIt.logger = RAILS_DEFAULT_LOGGER
$ RAILS_DEFAULT_LOGGER.level = Logger::DEBUG

RUBY INTERPRETER COMPABILITY:

* 2.0
* 1.9.3
* 1.9.2

AUTHORS:

CONTRIBUTORS:

LICENSE:

MIT License

Copyright © 2010 Kyle J. Ginavan

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

youtube_it's People

Contributors

bobbytables avatar chebyte avatar ciur avatar dbackeus avatar dopin avatar fixato avatar girishso avatar herestomwiththeweather avatar iloveitaly avatar jarthod avatar julik avatar kfigiela avatar kylejginavan avatar lefty313 avatar mseppae avatar muffl0n avatar niels avatar parallel588 avatar philippelegrain avatar rafaelgaspar avatar ravbaker avatar rhodrid avatar sbounmy avatar tarko avatar tmm1 avatar winescout avatar yaauie avatar yoyostile avatar zentrification avatar zhu1230 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

youtube_it's Issues

NoMethodError: undefined method `text' for nil:NilClass when accessing commetns

Trying to get comments for videos and get NoMethodError:

This is from console:

NoMethodError: undefined method text' for nil:NilClass from /Users/stpn/.rvm/gems/ruby-1.9.3-p0/gems/youtube_it-2.0.1/lib/youtube_it/parser.rb:45:inparse_entry'
from /Users/stpn/.rvm/gems/ruby-1.9.3-p0/gems/youtube_it-2.0.1/lib/youtube_it/parser.rb:36:in block in parse_content' from /Users/stpn/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/rexml/element.rb:905:inblock in each'
from /Users/stpn/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/rexml/xpath.rb:67:in each' from /Users/stpn/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/rexml/xpath.rb:67:ineach'
from /Users/stpn/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/rexml/element.rb:905:in each' from /Users/stpn/.rvm/gems/ruby-1.9.3-p0/gems/youtube_it-2.0.1/lib/youtube_it/parser.rb:35:inparse_content'
from /Users/stpn/.rvm/gems/ruby-1.9.3-p0/gems/youtube_it-2.0.1/lib/youtube_it/parser.rb:15:in parse' from /Users/stpn/.rvm/gems/ruby-1.9.3-p0/gems/youtube_it-2.0.1/lib/youtube_it/request/video_upload.rb:160:incomments'
from /Users/stpn/.rvm/gems/ruby-1.9.3-p0/gems/youtube_it-2.0.1/lib/youtube_it/client.rb:122:in comments' from (irb):3 from /Users/stpn/.rvm/rubies/ruby-1.9.3-p0/bin/irb:16:in

'

Any suggestions? Great gem otherwise, thanks a lot!

Authentication Problem with Public Data

I'm trying to access a user's public subscriptions like this:

# Set up client
user_client = YouTubeIt::Client.new(:dev_key => "my_dev_key")

 # Load the user's activity
user_activity = user_client.subscriptions("my_username")

but it throws an exception:

AuthenticationError (Unknown)

It does this on any method that isn't support to require authentication.

Any help with this would be appreciated!

Getting videos from all pages

Is there a smarter/default way to do this?

class YouTubeIt::Client
  def all_videos_by(*args)
    page = videos_by(*args)
    videos = page.videos

    while page = page.next_page
      videos += page.videos
    end

    videos
  end
end

repo too big?

Fetching git://github.com/kylejginavan/youtube_it.git
remote: Counting objects: 1707, done.
remote: Compressing objects: 100% (857/857), done.
remote: Total 1707 (delta 1051), reused 1244 (delta 770)
Receiving objects: 100% (1707/1707), 139.23 MiB | 272 KiB/s, done.
Resolving deltas: 100% (1051/1051), done

Took me a good while

warning: regexp match /.../n against to UTF-8 string

youtube_it fails when query is an unicode string (for example):

c = YouTubeIt::Client.new
c.videos_by(:query => "спят усталые игрушки")

issues

youtube_it.rb:18: warning: regexp match /.../n against to UTF-8 string
youtube_it.rb:18: warning: regexp match /.../n against to UTF-8 string
youtube_it.rb:18: warning: regexp match /.../n against to UTF-8 string

and returns wrong list of videos (different then one from youtube.com search ).

REXML::ParseException: #<RuntimeError: Illegal character '&' in raw string "

Using ruby-1.9.2-p180 or ruby-1.9.3-rc1 the exception can be reproduced as follows:
client = YouTubeIt::Client.new
client.video_by("http://www.youtube.com/watch?v=ll68RgUIbks")
or
client.video_by("http://www.youtube.com/watch?v=wKjmbt_eTMs")

I'm aware that it works when you parse the unique_id yourself, but I'm quite sure most people expect this to be the responsiblity of the gem. And if a plain call to video_by can't be bothered to handle this, there should at least be a possibility to do this for example like so:
client.video_by(:url => "http://www.youtube.com/watch?v=wKjmbt_eTMs")

I think a lot of the users of this gem have their visitors pasting some YouTube-URL into an input field, so this would save them from parsing stuff on their own (which isn't likely to be future proof) e.g. like:

def get_unique_id
  uri = Addressable::URI.parse(youtube_url)
  if uri.path == "/watch"
    uri.query_values["v"] if uri.query_values
  else
    uri.path
  end
end

If the gem would do it, the devs could rely on it to handle future changes to the URL schema and could ideally just update it, and everyting works again.

Video#unique_id is nil when browsing playlist

Video#unique_id is nil when browsing playlist. Problem occurs because #video_id doesn't carry information on #unique_id. On the other hand, #unique_id is present in XML returned by YouTube API in yt:id tag in media:groupt

> client = YouTubeIt::Client.new
> client.playlist("21C62A3473376C47").videos[0].video_id
 => "tag:youtube.com,2008:playlist:21C62A3473376C47:PLyiwTzVYoxrm7UlMB2jGbokLoGU0nnBox"  # no unique_id here
> client.playlist("21C62A3473376C47").videos[0].player_url
 => "http://www.youtube.com/watch?v=aWEghdiY9cs&feature=youtube_gdata_player" 
> client.playlist("21C62A3473376C47").videos[0].unique_id
 => nil # returned, expected: aWEghdiY9cs

OAuth request being treated as AuthSub

I have generated an access token and secret, but when I try to grab any user information I get the following error:

a = YouTubeIt::OAuthClient.new(:consumer_key => 'consumer_key', :consumer_secret => 'consumer_secret', :dev_key => 'dev_key', :debug => true)
a.authorize_from_access('token', 'secret')
a.current_user
=> NoMethodError: undefined method `elements' for nil:NilClass

When I look at the body of the GET, it looks like the request is being treated as AuthSub.

a.access_token.get("http://gdata.youtube.com/feeds/api/users/default").body
=> "<HTML>\n<HEAD>\n<TITLE>Token invalid - Invalid AuthSub token.</TITLE>\n</HEAD>\n<BODY BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\">\n<H1>Token invalid - Invalid AuthSub token.</H1>\n<H2>Error 401</H2>\n</BODY>\n</HTML>\n"

Any thoughts?

Can't upload from S3

In my app I'm uploading a video to S3 and then trying to upload it to Youtube from there. I get this error:

RuntimeError: Cannot predict length of path/in/s3.mov

Thoughts?

parse_activity_videos is broken

When I tried

youtube_client.activity(user_id)

it will raise an error "NoMethodError Exception: undefined method `elements' for nil:NilClass"

the bug is here:

 https://github.com/kylejginavan/youtube_it/blob/master/lib/youtube_it/parser.rb#L218

the value of link_tag would be (when video_type is "video_rated"):

 "<link href='http://gdata.youtube.com/feeds/api/videos/videoid' rel='http://gdata.youtube.com/schemas/2007#video' type='application/atom+xml'/>"

then

YouTubeIt::Parser::VideoFeedParser.new(link_tag).parse

will be exceptional

here is a quick fix:

videos << YouTubeIt::Parser::VideoFeedParser.new(link_tag).parse if link_tag.elements["entry"]

gem version : 2.1.4

Error (unable to convert video file)

Hi Im new using rails and I need upload vieos on youtube, so Im trying to use youtube_it but when I try to upload a flv movie trough the gem, the video seems to be uploaded but when I consult it on youtube this error appear

Error (unable to convert video file)

Some idea?

Playlist.videos fails with HTTP 403 for private playlist

Video method calls YouTubeIt::Parser::VideosFeedParser directly with URL thus request doesn't have any OAuth data attached.

Example test code:

    c = YouTubeIt::OAuthClient.new(
        :consumer_key => GOOGLE_CONS_KEY,
        :consumer_secret => GOOGLE_CONS_SECRET,
        :dev_key => YOUTUBE_DEV_KEY
    )
    c.authorize_from_access(token, secret)

    playlists = c.playlists
    pp playlists.first
    pp playlists.first.videos

Results:

<YouTubeIt::Model::Playlist:0xb6872664

@description=nil,
@playlist_id="515918B2F7AFA494",
@published="2012-04-04T17:29:57.000Z",
@response_code=nil,
@summary=nil,
@title="testplaylist",
@xml=nil>
/var/lib/gems/1.8/gems/youtube_it-2.0.1/lib/youtube_it/parser.rb:8:in initialize': 403 (OpenURI::HTTPError) from /var/lib/gems/1.8/gems/youtube_it-2.0.1/lib/youtube_it/model/playlist.rb:6:innew'
from /var/lib/gems/1.8/gems/youtube_it-2.0.1/lib/youtube_it/model/playlist.rb:6:in `videos'
from providers.rb:29

'term' and 'label' are not defined for 'category'

To replicate this,

  1. Set client.
  2. Find video using url.
video = client.video_by("YOUTUBE_VIDEO_URL")
video.categories # => [#<YouTubeIt::Model::Category:0x007fef11139428 @term="Music", @label="Music">] 
video.categories.term # => NoMethodError: undefined method `term' for #<Array:0x007fef11137948>
video.categories.label # => NoMethodError: undefined method `label' for #<Array:0x007fef11137948>

exclude videos

have a way to exclude certain videos from the results.

FeedParser exception handling

While testing the gem I had a network problem and I was surprised to see that videos_by continued "working", but returning empty objects. I checked the code and the problem seems to be here:

https://github.com/kylejginavan/youtube_it/blob/master/lib/youtube_it/parser.rb#L9

class FeedParser #:nodoc:
  def initialize(content)
    @content = open(content).read        
  rescue OpenURI::HTTPError => e
    raise OpenURI::HTTPError.new(e.io.status[0],e)
  rescue
    @content = content
  end 

I don't understand the details of the first rescue but I guess for some reason it's important to re-raise it with different parameters. But the second rescue makes no sense to me, since it assigns content (a url, why is it called content?) to @content (the expected body response)? why don't leave the method raise the exception and let the caller decide how to handle it?

gem dependencies

As mentioned in the other ticket on faraday, you shouldn't be using hard version dependencies in your gemfile. I'm using this in a Rails app and the latest version that bundler can load right now is 2.1.1 because of the hard dependencies on old gems in the newer versions.

changelog needed

please provie a changelog / history for the gem.
it would be very useful. for example i don't know about the major changes - from 1.4 to 2.0.

its possible autoplay?

Hello I want to know if is possible add autoplay option in video player.

I dont find this option in readme.

Thank you very much

Improve Documentation on OAuth2 usage

I am new to OAuth & OAuth2. It looks like from looking at pull request and doumentation youtube_it supports OAuth2 but I could not find a good documentation for it.

Following pull request was helpful

https://github.com/kylejginavan/youtube_it/pull/46/files

By going the OAuth2 documentation

https://github.com/intridea/oauth2

I creating following actions to test OAuth2 support

  def get_access
    client = YouTubeIt::OAuth2Client.new(:client_id => 'client_id', :client_secret => 'client_secret')
    redirect_to client.oauth_client.auth_code.authorize_url(:redirect_uri => 'http://localhost:3000/oauth2callback', :scope => "https://gdata.youtube.com")
  end

  def oauth2callback
    client = YouTubeIt::OAuth2Client.new(:client_id => 'client_id', :client_secret => 'client_secret')
    @token = client.oauth_client.auth_code.get_token(params[:code], :redirect_uri => 'http://localhost:3000/oauth2callback', :headers => {'Authorization' => 'Basic authorization_code', :grant_type => "authorization_code"})
    #render :text => @token.token
    client = YouTubeIt::OAuth2Client.new(:client_access_token => @token.token, :client_refresh_token => @token.refresh_token, :client_id => 'client_id', :client_secret => 'client_secret', :dev_key => dev_key")
    @result = client.profile #videos_by({ :query => "lol", :page => 1, :per_page => 10 })
    render :text => @result.inspect
  end

There are two problems here

Current version is giving OAuth2 Error at client.profile call. Other thing is when I inspect returned token (i.e. @token) it does not have resresh_token. Furthermore following documentation suggests that we should pass grant_type parameter in token request

https://developers.google.com/youtube/2.0/developers_guide_protocol_oauth2#OAuth2_Server_Side_Web_Applications_Flow

But I could not set it as parameter in token request call.

Could someone shed light on how to use it. If possible also update documentation to make it more clear on usage otherwise I will send pull request once I understand it.

Release new gem version with oauth2

Hi!

I've seen that you have recently merged in the oauth2 patch in youtube_it. Thanks! Would it be at all possible to release a new gem version on rubygems so we can use it directly in our applications? That way, we wouldn't have to roll our own from our fork.

Thanks a lot.

Exception: #<RuntimeError: Illegal character '&' in raw string

I got this exception error in my application:

Exception: #<RuntimeError: Illegal character '&' in raw string "
var yt = yt || {};yt.timing = yt.timing || {};yt.timing.tick = function(label, opt_time) {var timer = yt.timing['timer'] || {};if(opt_time) {timer[label] = opt_time;}else {timer[label] = new Date().getTime();}yt.timing['timer'] = timer;};yt.timing.info = function(label, value) {var info_args = yt.timing['info_args'] || {};info_args[label] = value;yt.timing['info_args'] = info_args;};yt.timing.info('e', '903708,901601,911303');yt.timing.wff = true;yt.timing.info('an', '');yt.timing.tick('start');yt.timing.info('li','0');try {yt.timing['srt'] = window.gtbExternal && window.gtbExternal.pageT() ||window.external && window.external.pageT;} catch(e) {}if (window.chrome && window.chrome.csi) {yt.timing['srt'] = Math.floor(window.chrome.csi().pageT);}if (window.msPerformance && window.msPerformance.timing) {yt.timing['srt'] = window.msPerformance.timing.responseStart - window.msPerformance.timing.navigationStart;} ">
/home/donny/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/rexml/text.rb:91:in initialize' /home/donny/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/rexml/parsers/treeparser.rb:43:innew'
/home/donny/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/rexml/parsers/treeparser.rb:43:in parse' /home/donny/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/rexml/document.rb:227:inbuild'
/home/donny/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/rexml/document.rb:43:in initialize' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/bundler/gems/youtube_it-810e661994c8/lib/youtube_it/parser.rb:126:innew'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/bundler/gems/youtube_it-810e661994c8/lib/youtube_it/parser.rb:126:in parse_content' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/bundler/gems/youtube_it-810e661994c8/lib/youtube_it/parser.rb:9:inparse'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/bundler/gems/youtube_it-810e661994c8/lib/youtube_it/client.rb:89:in video_by' /home/donny/data/Projects/WGS/vortex/jotky-git/app/models/attached_item.rb:48:inretrieve_youtube_info'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:415:in _run_validation_callbacks' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activemodel-3.0.3/lib/active_model/validations/callbacks.rb:67:inrun_validations!'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activemodel-3.0.3/lib/active_model/validations.rb:179:in valid?' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activerecord-3.0.3/lib/active_record/validations.rb:55:invalid?'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activerecord-3.0.3/lib/active_record/autosave_association.rb:263:in association_valid?' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activerecord-3.0.3/lib/active_record/autosave_association.rb:252:invalidate_collection_association'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/will_paginate-2.3.15/lib/will_paginate/finder.rb:168:in method_missing' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activerecord-3.0.3/lib/active_record/associations/association_collection.rb:430:inmethod_missing_without_paginate'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activerecord-3.0.3/lib/active_record/associations/association_proxy.rb:216:in method_missing' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activerecord-3.0.3/lib/active_record/associations/association_proxy.rb:216:ineach'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activerecord-3.0.3/lib/active_record/associations/association_proxy.rb:216:in send' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activerecord-3.0.3/lib/active_record/associations/association_proxy.rb:216:inmethod_missing'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activerecord-3.0.3/lib/active_record/associations/association_collection.rb:430:in method_missing_without_paginate' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/will_paginate-2.3.15/lib/will_paginate/finder.rb:168:inmethod_missing'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activerecord-3.0.3/lib/active_record/autosave_association.rb:252:in validate_collection_association' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activerecord-3.0.3/lib/active_record/autosave_association.rb:180:insend'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activerecord-3.0.3/lib/active_record/autosave_association.rb:180:in validate_associated_records_for_attached_items' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:468:in_run_validate_callbacks'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activemodel-3.0.3/lib/active_model/validations.rb:212:in run_validations!' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activemodel-3.0.3/lib/active_model/validations/callbacks.rb:67:inrun_validations!'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:413:in _run_validation_callbacks' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activemodel-3.0.3/lib/active_model/validations/callbacks.rb:67:inrun_validations!'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activemodel-3.0.3/lib/active_model/validations.rb:179:in valid?' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activerecord-3.0.3/lib/active_record/validations.rb:55:invalid?'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activerecord-3.0.3/lib/active_record/validations.rb:75:in perform_validations' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activerecord-3.0.3/lib/active_record/validations.rb:43:insave'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activerecord-3.0.3/lib/active_record/attribute_methods/dirty.rb:21:in save' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activerecord-3.0.3/lib/active_record/transactions.rb:237:insave'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activerecord-3.0.3/lib/active_record/transactions.rb:289:in with_transaction_returning_status' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/database_statements.rb:139:intransaction'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activerecord-3.0.3/lib/active_record/transactions.rb:204:in transaction_without_trace_ActiveRecord_self_name_transaction' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/newrelic_rpm-2.13.4/lib/new_relic/agent/method_tracer.rb:319:intransaction'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/newrelic_rpm-2.13.4/lib/new_relic/agent/method_tracer.rb:141:in trace_execution_scoped' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/newrelic_rpm-2.13.4/lib/new_relic/agent/method_tracer.rb:314:intransaction'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activerecord-3.0.3/lib/active_record/transactions.rb:287:in with_transaction_returning_status' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activerecord-3.0.3/lib/active_record/transactions.rb:237:insave'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activerecord-3.0.3/lib/active_record/transactions.rb:248:in rollback_active_record_state!' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activerecord-3.0.3/lib/active_record/transactions.rb:236:insave'
/home/donny/data/Projects/WGS/vortex/jotky-git/app/controllers/jots_controller.rb:92:in create' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/action_controller/metal/mime_responds.rb:264:incall'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/action_controller/metal/mime_responds.rb:264:in retrieve_response_from_mimes' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/action_controller/metal/mime_responds.rb:191:inrespond_to'
/home/donny/data/Projects/WGS/vortex/jotky-git/app/controllers/jots_controller.rb:91:in create' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/action_controller/metal/implicit_render.rb:4:insend_action'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/action_controller/metal/implicit_render.rb:4:in send_action' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/abstract_controller/base.rb:151:inprocess_action'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/action_controller/metal/rendering.rb:11:in process_action' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/abstract_controller/callbacks.rb:18:inprocess_action'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:450:in _run__135333363__process_action__524098549__callbacks' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:409:insend'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:409:in _run_process_action_callbacks' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:93:insend'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:93:in run_callbacks' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/abstract_controller/callbacks.rb:17:inprocess_action'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/action_controller/metal/instrumentation.rb:30:in process_action' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activesupport-3.0.3/lib/active_support/notifications.rb:52:ininstrument'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activesupport-3.0.3/lib/active_support/notifications/instrumenter.rb:21:in instrument' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activesupport-3.0.3/lib/active_support/notifications.rb:52:ininstrument'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/action_controller/metal/instrumentation.rb:29:in process_action' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/action_controller/metal/rescue.rb:17:inprocess_action'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/newrelic_rpm-2.13.4/lib/new_relic/agent/instrumentation/rails3/action_controller.rb:34:in process_action' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/newrelic_rpm-2.13.4/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:252:inperform_action_with_newrelic_trace'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/newrelic_rpm-2.13.4/lib/new_relic/agent/method_tracer.rb:141:in trace_execution_scoped' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/newrelic_rpm-2.13.4/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:247:inperform_action_with_newrelic_trace'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/newrelic_rpm-2.13.4/lib/new_relic/agent/instrumentation/rails3/action_controller.rb:33:in process_action' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/abstract_controller/base.rb:120:inprocess'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/abstract_controller/rendering.rb:40:in process' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/action_controller/metal.rb:138:indispatch'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/action_controller/metal/rack_delegation.rb:14:in dispatch' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/action_controller/metal.rb:178:inaction'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:62:in call' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:62:indispatch'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:27:in call' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/rack-mount-0.6.13/lib/rack/mount/route_set.rb:148:incall'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/rack-mount-0.6.13/lib/rack/mount/code_generation.rb:93:in recognize' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/rack-mount-0.6.13/lib/rack/mount/code_generation.rb:103:inoptimized_each'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/rack-mount-0.6.13/lib/rack/mount/code_generation.rb:92:in recognize' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/rack-mount-0.6.13/lib/rack/mount/route_set.rb:139:incall'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:492:in call' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:50:incall_app!'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:32:in call!' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:19:incall'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:50:in call_app!' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:32:incall!'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:19:in call' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:50:incall_app!'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:32:in call!' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:19:incall'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:50:in call_app!' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:32:incall!'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:19:in call' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/oa-core-0.1.6/lib/omniauth/builder.rb:30:incall'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/newrelic_rpm-2.13.4/lib/new_relic/rack/developer_mode.rb:20:in call' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/haml-3.0.24/lib/sass/plugin/rack.rb:41:incall'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/warden-1.0.3/lib/warden/manager.rb:35:in call' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/warden-1.0.3/lib/warden/manager.rb:34:incatch'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/warden-1.0.3/lib/warden/manager.rb:34:in call' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/action_dispatch/middleware/best_standards_support.rb:17:incall'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/action_dispatch/middleware/head.rb:14:in call' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/rack-1.2.1/lib/rack/methodoverride.rb:24:incall'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/action_dispatch/middleware/params_parser.rb:21:in call' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/action_dispatch/middleware/flash.rb:182:incall'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/action_dispatch/middleware/session/abstract_store.rb:149:in call' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/action_dispatch/middleware/cookies.rb:295:incall'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activerecord-3.0.3/lib/active_record/query_cache.rb:32:in call' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/query_cache.rb:28:incache'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activerecord-3.0.3/lib/active_record/query_cache.rb:12:in cache' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activerecord-3.0.3/lib/active_record/query_cache.rb:31:incall'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:353:in call' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/action_dispatch/middleware/callbacks.rb:46:incall'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:415:in _run_call_callbacks' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/action_dispatch/middleware/callbacks.rb:44:incall'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/rack-1.2.1/lib/rack/sendfile.rb:107:in call' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/action_dispatch/middleware/remote_ip.rb:48:incall'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/action_dispatch/middleware/show_exceptions.rb:46:in call' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/railties-3.0.3/lib/rails/rack/logger.rb:13:incall'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/rack-1.2.1/lib/rack/runtime.rb:17:in call' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/activesupport-3.0.3/lib/active_support/cache/strategy/local_cache.rb:72:incall'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/rack-1.2.1/lib/rack/lock.rb:11:in call' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/rack-1.2.1/lib/rack/lock.rb:11:insynchronize'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/rack-1.2.1/lib/rack/lock.rb:11:in call' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/actionpack-3.0.3/lib/action_dispatch/middleware/static.rb:30:incall'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/railties-3.0.3/lib/rails/application.rb:168:in call' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/railties-3.0.3/lib/rails/application.rb:77:insend'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/railties-3.0.3/lib/rails/application.rb:77:in method_missing' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/railties-3.0.3/lib/rails/rack/log_tailer.rb:14:incall'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/rack-1.2.1/lib/rack/content_length.rb:13:in call' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/rack-1.2.1/lib/rack/chunked.rb:15:incall'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/rack-1.2.1/lib/rack/handler/mongrel.rb:67:in process' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:165:inprocess_client'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:164:in each' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:164:inprocess_client'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:291:in run' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:291:ininitialize'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:291:in new' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:291:inrun'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:274:in initialize' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:274:innew'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:274:in run' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/rack-1.2.1/lib/rack/handler/mongrel.rb:38:inrun'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/rack-1.2.1/lib/rack/server.rb:213:in start' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/railties-3.0.3/lib/rails/commands/server.rb:65:instart'
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/railties-3.0.3/lib/rails/commands.rb:30
/home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/railties-3.0.3/lib/rails/commands.rb:27:in tap' /home/donny/.rvm/gems/ree-1.8.7-2011.03@vortex/gems/railties-3.0.3/lib/rails/commands.rb:27 script/rails:6:inrequire'
script/rails:6
...
Illegal character '&' in raw string "
var yt = yt || {};yt.timing = yt.timing || {};yt.timing.tick = function(label, opt_time) {var timer = yt.timing['timer'] || {};if(opt_time) {timer[label] = opt_time;}else {timer[label] = new Date().getTime();}yt.timing['timer'] = timer;};yt.timing.info = function(label, value) {var info_args = yt.timing['info_args'] || {};info_args[label] = value;yt.timing['info_args'] = info_args;};yt.timing.info('e', '903708,901601,911303');yt.timing.wff = true;yt.timing.info('an', '');yt.timing.tick('start');yt.timing.info('li','0');try {yt.timing['srt'] = window.gtbExternal && window.gtbExternal.pageT() ||window.external && window.external.pageT;} catch(e) {}if (window.chrome && window.chrome.csi) {yt.timing['srt'] = Math.floor(window.chrome.csi().pageT);}if (window.msPerformance && window.msPerformance.timing) {yt.timing['srt'] = window.msPerformance.timing.responseStart - window.msPerformance.timing.navigationStart;} "
Line:
Position:
Last 80 unconsumed characters:
</script> <script> var yt = yt || {}; yt.preload = {}; yt.

How to solve this bug?

Ruby 1.9 error.

I am actually running this under JRuby, but I think you would get the same result in normal Ruby. It would be good to move this library to Nokogiri. I am lazy and just working around with jruby --1.8

REXML::ParseException: #<Encoding::CompatibilityError: incompatible encoding regexp match (ASCII-8BIT regexp with UTF-8 string)>
org/jruby/RubyRegexp.java:1414:in `=~'
org/jruby/RubyString.java:1588:in `=~'
/home/gweber/.rvm/rubies/jruby-1.6.4/lib/ruby/1.9/rexml/text.rb:131:in `check'
/home/gweber/.rvm/rubies/jruby-1.6.4/lib/ruby/1.9/rexml/text.rb:119:in `initialize'
/home/gweber/.rvm/rubies/jruby-1.6.4/lib/ruby/1.9/rexml/parsers/treeparser.rb:47:in `parse'
/home/gweber/.rvm/rubies/jruby-1.6.4/lib/ruby/1.9/rexml/document.rb:230:in `build'
/home/gweber/.rvm/rubies/jruby-1.6.4/lib/ruby/1.9/rexml/document.rb:43:in `initialize'
/home/gweber/.rvm/gems/jruby-1.6.4/gems/youtube_it-2.1.1/lib/youtube_it/parser.rb:78:in `parse_content'
/home/gweber/.rvm/gems/jruby-1.6.4/gems/youtube_it-2.1.1/lib/youtube_it/parser.rb:15:in `parse'
/home/gweber/.rvm/gems/jruby-1.6.4/gems/youtube_it-2.1.1/lib/youtube_it/request/video_upload.rb:226:in `playlists'
/home/gweber/.rvm/gems/jruby-1.6.4/gems/youtube_it-2.1.1/lib/youtube_it/client.rb:158:in `playlists'

YouTube_It::Client::OAuth2Client#current_user is a pointless waste of an API call

https://github.com/kylejginavan/youtube_it/blob/master/lib/youtube_it/client.rb#L450

YouTubeIt::Upload::VideoUpload does not need to know the username unless auth is via AuthSub/ClientLogin. This was a dirty hack in the first place, and it wasn't even necessary.

This call is damaging because it means each client has an API-call overhead of N+1, which is especially damaging for low N, such as when each client is only intending to make one request. With it in place on our distributed system (which makes one call per client), 100% of my rate limits (which happened often) were coming from this call, but with it removed, no limits were getting hit at all, even with high concurrency.

Link to a URL in youtube description box

Hi, I want make a custom modification in this gem for people who are on youtube, can find the website where the user uploaded the video.

In youtube description I have seen a lot of videos that have a url before the description you can see a example:

http://www.youtube.com/watch?v=AhdoE8GQeFo

and a tutorial for do it manual mode:

http://www.youtube.com/watch?v=1hyJfRMyKeI

When I make a new object in my app, I get a url with slug attribute sth like:

http://mydomain.com/object/object-title-slug

I have an attribute :slug. This attribute have a value object-title-slug

I want send to youtube this url http://mydomain.com/object/object-title-slug to description box before the description text sth like.

http://mydomain.com/object/object-title-slug this is the full description...bla bla bla....

Its possible add this functionality to this gem?

would be very grateful and would be helpful to youtube users.

unique_id for favorited videos

I have many examples where favorite videos are coming back with a video_id without the word 'videos' in it, so the unique_id is returning nil. Maybe YT just changed this.

video_id = "tag:youtube.com,2008:favorite:vjVQa1PpcFPfyaKcZJIbwsy1k2RZ5xS2z93alVDym6E" 
video_id[/videos\/([^<]+)/, 1] || video_id[/video\:([^<]+)/, 1]
=> nil

Cheers

NoMethodError: undefined method `elements' for nil:NilClass

YouTubeIt::Client.new(:dev_key => 'yourkey').videos_by(:video_id =>'W8FgayonSGE')
Submitting request [url=http://gdata.youtube.com/feeds/api/videos/W8FgayonSGE]

NoMethodError: undefined method elements' for nil:NilClass from /Users/kain/Sites/test/vendor/rails/activesupport/lib/active_support/whiny_nil.rb:52:inmethod_missing'
from /Users/kain/.gem/ruby/1.8/bundler/gems/youtube_it-e1e504affbc4/lib/youtube_it/parser.rb:182:in parse_content' from /Users/kain/.gem/ruby/1.8/bundler/gems/youtube_it-e1e504affbc4/lib/youtube_it/parser.rb:9:inparse'
from /Users/kain/.gem/ruby/1.8/bundler/gems/youtube_it-e1e504affbc4/lib/youtube_it/client.rb:75:in `videos_by'

faraday dependency conflict with twitter gem

twitter gem requires faraday 0.8, where youtube_it requries ~> 0.7.6, is there a particular reason we cannot upgrade to 0.8?

if ok I can create a pull request to update the gem version.

Thanks.

Caching results only possible with heavy serialization

Hello,
currently I'm trying to store results in a normal Rails.cache key. The only method that worked was to serialize the videos_by call directly to_yaml and then wrap in a YAML::load call, like so:

@youtube_response = YAML::load(Rails.cache.fetch(youtube_search.cache_key) { $youtube_client.videos_by(query: term).to_yaml })

The obvious error I get with no yaml involved:

@youtube_response = Rails.cache.fetch(youtube_search.cache_key) { $youtube_client.videos_by(query: term) }

is

TypeError (singleton can't be dumped).

Now, using yaml or other possible serialization that I haven't think of leads to a huge performance loss as from my tests, around 4 seconds just for retrieving from the cache and parse.

The solution might be that youtube_it implements proper serialization methods in code, like (links in order):
http://stackoverflow.com/questions/4228252/rails-cache-and-un-dumpable-marshal-structures-how-to-cache-on-the-example-f
https://github.com/hanklords/flickraw/issues#issue/16
hanklords/flickraw@d09db4c

Better dependency handling

Adding the youtube_it gem to my rails app adds the following dependencies:

  • builder
  • faraday
  • jeweler
  • oauth
  • oauth2
  • simple_oauth

That seems a bit much.

First off Jeweler should only be development dependency.

Second the OAuth gems should be optional (user has to manage the dependency himself) since I might not be using them at all or only one of them if I am.

Also I got a OAuth2 constant not found error when trying to run client.my_videos using the OAuth2Client without manually doing require 'oauth2' first. Nice thing to do would be if youtube_it would do the require 'oauth2' if needed and give a helpful error message if there is a LoadError (something like please add oauth2 to your Gemfile).

On a more personal note I would recommend skipping Jeweler altogether and go with the simpler manual gemspec managing instead - http://yehudakatz.com/2010/04/02/using-gemspecs-as-intended

Unable to Update Video

Testing out YouTubeIt. Everything works fine so far. Thanks for putting up this great gem. Unfortunately I am unable to update a video.

client = YouTubeIt::Client.new(
   :username => ENV['GMAIL_LOGIN'],
   :password =>  ENV['GMAIL_PASS'],
   :dev_key => ENV['YT_DEV_KEY']
)

client.video_update(
  youtube_id, # eg. IMqtB9rE2Lo
  :title => title,
  :description => description,
  :category => 'People'
)

throws

/home/besu/.rvm/gems/ruby-1.9.2-p180@youtube_it/gems/youtube_it-2.0.1/lib/youtube_it/request/video_upload.rb:361:in `block (2 levels) in video_xml': undefined method `join' for nil:NilClass (NoMethodError)
    from /home/besu/.rvm/gems/ruby-1.9.2-p180@youtube_it/gems/builder-3.0.0/lib/builder/xmlbase.rb:155:in `call'
    from /home/besu/.rvm/gems/ruby-1.9.2-p180@youtube_it/gems/builder-3.0.0/lib/builder/xmlbase.rb:155:in `_nested_structures'
    from /home/besu/.rvm/gems/ruby-1.9.2-p180@youtube_it/gems/builder-3.0.0/lib/builder/xmlbase.rb:63:in `method_missing'
    from /home/besu/.rvm/gems/ruby-1.9.2-p180@youtube_it/gems/builder-3.0.0/lib/builder/xmlbase.rb:34:in `tag!'
    from /home/besu/.rvm/gems/ruby-1.9.2-p180@youtube_it/gems/youtube_it-2.0.1/lib/youtube_it/request/video_upload.rb:358:in `block in video_xml'
    from /home/besu/.rvm/gems/ruby-1.9.2-p180@youtube_it/gems/builder-3.0.0/lib/builder/xmlbase.rb:155:in `call'
    from /home/besu/.rvm/gems/ruby-1.9.2-p180@youtube_it/gems/builder-3.0.0/lib/builder/xmlbase.rb:155:in `_nested_structures'
    from /home/besu/.rvm/gems/ruby-1.9.2-p180@youtube_it/gems/builder-3.0.0/lib/builder/xmlbase.rb:63:in `method_missing'
    from /home/besu/.rvm/gems/ruby-1.9.2-p180@youtube_it/gems/youtube_it-2.0.1/lib/youtube_it/request/video_upload.rb:357:in `video_xml'
    from /home/besu/.rvm/gems/ruby-1.9.2-p180@youtube_it/gems/youtube_it-2.0.1/lib/youtube_it/request/video_upload.rb:92:in `update'
    from /home/besu/.rvm/gems/ruby-1.9.2-p180@youtube_it/gems/youtube_it-2.0.1/lib/youtube_it/client.rb:103:in `video_update'
    from test.rb:10:in `<main>'

Has this one something to do with builder or am I just to dumb to use this method correctly? Sorry.

Set "Recorded date"?

Is it possible to pass with .video_update or .video_upload the "Recorded Date" attribute?

Documentation needed

It is very hard to dive into the code and the examples are not very helpful in many cases.

Minus Signs

I have noticed that YouTube vids with a video id preceded by a minus sign don't show up in search results. Only when removing the minus sign can it be found.

Example:

http://www.youtube.com/watch?v=-t2joAYI0JQ

[code with minus sign in video id]
video_id = "-t2joAYI0JQ"
client = YouTubeIt::Client.new
youtube_video = client.videos_by(:query => video_id).videos[0] # => nil

[code without minus sign in video id]
video_id = "t2joAYI0JQ"
client = YouTubeIt::Client.new
youtube_video = client.videos_by(:query => video_id).videos[0] # => results

problem with create_session_token

There is some problems with create_session_token and session_token_info functions

in view:

< a href="https://www.google.com/accounts/AuthSubRequest?next=http%3A%2F%2Fsome.site.com%3A3000%2Ff%2F39%2Fd%2Fg%2F5&amp;scope=http%3A%2F%2Fgdata.youtube.com&amp;secure=0&amp;session=1">Login to Youtube</a>

click -> grant access to application

in controller:

client = ::YouTubeIt::AuthSubClient.new(:token => params[:token])
client.create_session_token

in logs:

opening connection to www.google.com...
opened
<- "GET https:///accounts/AuthSubSessionToken HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded\r\nAuthorization: AuthSub token=1/GoyWxrcnDlixBRB-5QC8WTz9XUjwWv-9VWO8dQapP1M\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: www.google.com\r\n\r\n"
-> "HTTP/1.1 400 Bad Request\r\n"
-> "Content-Type: text/html; charset=UTF-8\r\n"
-> "Content-Length: 145\r\n"
-> "Date: Mon, 04 Jun 2012 14:01:32 GMT\r\n"
-> "Expires: Mon, 04 Jun 2012 14:01:32 GMT\r\n"
-> "Cache-Control: private, max-age=0\r\n"
-> "X-Content-Type-Options: nosniff\r\n"
-> "X-XSS-Protection: 1; mode=block\r\n"
-> "Server: GSE\r\n"
-> "\r\n"
reading 145 bytes...
-> "<HTML>\n<HEAD>\n<TITLE>Bad Request</TITLE>\n</HEAD>\n<BODY BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\">\n<H1>Bad Request</H1>\n<H2>Error 400</H2>\n</BODY>\n</HTML>\n"
read 145 bytes

insight_uri for Video returning nil?

I've been using YouTubeIt to download the Insight data CSV files for Channels, and I'd like to also start doing it for individual videos as well. I discovered that the inisght_uri property of the videos ends up being null.

Upon investigating this, it appears that the feed I get from YouTube for the video is missing this insight URI link element. After discussing this with YouTube API support, they are convinced that I didn't properly authenticate with YouTube to get the data. I used HTTPScoop to see what was happening under the hood. The GET that is being requested is:

http://gdata.youtube.com/feeds/api/videos/165_M-qhL9A?v=2&key=[redacted]

But what I get back from that doesn't include the Insight URI. The fact that it's going over HTTP and not HTTPS might also lead me to believe something isn't authenticated.

I'm using OAuth and I have authenticated my client with this OAuth key, but getting the video using video_by doesn't get me a video object which contains the insight URI.

Is there another way I can instantiate the video object so that it downloads the video's feed using the OAuth so that it includes the insight URI?

Providing a means to obtain the total comment count.

Can you provide a means to obtain the total comment count? I quickly modified the parser.rb file to include the following:

    class CommentsCountParser < FeedParser
      def parse_content(content)
        doc = REXML::Document.new(content.body)
        feed = doc.elements["feed"]
        feed.elements.each("openSearch:totalResults") do |total|
          return total.text.to_i
        end
      end
    end

Cheers,
Richard Burton III

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.