nhentai-api 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nhentai-api.rb +13 -4
  3. metadata +6 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 109d37e0a068cd29975a5089ba3fb56fca2483a8aee361608d17e12a76f7e6ee
4
- data.tar.gz: 4995763a326ed1d4e68d25857b85563a5000136022af7f9b41b13d91901c8229
3
+ metadata.gz: 32a8382ebb1c8c5d33c1ea5baa94070fc31c788e31c628c7708fa6b29d839d94
4
+ data.tar.gz: 1481e553fa7663d4898b07f60814413be9efb5ccd8c233bf84d0c08281edf934
5
5
  SHA512:
6
- metadata.gz: ea468a964c41b3bf7ac264f16a6206ff6c56be7fa98c3b4beeb765d08d6a2a803e56cd12cf453d3f9804dd6e81262058f7c5caf7b2e7bdabb05f9051c8f94abb
7
- data.tar.gz: 7b66422ee77f01ef7f76f8be440a45970b612f4e36c6a405895766354cccea1b107bf171d592e8259c91172c68183e1a8c6f66dc352fab606c086918cdc6432c
6
+ metadata.gz: 585e38f3cb7d7397158535f4bca3dd10fde1fb70bcf4ecddff39eaee1178a6f1cb50ad668897e838087265ab1d61e1617bddbdcede672d1f8de46fd6a5945a7c
7
+ data.tar.gz: a5246ab1e9eec631fed5a883822e9190bf004e88840b6cc9d3a13cb516371019a61c77a7808d04eaebd325ba5a23e823c930351f16f5063164cc8b963fd5c2e5
@@ -20,7 +20,7 @@ class Doujinshi
20
20
  @client = Net::HTTP.get_response(URI("https://nhentai.net/g/#{@id}/"))
21
21
  if self.exists?
22
22
  @media_id = @client.body.match(%r{\/([0-9]+)\/cover})[1]
23
- @count_pages = @client.body.match(/([0-9]+) pages/)[1].to_i
23
+ @count_pages = @client.body.match(/Pages:\s*.*>([0-9]+)</)[1].to_i
24
24
  end
25
25
  end
26
26
 
@@ -45,7 +45,7 @@ class Doujinshi
45
45
  # doujinshi.title #=> '[Illumination. (Ogadenmon)] Android no Ecchi na Yatsu | Horny Androids (NieR:Automata) [English] =TLL + mrwayne= [Digital]'
46
46
  #
47
47
  def title
48
- @client.body.match(%r{<div id="info">\s+<h1>(.+)<\/h1>})[1]
48
+ @client.body.match(/"pretty">(.*?)</)[1]
49
49
  end
50
50
 
51
51
  #
@@ -141,7 +141,7 @@ class Doujinshi
141
141
  # doujinshi.upload_date #=> 2018-01-17 15:56:16 +0000
142
142
  #
143
143
  def upload_date
144
- Time.iso8601(@client.body.match(/datetime="(.+)"/)[1])
144
+ Time.iso8601(@client.body.match(/<time .+ datetime="(.*?)"/)[1])
145
145
  end
146
146
 
147
147
  #
@@ -154,6 +154,7 @@ class Doujinshi
154
154
  #
155
155
  def tags
156
156
  res = @client.body.match(%r{Tags:\s*<span class="tags">(.+)<\/span>})
157
+ return [] if res.nil?
157
158
 
158
159
  parse_tags(res[1])
159
160
  end
@@ -192,6 +193,7 @@ class Doujinshi
192
193
  #
193
194
  def parodies
194
195
  res = @client.body.match(%r{Parodies:\s+<span class="tags">(.+)<\/span>})
196
+ return [] if res.nil?
195
197
 
196
198
  parse_tags(res[1])
197
199
  end
@@ -226,6 +228,7 @@ class Doujinshi
226
228
  #
227
229
  def characters
228
230
  res = @client.body.match(%r{Characters:\s+<span class="tags">(.+)<\/span>})
231
+ return [] if res.nil?
229
232
 
230
233
  parse_tags(res[1])
231
234
  end
@@ -260,6 +263,7 @@ class Doujinshi
260
263
  #
261
264
  def artists
262
265
  res = @client.body.match(%r{Artists:\s+<span class="tags">(.+)<\/span>})
266
+ return [] if res.nil?
263
267
 
264
268
  parse_tags(res[1])
265
269
  end
@@ -294,6 +298,7 @@ class Doujinshi
294
298
  #
295
299
  def groups
296
300
  res = @client.body.match(%r{Groups:\s+<span class="tags">(.+)<\/span>})
301
+ return [] if res.nil?
297
302
 
298
303
  parse_tags(res[1])
299
304
  end
@@ -328,6 +333,7 @@ class Doujinshi
328
333
  #
329
334
  def languages
330
335
  res = @client.body.match(%r{Languages:\s+<span class="tags">(.+)<\/span>})
336
+ return [] if res.nil?
331
337
 
332
338
  parse_tags(res[1])
333
339
  end
@@ -362,6 +368,7 @@ class Doujinshi
362
368
  #
363
369
  def categories
364
370
  res = @client.body.match(%r{Categories:\s+<span class="tags">(.+)<\/span>})
371
+ return [] if res.nil?
365
372
 
366
373
  parse_tags(res[1])
367
374
  end
@@ -398,9 +405,11 @@ class Doujinshi
398
405
  res.split(%r{<a(.+?)<\/a>}).reject(&:empty?).map do |line|
399
406
  id = line.match(/tag-(\d+)/)[1]
400
407
  name = line.match(/">(.+?)</)[1].strip
401
- count = line.match(/\((.+?)\)</)[1].tr(',', '').to_i
408
+ count = line.match(/class="count">(\d+.)</)[1]
402
409
  url = line.match(/href=\"(.+?)\"/)[1]
403
410
 
411
+ count = count[-1] == 'K' ? count.to_i * 1000 : count.to_i
412
+
404
413
  Info.new(id, name, count, url)
405
414
  end
406
415
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nhentai-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gael Roussel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-06 00:00:00.000000000 Z
11
+ date: 2020-07-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: nhentai-api is a basic and easy to use API for nhentai.net
14
- email: groussel42@gmail.com
14
+ email: gaelroussel@protonmail.com
15
15
  executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
@@ -22,7 +22,7 @@ licenses:
22
22
  - MIT
23
23
  metadata:
24
24
  documentation_uri: https://www.rubydoc.info/github/groussel42/nhentai-api
25
- source_code_uri: https://github.com/groussel42/nhentai-api
25
+ source_code_uri: https://github.com/Mraiih/nhentai-api
26
26
  post_install_message:
27
27
  rdoc_options: []
28
28
  require_paths:
@@ -38,7 +38,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
38
38
  - !ruby/object:Gem::Version
39
39
  version: '0'
40
40
  requirements: []
41
- rubygems_version: 3.0.6
41
+ rubyforge_project:
42
+ rubygems_version: 2.7.6
42
43
  signing_key:
43
44
  specification_version: 4
44
45
  summary: nhentai-api is a basic and easy to use API for nhentai.net