#!ruby
# vim: fileencoding=utf-8
-require 'nkf'
-
-class Scrap
- def match(line)
- @md = @row_re.match(line)
- end
-
- def row
- raise
- end
-
- def encode(str)
- str && NKF.nkf('-Sw', str)
- end
-
- def encode_to_sjis(str)
- str && NKF.nkf('-Ws', str)
- end
-end
-
-class Scrap_mmd < 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>"))
- @password_re = Regexp.new(Regexp.escape("<font color=\"#FF0000\">*</font>"))
- end
-
- def row
- _, href, name, comment, size, date, mime, orig = @md.to_a
- comment.sub!(@key_re, '')
- comment.sub!(@password_re, '')
- [ name, comment, size, date, orig ]
- end
-end
-
-class Scrap_mmdfile < Scrap
- def initialize
- @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> "))
- end
-
- def row
- _, href, name, comment, size, date, orig = @md.to_a
- comment.sub!(@key_re, '')
- [ name, comment, size, date, orig ]
- end
-end
-
-class Scrap_mmdacc1 < Scrap
- def initialize
- @row_re = %r(<td align=center>\[<a href='(.+?)' target='_new'>(.+?)</a>\]</td><td>(.+?)</td><td align=right>(.+?)</td><td align=center>(.+?)</td><td>(.+))
- end
-
- def row
- _, href, name, comment, size, date, orig = @md.to_a
- [ name, encode(comment), size, date, encode(orig) ]
- end
-end
-
-class Scrap_mmdacc2 < Scrap
- def initialize
- @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>")))
- end
-
- def row
- _, href, name, comment, size, date = @md.to_a
- comment.sub!(@key_re, '')
- [ name, encode(comment), size, encode(date) ]
- end
-end
+$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
+require 'scrap'
location = ARGV.shift || 'mmd'
--- /dev/null
+# vim: fileencoding=utf-8
+require 'nkf'
+
+class Scrap
+ def match(line)
+ @md = @row_re.match(line)
+ end
+
+ def row
+ raise
+ end
+
+ def encode(str)
+ str && NKF.nkf('-Sw', str)
+ end
+
+ def encode_to_sjis(str)
+ str && NKF.nkf('-Ws', str)
+ end
+end
+
+class Scrap_mmd < 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>"))
+ @password_re = Regexp.new(Regexp.escape("<font color=\"#FF0000\">*</font>"))
+ end
+
+ def row
+ _, href, name, comment, size, date, mime, orig = @md.to_a
+ comment.sub!(@key_re, '')
+ comment.sub!(@password_re, '')
+ [ name, comment, size, date, orig ]
+ end
+end
+
+class Scrap_mmdfile < Scrap
+ def initialize
+ @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> "))
+ end
+
+ def row
+ _, href, name, comment, size, date, orig = @md.to_a
+ comment.sub!(@key_re, '')
+ [ name, comment, size, date, orig ]
+ end
+end
+
+class Scrap_mmdacc1 < Scrap
+ def initialize
+ @row_re = %r(<td align=center>\[<a href='(.+?)' target='_new'>(.+?)</a>\]</td><td>(.+?)</td><td align=right>(.+?)</td><td align=center>(.+?)</td><td>(.+))
+ end
+
+ def row
+ _, href, name, comment, size, date, orig = @md.to_a
+ [ name, encode(comment), size, date, encode(orig) ]
+ end
+end
+
+class Scrap_mmdacc2 < Scrap
+ def initialize
+ @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>")))
+ end
+
+ def row
+ _, href, name, comment, size, date = @md.to_a
+ comment.sub!(@key_re, '')
+ [ name, encode(comment), size, encode(date) ]
+ end
+end