x2ch 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/x2ch.rb +15 -5
  2. metadata +4 -3
data/lib/x2ch.rb CHANGED
@@ -86,7 +86,12 @@ module X2CH
86
86
  end
87
87
 
88
88
  def posts(if_modified_since = nil, range = nil)
89
- res = Dat.download(@url + "dat/" + @dat, if_modified_since, range)
89
+ if @url.match(/machi.to/)
90
+ part = @url.match(/^(http:\/\/.+?)\/(.+?)\//).to_a
91
+ res = Dat.download(part[1] + "/bbs/offlaw.cgi/" + part[2] + '/' + @dat.sub('.cgi', ''), if_modified_since, range)
92
+ else
93
+ res = Dat.download(@url + "dat/" + @dat, if_modified_since, range)
94
+ end
90
95
  ArrayResponse.new(Dat.parse(res), res.status, res.last_modified, res.content_encoding, res.body_size)
91
96
  end
92
97
 
@@ -176,7 +181,7 @@ module X2CH
176
181
 
177
182
  next unless category
178
183
 
179
- b = l.match(/<A HREF=(http:\/\/.*(?:\.2ch\.net|\.bbspink\.com).+\/)>(.+)<\/A>/).to_a
184
+ b = l.match(/<A HREF=(http:\/\/.*(?:\.2ch\.net|\.bbspink\.com|\.machi\.to)[^\s]*).*>(.+)<\/A>/).to_a
180
185
  if b[0]
181
186
  next if IGNORE_BOARDS.include?(b[2])
182
187
 
@@ -196,7 +201,7 @@ module X2CH
196
201
  def self.parse(url, subject)
197
202
  threads = []
198
203
  subject.each_line{|l|
199
- m = l.match(/^(\d+\.dat)<>(.+)\((\d+)\)$/).to_a
204
+ m = l.match(/^(\d+\.(?:dat|cgi))(?:<>|,)(.+)\((\d+)\)$/).to_a
200
205
  if m[0]
201
206
  threads << Thread.new(url, m[1], m[2], m[3].to_i)
202
207
  end
@@ -213,9 +218,14 @@ module X2CH
213
218
  def self.parse(dat)
214
219
  posts = []
215
220
  dat.each_line{|l|
216
- m = l.match(/^(.+?)<>(.*?)<>(.*?)<>(.+)<>.*$/).to_a
221
+ m = l.match(/^(\d+)<>(.+?)<>(.*?)<>(.*?)<>(.+)<>.*$/).to_a
217
222
  if m[0]
218
- posts << Post.new(m[1], m[2], m[3], m[4])
223
+ posts << Post.new(m[2], m[3], m[4], m[5])
224
+ else
225
+ m = l.match(/^(.+?)<>(.*?)<>(.*?)<>(.+)<>.*$/).to_a
226
+ if m[0]
227
+ posts << Post.new(m[1], m[2], m[3], m[4])
228
+ end
219
229
  end
220
230
  }
221
231
  posts
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: x2ch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-14 00:00:00.000000000 Z
12
+ date: 2013-10-27 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: 2ch downloader and parser library
15
15
  email: mail@xmisao.com
@@ -19,7 +19,8 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - lib/x2ch.rb
21
21
  homepage: https://github.com/xmisao/x2ch
22
- licenses: []
22
+ licenses:
23
+ - MIT
23
24
  post_install_message:
24
25
  rdoc_options: []
25
26
  require_paths: