Module: Yourub::MetaSearch
Instance Method Summary collapse
-
#get(video_id) ⇒ Object
return an hash containing the metadata for the given video.
-
#search(criteria) ⇒ Object
Search through the youtube API, executing multiple queries where necessary.
Methods included from REST::Videos
Methods included from REST::Categories
Methods included from REST::Search
Instance Method Details
#get(video_id) ⇒ Object
return an hash containing the metadata for the given video
44 45 46 47 48 |
# File 'lib/yourub/meta_search.rb', line 44 def get(video_id) params = {:id => video_id, :part => 'snippet,statistics'} request = Yourub::REST::Videos.list(self,params) Yourub::Result.format(request).first end |
#search(criteria) ⇒ Object
Search through the youtube API, executing multiple queries where necessary
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/yourub/meta_search.rb', line 12 def search(criteria) begin Yourub::CountFilter.filter = nil @api_options= { :part => 'snippet', :type => 'video', :order => 'relevance', :safeSearch => 'none', :q => nil } @categories = [] @count_filter = {} @api_options[:q] = criteria[:query] if criteria[:query] @criteria = Yourub::Validator.confirm(criteria) search_by_criteria do |result| yield result end rescue ArgumentError => e Yourub.logger.error "#{e}" raise end end |