Module: Yourub::MetaSearch
Instance Method Summary collapse
-
#get(video_id) ⇒ Object
return an hash containing the metadata for the given video.
-
#get_views(video_id) ⇒ Object
return the number of times a video was watched.
-
#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
48 49 50 51 52 |
# File 'lib/yourub/meta_search.rb', line 48 def get(video_id) params = {:id => video_id, :part => 'snippet,statistics'} request = Yourub::REST::Videos.list(self,params) Yourub::Result.format(request).first end |
#get_views(video_id) ⇒ Object
return the number of times a video was watched
36 37 38 39 40 41 |
# File 'lib/yourub/meta_search.rb', line 36 def get_views(video_id) params = { :id => video_id, :part => 'statistics' } request = Yourub::REST::Videos.list(self,params) v = Yourub::Result.format(request).first v ? Yourub::CountFilter.get_views_count(v) : nil 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 |
# File 'lib/yourub/meta_search.rb', line 12 def search(criteria) begin @api_options= { :part => 'snippet', :type => 'video', :order => 'relevance', :safeSearch => 'none', } @categories = [] @count_filter = {} @criteria = Yourub::Validator.confirm(criteria) search_by_criteria do |result| yield result end rescue ArgumentError => e Yourub.logger.error "#{e}" end end |