OSDN Git Service

load arcs bowl
authornomeu <nomeu@users.sourceforge.jp>
Mon, 4 Jul 2011 04:23:18 +0000 (13:23 +0900)
committernomeu <nomeu@users.sourceforge.jp>
Mon, 4 Jul 2011 04:23:18 +0000 (13:23 +0900)
bin/load-arcs-bowl.rb [new file with mode: 0644]
bin/load-arcs-locked.rb [deleted file]
bin/load-arcs.rb
bin/read-tabs.rb
lib/bowl.rb
lib/location.rb

diff --git a/bin/load-arcs-bowl.rb b/bin/load-arcs-bowl.rb
new file mode 100644 (file)
index 0000000..3a2e73c
--- /dev/null
@@ -0,0 +1,31 @@
+#!ruby
+# encoding: utf-8
+$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
+require 'connection'
+require 'location'
+require 'arc'
+require 'pmd'
+require 'vmd'
+require 'x'
+require 'bowl'
+
+location = Location.find_by_code('mmdbowl')
+
+for number in 135..416
+  code = "dl#{number}"
+  bowl = Bowl.new(code)
+  bowl.load
+  next if bowl.removed?
+  next unless bowl.tabs.include?('MikuMikuDance')
+
+  name = bowl.name
+  summary = bowl.summary
+  size = '0KB'
+  date = '01/01/01(Mon),00:00:00'
+  origname = bowl.origname
+  locked = bowl.locked?
+
+  arc = location.create_arc(name, summary, size, date, origname, locked)
+  arc.create_zip_entries("/Volumes/uploader/arc/#{location.code}/#{name}") unless locked
+  puts
+end
diff --git a/bin/load-arcs-locked.rb b/bin/load-arcs-locked.rb
deleted file mode 100644 (file)
index a217b1c..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#!ruby
-# encoding: utf-8
-$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
-require 'connection'
-require 'location'
-require 'arc'
-require 'pmd'
-require 'vmd'
-require 'x'
-require 'scrap'
-
-location_code = ARGV.shift || 'mmd'
-location = Location.find_by_code(location_code)
-unless location
-  puts "location not found."
-  exit
-end
-
-def update_arcs(f, location)
-  scrap = Scrap.find_by_location_code(location.code)
-  while line = f.gets
-    if scrap.match(line)
-      name, summary, size, date, origname, locked = scrap.row
-      arc = location.update_arc(name, summary, size, date, origname, locked)
-      # arc.create_zip_entries("/Volumes/uploader/arc/#{location.code}/#{name}")
-      puts
-    end
-  end
-end
-
-i = 0
-while true
-  ent = "/Volumes/uploader/src/#{location.code}/#{i + 1}.html"
-  break unless File.exist?(ent)
-  puts ent
-  open(ent) do |f|
-    update_arcs(f, location)
-  end
-  i = i + 1
-end
index 1a06a9b..ae45bdb 100644 (file)
@@ -23,7 +23,7 @@ open(ent) do |f|
     if scrap.match(line)
       name, summary, size, date, origname, locked = scrap.row
       arc = location.create_arc(name, summary, size, date, origname, locked)
-      arc.create_zip_entries("/Volumes/uploader/arc/#{location.code}/#{name}")
+      arc.create_zip_entries("/Volumes/uploader/arc/#{location.code}/#{name}") unless locked
       puts
     end
   end
index 3071801..d684c9b 100644 (file)
@@ -1,5 +1,5 @@
 require 'lib/bowl'
-for number in 393..416
+for number in 135..416
   code = "dl#{number}"
   bowl = Bowl.new(code)
   bowl.load
index 6ea73b2..a77e955 100644 (file)
@@ -87,8 +87,12 @@ class Bowl
     body
   end
 
+  def name
+    "#{code}.#{extname}"
+  end
+
   def arc_path
-    "/Volumes/uploader/arc/mmdbowl/#{code}.#{extname}"
+    "/Volumes/uploader/arc/mmdbowl/#{name}"
   end
 
   def save_arc_0
index 5ed3e10..97b6dd6 100644 (file)
@@ -54,6 +54,8 @@ class Location < ActiveRecord::Base
       code = code[3..-1]
     when 'mmd3dcu'
       code = 'cu%04d' % code[3..-1].to_i
+    when 'mmdbowl'
+      code = 'bo%04d' % code[2..-1].to_i
     end
     [ code, extname ]
   end