OSDN Git Service

inc feed count 50
[tdcgexplorer/nimono-crawlers.git] / bin / load-whole-thumbs.rb
1 #!ruby
2 # encoding: utf-8
3 $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
4 $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../app/models')
5 require 'connection'
6 require 'site'
7 require 'arc'
8 require 'thumb'
9 require 'nicovideo'
10
11 nv = Nicovideo.new
12
13 class << nv
14   PAGE_SIZE = 30
15
16   def tag_search_and_get_thumbinfo_0(tag_name, options = {})
17     video_ids = tag_search(tag_name, options)
18     video_ids.each do |video_id|
19       puts video_id
20       td = get_thumbinfo(video_id)
21       thumb = Thumb.find(td.video_id) || Thumb.new(:key => td.video_id)
22       thumb.title = td.title
23       thumb.description = td.description
24       thumb.save
25     end
26   end
27
28   def tag_search_and_get_thumbinfo(tag_name, size)
29     max_page = (size - 1) / PAGE_SIZE + 1
30     for page in 1 .. max_page
31       tag_search_and_get_thumbinfo_0(tag_name, :page => page, :order => 'a')
32     end
33   end
34 end
35
36 nv.tag_search_and_get_thumbinfo("MMDデータ配布あり",      264)
37 nv.tag_search_and_get_thumbinfo("MMDモデル配布あり",     3610)
38 nv.tag_search_and_get_thumbinfo("MMDモーション配布あり", 1458)