OSDN Git Service

added
authornomeu <nomeu@duo2mini.nomeu.org>
Wed, 9 Jun 2010 17:10:29 +0000 (02:10 +0900)
committernomeu <nomeu@duo2mini.nomeu.org>
Wed, 9 Jun 2010 17:10:29 +0000 (02:10 +0900)
read-upl-mmdacc1.rb [new file with mode: 0644]
read-upl-mmdacc2.rb [new file with mode: 0644]
read-upl-mmdfile.rb [new file with mode: 0644]
read-upl.rb [new file with mode: 0644]
read-zip.rb [new file with mode: 0644]

diff --git a/read-upl-mmdacc1.rb b/read-upl-mmdacc1.rb
new file mode 100644 (file)
index 0000000..4e2fff8
--- /dev/null
@@ -0,0 +1,20 @@
+#!ruby
+require 'nkf'
+
+def encode(str)
+  str && NKF.nkf('-Sw', str)
+end
+
+row_re = %r(<td align=center>\[<a href='(.+?)' target='_new'>(.+?)</a>\]</td><td>(.+?)</td><td align=right>(.+?)</td><td align=center>(.+?)</td><td>(.+))
+
+Dir.glob('/Volumes/uploader/src/mmdacc1/*.html') do |ent|
+  f = open(ent)
+  while line = f.gets
+    # puts line
+    if match = row_re.match(line)
+      _, href, name, comment, size, date, orig = match.to_a
+      puts [ name, encode(comment), size, date, encode(orig) ].join("\t")
+    end
+  end
+  f.close
+end
diff --git a/read-upl-mmdacc2.rb b/read-upl-mmdacc2.rb
new file mode 100644 (file)
index 0000000..7f0d322
--- /dev/null
@@ -0,0 +1,30 @@
+#!ruby
+# vim: fileencoding=utf-8
+require 'nkf'
+
+def encode(str)
+  str && NKF.nkf('-Sw', str)
+end
+
+def encode_to_sjis(str)
+  str && NKF.nkf('-Ws', str)
+end
+
+row_re = %r(</td><td><a href="(.+?)">(.+?)</a></td><td>(.+?)</td><td>(.+?)</td><td>(.+?)</td><td class="down_max">(.+?)</td></tr>)
+key_re = Regexp.new(Regexp.escape(encode_to_sjis("<font color=\"#FF0000\">[パス設定] </font>")))
+
+Dir.glob('/Volumes/uploader/src/mmdacc2/*.html') do |ent|
+  f = open(ent)
+  while line = f.gets
+    # puts line
+    if match = row_re.match(line)
+      _, href, name, comment, size, date = match.to_a
+      with_key = !!key_re.match(comment)
+      if with_key
+        comment.sub!(key_re, '')
+      end
+      puts [ name, encode(comment), size, encode(date) ].join("\t")
+    end
+  end
+  f.close
+end
diff --git a/read-upl-mmdfile.rb b/read-upl-mmdfile.rb
new file mode 100644 (file)
index 0000000..001ce50
--- /dev/null
@@ -0,0 +1,20 @@
+#!ruby
+
+row_re = %r(<td>\[<a href="(.+?)" >(.+?)</a>\]</td><td>(.+?) <a href="(?:.+?)">(?:.+?)</a></td><td class="size">(.+?)</td><td class="date">(.+?)</td><td class="orig"><span class="orig">(.+?)</span></td>)
+key_re = Regexp.new(Regexp.escape("<strong class=\"key\">[P]</strong> "))
+
+Dir.glob('/Volumes/uploader/src/mmdfile/*.html') do |ent|
+  f = open(ent)
+  while line = f.gets
+    comment, href, name, rest = nil
+    if md = row_re.match(line)
+      _, href, name, comment, size, date, orig = md.to_a
+      with_key = !!key_re.match(comment)
+      if with_key
+        comment.sub!(key_re, '')
+      end
+      puts [ name, comment, size, date, orig ].join("\t")
+    end
+  end
+  f.close
+end
diff --git a/read-upl.rb b/read-upl.rb
new file mode 100644 (file)
index 0000000..257d55e
--- /dev/null
@@ -0,0 +1,24 @@
+#!ruby
+
+row_re = %r(</td><td><a href="(.+?)">(.+?)</a></td><td>(.+?)</td><td>(.+?)</td><td>(.+?)</td><td>(.+?)</td><td>(.+?)</td></tr>)
+key_re = Regexp.new(Regexp.escape("<font color=\"#FF0000\">[DLKey] </font>"))
+password_re = Regexp.new(Regexp.escape("<font color=\"#FF0000\">*</font>"))
+
+Dir.glob('/Volumes/uploader/src/mmd/*.html') do |ent|
+  f = open(ent)
+  while line = f.gets
+    if match = row_re.match(line)
+      _, href, name, comment, size, date, mime, orig = match.to_a
+      with_key = !!key_re.match(comment)
+      if with_key
+        comment.sub!(key_re, '')
+      end
+      with_password = !!password_re.match(comment)
+      if with_password
+        comment.sub!(password_re, '')
+      end
+      puts [ name, comment, size, date, mime, orig, with_key ? 'key' : '-', with_password ? 'password' : '-' ].join("\t")
+    end
+  end
+  f.close
+end
diff --git a/read-zip.rb b/read-zip.rb
new file mode 100644 (file)
index 0000000..80a55d6
--- /dev/null
@@ -0,0 +1,33 @@
+require 'rubygems'
+gem 'zipruby'
+require 'zipruby'
+require 'nkf'
+
+def encode(str)
+  str && NKF.nkf('-Sw', str)
+end
+
+def dump_zip(path)
+  Zip::Archive.open(path) do |ar|
+    puts "# #{path}"
+
+    n = ar.num_files # number of entries
+    n.times do |i|
+      entry_name = ar.get_name(i) # get entry name from archive
+
+      # open entry
+      ar.fopen(i) do |f|
+        puts [ f.size, f.comp_size, f.mtime.strftime("%d-%m-%y %H:%M"), encode(f.name) ].join("\t")
+
+        # content = f.read # read entry content
+      end
+    end
+  end
+rescue Zip::Error => exc
+  puts "error: " + exc.message
+end
+
+Dir.glob('/Volumes/uploader/arc/mmd/*.zip') do |ent|
+  dump_zip(ent)
+  puts
+end