From: nomeu Date: Tue, 17 May 2011 06:41:42 +0000 (+0900) Subject: scrap mmd3dcu X-Git-Tag: 0.0.3~10 X-Git-Url: http://git.osdn.net/view?p=tdcgexplorer%2Fnimono-crawlers.git;a=commitdiff_plain;h=85c5c49629f251bbef43e13e7cdc7260bc435255 scrap mmd3dcu --- diff --git a/lib/location.rb b/lib/location.rb index 1d9952e..5ed3e10 100644 --- a/lib/location.rb +++ b/lib/location.rb @@ -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 diff --git a/lib/scrap.rb b/lib/scrap.rb index 3bec00e..8fdd492 100644 --- a/lib/scrap.rb +++ b/lib/scrap.rb @@ -72,6 +72,21 @@ class Scrap_mmdacc2 < Scrap end end +class Scrap_mmd3dcu < Scrap + def initialize + @row_re = %r((.+?)(.+?)(.+?)(.+?)(.+?)(.+?)) + @key_re = Regexp.new(Regexp.escape("[DLKey] ")) + @tag_list_re = Regexp.new("(.+?)") + 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