class Nicos::Searcher::ByTagSuper
@private
Private Instance Methods
get(tag, sort, method)
click to toggle source
# File lib/classes/searcher.rb, line 15 def get(tag, sort, method) paramAry = [] case sort when :comment_new sortStr = '' when :comment_old sortStr = 'order=a' when :view_many sortStr = 'sort=v' when :view_few sortStr = 'sort=v&order=a' when :comment_many sortStr = 'sort=r' when :comment_few sortStr = 'sort=r&order=a' when :mylist_many sortStr = 'sort=m' when :mylist_few sortStr = 'sort=m&order=a' when :post_new sortStr = 'sort=f' when :post_old sortStr = 'sort=f&order=a' when :length_long sortStr = 'sort=l' when :length_short sortStr = 'sort=l&order=a' end paramAry.push("page=#{@page}") if @page != 1 paramAry.push(sortStr) paramAry.push("rss=atom&numbers=1") if method == :atom param = "#{tag}?" + paramAry.join('&') host = 'www.nicovideo.jp' entity = '/tag/' @connector.get(host, entity, param) end
loop(tag, sort, method, &block)
click to toggle source
# File lib/classes/searcher.rb, line 56 def loop(tag, sort, method, &block) @page = 1 order = nil begin movieObjAry = [] response = get( tag, sort, method ) if response[:order] == :afterTheSuccess result = parse(response[:body]) result.each { |each| movie = Nicos::Movie.new(each[:video_id]) each[:available] = true movie.set(each) movieObjAry.push(movie) } elsif response[:order] == :terminate puts "Request loop terminated." break end status = { :page => @page, :results => @connector.result} order = block.call(movieObjAry, status) @page += 1 end until order != "continue" && order != :continue end