Class: Vidly

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/vidly.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username, password) ⇒ Vidly

Returns a new instance of Vidly.



16
17
18
# File 'lib/vidly.rb', line 16

def initialize(username, password)
  @auth = {:username => username, :password => password}
end

Class Method Details

.meta(url) ⇒ Object



48
49
50
# File 'lib/vidly.rb', line 48

def self.meta(url)
  mashup(get("/import/meta.json", :query => {:url => url}))
end

.url(id) ⇒ Object



52
53
54
# File 'lib/vidly.rb', line 52

def self.url(id)
  "http://vid.ly/#{id}"
end

.videos(username) ⇒ Object



44
45
46
# File 'lib/vidly.rb', line 44

def self.videos(username)
  mashup(get("/videos/#{username}.json"))
end

Instance Method Details

#import(url, options = {}) ⇒ Object



28
29
30
# File 'lib/vidly.rb', line 28

def import(url, options={})
  self.class.mashup(self.class.post("/import.json", {:basic_auth => @auth, :body => default_video_options.merge(options.merge({:url => url})) }))
end

#import_and_post(url, options = {}) ⇒ Object



32
33
34
# File 'lib/vidly.rb', line 32

def import_and_post(url, options={})
  self.class.mashup(self.class.post("/importAndPost.json", {:basic_auth => @auth, :body => default_video_options.merge(options.merge({:url => url})) }))
end

#status(id) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/vidly.rb', line 36

def status(id)
  info = self.class.mashup(self.class.post("/status.json", {:basic_auth => @auth, :body => {:id => id}}))
  %w(views retweets likes).each do |key|
    info.meta[key] = info.meta[key].to_i
  end
  info
end

#upload(file, options = {}) ⇒ Object



20
21
22
# File 'lib/vidly.rb', line 20

def upload(file, options={})
  upload_file("/upload.json", file, options)
end

#upload_and_post(file, options = {}) ⇒ Object



24
25
26
# File 'lib/vidly.rb', line 24

def upload_and_post(file, options={})
  upload_file("/uploadAndPost.json", file, options)
end