OSDN Git Service

scrap mmd3dcu
authornomeu <nomeu@users.sourceforge.jp>
Tue, 17 May 2011 06:41:42 +0000 (15:41 +0900)
committernomeu <nomeu@users.sourceforge.jp>
Tue, 17 May 2011 06:41:42 +0000 (15:41 +0900)
lib/location.rb
lib/scrap.rb

index 1d9952e..5ed3e10 100644 (file)
@@ -3,7 +3,7 @@ class Location < ActiveRecord::Base
 
   def locked_path_pattern
     case self.code
-    when 'mmd'
+    when 'mmd', 'mmd3dcu'
       "upload\\.cgi\\?mode=dl&file=(\\d+)"
     when 'mmdfile'
       "\\?mode=pass&idd=(\\d+)"
@@ -12,7 +12,7 @@ class Location < ActiveRecord::Base
 
   def path_pattern
     case self.code
-    when 'mmd'
+    when 'mmd', 'mmd3dcu'
       "src/(\\w+)"
     when 'mmdfile'
       "\\?id=(\\d+)"
@@ -29,6 +29,8 @@ class Location < ActiveRecord::Base
       code = 'up%04d' % name.to_i
     when 'mmdfile'
       code = 'file%04d' % name.to_i
+    when 'mmd3dcu'
+      code = 'cu%04d' % name.to_i
     end
     code
   end
@@ -50,6 +52,8 @@ class Location < ActiveRecord::Base
       code = 'mini%04d' % code.to_i
     when 'mmdacc2'
       code = code[3..-1]
+    when 'mmd3dcu'
+      code = 'cu%04d' % code[3..-1].to_i
     end
     [ code, extname ]
   end
index 3bec00e..8fdd492 100644 (file)
@@ -72,6 +72,21 @@ class Scrap_mmdacc2 < Scrap
   end
 end
 
+class Scrap_mmd3dcu < Scrap
+  def initialize
+    @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>"))
+    @tag_list_re = Regexp.new("<span class=\"tag_list\">(.+?)</span>")
+  end
+
+  def row
+    _, href, name, comment, size, date, mime, orig = @md.to_a
+    locked = !!comment.sub!(@key_re, '')
+    comment.sub!(@tag_list_re, '\\1')
+    [ name, encode(comment), size, date, encode(orig), locked ]
+  end
+end
+
 def Scrap.find_by_location_code(location_code)
   case location_code
   when 'mmd'
@@ -82,5 +97,7 @@ def Scrap.find_by_location_code(location_code)
     scrap = Scrap_mmdacc1.new
   when 'mmdacc2'
     scrap = Scrap_mmdacc2.new
+  when 'mmd3dcu'
+    scrap = Scrap_mmd3dcu.new
   end
 end