Class: YoutubeSearch

Inherits:
Object
  • Object
show all
Defined in:
lib/ytsearch.rb

Constant Summary collapse

API_URL =
'https://www.googleapis.com/youtube/v3/search'
API_KEY =
ENV['API_KEY']

Class Method Summary collapse

Class Method Details

.search(options = {}) ⇒ Object



11
12
13
14
15
# File 'lib/ytsearch.rb', line 11

def self.search(options={})
  query = options.map{|k,v| "#{k}=#{v}"}.join('&')
  response = URI.open("#{API_URL}?key=#{API_KEY}&#{query}").read
  response = JSON.parse(response)
end