OSDN Git Service

added sn_uploader
[tdcgexplorer/nimono-crawlers.git] / bin / mmd-idx.rb
1 #!/usr/bin/ruby
2 # download from mikumikudance
3 # http://bytatsu.net/uploader/mikumikudance/index.html
4
5 $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
6 require 'sn_uploader'
7
8 def each_filename(text)
9   file_href = './src/'
10   file_re = Regexp.new(Regexp.escape(file_href) + '(.+)')
11   text.scan(/href="(.+?)"/) do |href, |
12     if md = file_re.match(href)
13       yield md[1]
14     end
15   end
16 end
17
18 uploader = SnUploader.new
19 uploader.host = "bytatsu.net"
20 uploader.root_path = "/uploader/mikumikudance"
21 uploader.base_html = "index.html"
22 uploader.local_dir = File.dirname(__FILE__) + '/../arc/mmd'
23 body = uploader.get_base
24 each_filename(body) do |filename|
25   exist = uploader.local_file_exist?(filename)
26   puts [ filename, exist ? 'exist' : 'download' ].join("\t")
27   uploader.download_file_directly(filename) unless exist
28 end