Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoMethodError: undefined method `get_videos' #21

Open
simonhutchings opened this issue Oct 9, 2011 · 3 comments
Open

NoMethodError: undefined method `get_videos' #21

simonhutchings opened this issue Oct 9, 2011 · 3 comments

Comments

@simonhutchings
Copy link

No sure why this is. Works fine in Simple mode, but when I use my authentication for the Advanced mode

i do

test = Vimeo::Advanced::Video.new("xxxxx", "xxxxx", :token => "xxxx", :secret => "xxxxx")

I have the appropriate token and secret in db

which generates

<Vimeo::Advanced::Video:0x387e878 @access_token=#<OAuth::AccessToken:0x387e814 @params={}, @consumer=#<OAuth::Consumer:0x387e828 @options={:signature_method=>"HMAC-SHA1", :access_token_path=>"/oauth/access_token", :http_method=>:get, :scheme=>:header, :oauth_version=>"1.0", :site=>"http://vimeo.com", :proxy=>nil, :request_token_path=>"/oauth/request_token", :authorize_path=>"/oauth/authorize"}, @key="xxxxxx", @secret="xxxxxx">, @secret="xxxxxx", @token="xxxxxxx">, @oauth_consumer=#<OAuth::Consumer:0x387e828 @options={:signature_method=>"HMAC-SHA1", :access_token_path=>"/oauth/access_token", :http_method=>:get, :scheme=>:header, :oauth_version=>"1.0", :site=>"http://vimeo.com", :proxy=>nil, :request_token_path=>"/oauth/request_token", :authorize_path=>"/oauth/authorize"}, @key="xxxxxx", @secret="xxxxxx">>

then do

test.get_videos("chamonix")

and I get

NoMethodError: undefined method `get_videos' for #Vimeo::Advanced::Video:0x387e878
from (irb):12

Any ideas

@qajaq
Copy link

qajaq commented Jan 9, 2012

I'm running into similar problem in the script/console. Inspecting the list of available methods for this object showed "get_uploaded_list", and "get_list". But if I do test.get_uploaded_list I get back a HTML response of "Page not found" from Vimeo. Anybody have any luck?

@simonhutchings
Copy link
Author

Got it working in the app

application.rb

  AWS::S3::Base.establish_connection!(
        :access_key_id     => 'xxxxxxx',
        :secret_access_key => 'xxxxxxxx'
      )

my controller for admin_videos (using active_admin)

before_filter :authorise, :only => :index

#adds the video refs from vimeo

def add_videos
  if params['sync'] == "true"
    videos = Vimeo::Simple::User.videos("chamonix")
    videos.each do |video|
      @video_entry = Video.find_or_create_by_video_id(video['id'])
      if @video_entry.title.blank?
        Video.import_info(@video_entry, video)
      end
    end
    #check_exist_on_vimeo
  end
end

def create
  video = Vimeo::Simple::Video.info(params[:video][:video_id])

  if !video.first.blank?
    @video_entry = Video.find_or_create_by_video_id(params[:video][:video_id])

    #uses video model to input the info
    Video.import_info(@video_entry, video.first)
    redirect_to admin_video_path(@video_entry), :notice => "Video Saved!"
  else
    redirect_to new_admin_video_path, :notice => "Could not find this video, try again!"
  end
end

#authorisation script
def authorise
  if params[:oauth_token]
    base = Vimeo::Advanced::Base.new(CUSTOMER_KEY, CUSTOMER_SECRET)
    access_token = base.get_access_token(params[:oauth_token], session[:oauth_secret], params[:oauth_verifier])
    current_admin_user.token = access_token.token
    current_admin_user.secret = access_token.secret
    current_admin_user.save
    redirect_to admin_videos_path
  end

  if current_admin_user.token.blank?
    base = Vimeo::Advanced::Base.new(CUSTOMER_KEY, CUSTOMER_SECRET)
    request_token = base.get_request_token
    session[:oauth_secret] = request_token.secret

    redirect_to base.authorize_url
  else
    @vimeo_access = Vimeo::Advanced::Video.new(CUSTOMER_KEY, CUSTOMER_SECRET, :token => current_admin_user.token, :secret => current_admin_user.secret)
  end
end

if interested check out http://www.sebmontaz.com theres some great footage on there, in the process of building a store for it

@qajaq
Copy link

qajaq commented Jan 9, 2012

Awesome! Thanks for the quick response. Will give it a shot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants