nhentai-api 0.2.2 → 0.3

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 +82 -479
  3. metadata +6 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32a8382ebb1c8c5d33c1ea5baa94070fc31c788e31c628c7708fa6b29d839d94
4
- data.tar.gz: 1481e553fa7663d4898b07f60814413be9efb5ccd8c233bf84d0c08281edf934
3
+ metadata.gz: 926018495ec0cfbf18b0cd8925ed8134dbc1535b153894c17b063f52243b699d
4
+ data.tar.gz: 64c9ed0d11c68d6e197228a0e4fc33d9f762c9fbeb4a3d47548a55769e45ebc8
5
5
  SHA512:
6
- metadata.gz: 585e38f3cb7d7397158535f4bca3dd10fde1fb70bcf4ecddff39eaee1178a6f1cb50ad668897e838087265ab1d61e1617bddbdcede672d1f8de46fd6a5945a7c
7
- data.tar.gz: a5246ab1e9eec631fed5a883822e9190bf004e88840b6cc9d3a13cb516371019a61c77a7808d04eaebd325ba5a23e823c930351f16f5063164cc8b963fd5c2e5
6
+ metadata.gz: 5d3341acdeb0c156ff91e12d21d1f606c8a1ee2d53c5fea454892977389aba4a8730cfa968fb843856efeab522d7afaf75f1be3ad250cdf347220beb642b5c99
7
+ data.tar.gz: 4462036c84fa2d4096074bb100ec1a4e4a2aaccfdeb5dded595ea1f09cedacbedadc77bb90d10923a88c6821c1f6fb971e862e537930af2341396281b1474765
data/lib/nhentai-api.rb CHANGED
@@ -1,552 +1,155 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'net/http'
4
+ require 'ostruct'
2
5
  require 'time'
3
-
4
- class Info
5
- attr_reader :id, :name, :count, :url
6
-
7
- def initialize(id, name, count, url)
8
- @id = id
9
- @name = name
10
- @count = count
11
- @url = url
12
- end
13
- end
6
+ require 'json'
14
7
 
15
8
  class Doujinshi
16
- attr_reader :id, :client, :media_id, :count_pages
9
+ attr_reader :id, :client, :media_id, :count_pages, :response
17
10
 
18
11
  def initialize(id)
19
12
  @id = id
20
13
  @client = Net::HTTP.get_response(URI("https://nhentai.net/g/#{@id}/"))
21
- if self.exists?
22
- @media_id = @client.body.match(%r{\/([0-9]+)\/cover})[1]
23
- @count_pages = @client.body.match(/Pages:\s*.*>([0-9]+)</)[1].to_i
24
- end
14
+ return unless exists?
15
+
16
+ @media_id = client.body.match(%r{\/([0-9]+)\/cover})[1]
17
+ @count_pages = client.body.match(/Pages:\s*.*>([0-9]+)</)[1].to_i
25
18
  end
26
19
 
27
- #
28
- # Check if a doujinshi with the given id exist
29
- #
30
- # @return [Bool] true if the doujinshi exist, otherwise false
31
- # @since 0.1.0
32
- # @example
33
- # doujinshi.exists? #=> true
34
- #
35
20
  def exists?
36
- @client.code == '200'
21
+ client.code == '200'
37
22
  end
38
23
 
39
- #
40
- # Give the title of a doujinshi
41
- #
42
- # @return [String] the title of a given doujinshi
43
- # @since 0.1.0
44
- # @example
45
- # doujinshi.title #=> '[Illumination. (Ogadenmon)] Android no Ecchi na Yatsu | Horny Androids (NieR:Automata) [English] =TLL + mrwayne= [Digital]'
46
- #
47
24
  def title
48
- @client.body.match(/"pretty">(.*?)</)[1]
25
+ client.body.match(/"pretty">(.*?)</)[1]
49
26
  end
50
27
 
51
- #
52
- # Give the cover's URL of a doujinshi
53
- #
54
- # @return [String] the cover's URL of a given doujinshi
55
- # @since 0.1.0
56
- # @example
57
- # doujinshi.cover #=> 'https://t.nhentai.net/galleries/1170172/cover.jpg'
58
- #
59
28
  def cover
60
- res = @client.body.match(%r{https://t.nhentai.net/galleries/#{@media_id}/cover\.(.{3})"})
29
+ res = client.body.match(%r{https://t.*.nhentai.net/galleries/#{media_id}/cover\.(.{3})"})
61
30
 
62
- "https://t.nhentai.net/galleries/#{@media_id}/cover.#{res[1]}"
31
+ "https://t.nhentai.net/galleries/#{media_id}/cover.#{res[1]}"
63
32
  end
64
33
 
65
- #
66
- # Give the URL of a given page of a doujinshi
67
- #
68
- # @param [Integer] page a particular page of a doujinshi
69
- # @return [String] the URL of a given page of a doujinshi
70
- # @since 0.1.0
71
- # @example
72
- # doujinshi.get_page #=> 'https://i.nhentai.net/galleries/1170172/1.jpg'
73
- # doujinshi.get_page(10) #=> 'https://i.nhentai.net/galleries/1170172/10.jpg'
74
- #
75
34
  def page(page = 1)
76
- res = @client.body.match(%r{https://t.nhentai.net/galleries/#{@media_id}/#{page}t\.(.{3})"})
35
+ res = client.body.match(%r{https://t.*.nhentai.net/galleries/#{media_id}/#{page}t\.(.{3})"})
77
36
 
78
- "https://i.nhentai.net/galleries/#{@media_id}/#{page}.#{res[1]}"
37
+ "https://i.nhentai.net/galleries/#{media_id}/#{page}.#{res[1]}"
79
38
  end
80
39
 
81
- #
82
- # Give the URL of a all pages of a doujinshi
83
- #
84
- # @return [Array] array pages' URL
85
- # @since 0.1.0
86
- # @example
87
- # doujinshi.pages #=> ['https://i.nhentai.net/galleries/1170172/1.jpg', ..., 'https://i.nhentai.net/galleries/1170172/31.jpg']
88
- #
89
40
  def pages
90
- (1..@count_pages).map { |page| page(page) }
41
+ (1..count_pages).map { |page| page(page) }
91
42
  end
92
43
 
93
- #
94
- # Give the thumbnail's URL of a given page of a doujinshi
95
- #
96
- # @param [Integer] page a particular page of a doujinshi
97
- # @return [String] the thumbnail's URL of a given page of a doujinshi
98
- # @since 0.1.0
99
- # @example
100
- # doujinshi.get_thumbnail #=> 'https://t.nhentai.net/galleries/1170172/1t.jpg'
101
- # doujinshi.get_thumbnail(10) #=> 'https://t.nhentai.net/galleries/1170172/10t.jpg'
102
- #
103
44
  def thumbnail(page = 1)
104
- res = @client.body.match(%r{https://t.nhentai.net/galleries/#{@media_id}/(#{page}t\..{3})"})
45
+ res = client.body.match(%r{https://t.*.nhentai.net/galleries/#{media_id}/(#{page}t\..{3})"})
105
46
 
106
- "https://t.nhentai.net/galleries/#{@media_id}/#{res[1]}"
47
+ "https://t.nhentai.net/galleries/#{media_id}/#{res[1]}"
107
48
  end
108
49
 
109
- #
110
- # Give the URL of a all thumbnails of a doujinshi
111
- #
112
- # @return [Array] an array thumbnails' URL
113
- # @since 0.1.0
114
- # @example
115
- # doujinshi.thumbnails #=> ['https://t.nhentai.net/galleries/1170172/1t.jpg',..., 'https://t.nhentai.net/galleries/1170172/31t.jpg']
116
- #
117
50
  def thumbnails
118
- (1..@count_pages).map { |page| thumbnail(page) }
51
+ (1..count_pages).map { |page| thumbnail(page) }
119
52
  end
120
53
 
121
- #
122
- # Give the number of favorites on a doujinshi
123
- #
124
- # @return [Integer] a counter of favorites on a given doujinshi
125
- # @since 0.1.0
126
- # @example
127
- # doujinshi.num_favorites #=> 13326
128
- #
129
54
  def count_favorites
130
55
  regex = %r{<span>Favorite <span class="nobold">.(\d+).<\/span><\/span>}
131
56
 
132
- @client.body.match(regex)[1].to_i
57
+ client.body.match(regex)[1].to_i
133
58
  end
134
59
 
135
- #
136
- # Give the upload date of a doujinshi
137
- #
138
- # @return [Integer] the upload date of a given doujinshi
139
- # @since 0.1.0
140
- # @example
141
- # doujinshi.upload_date #=> 2018-01-17 15:56:16 +0000
142
- #
143
60
  def upload_date
144
- Time.iso8601(@client.body.match(/<time .+ datetime="(.*?)"/)[1])
145
- end
146
-
147
- #
148
- # Give all tags of a doujinshi
149
- #
150
- # @return [Array] of Tag class of a given doujinshi
151
- # @since 0.1.0
152
- # @example
153
- # doujinshi.tags
154
- #
155
- def tags
156
- res = @client.body.match(%r{Tags:\s*<span class="tags">(.+)<\/span>})
157
- return [] if res.nil?
158
-
159
- parse_tags(res[1])
61
+ Time.iso8601(client.body.match(/<time .+ datetime="(.*?)"/)[1])
160
62
  end
161
63
 
162
- #
163
- # Give a counter of tags
164
- #
165
- # @return [Integer] of tags
166
- # @since 0.1.0
167
- # @example
168
- # doujinshi.count_tags #=> 9
169
- #
170
- def count_tags
171
- res = @client.body.match(%r{Tags:\s*<span class="tags">(.+)<\/span>})
172
-
173
- res.nil? ? 0 : parse_tags(res[1]).length
174
- end
175
-
176
- #
177
- # Check if a particular doujinshi have some tags
178
- #
179
- # @return [Bool] true if the doujinshi have tags, otherwise false
180
- # @since 0.1.0
181
- # @example
182
- # doujinshi.tags? #=> true
183
- #
184
- def tags?
185
- !@client.body.match(%r{Tags:\s*<span class="tags">(.+)<\/span>}).nil?
186
- end
187
-
188
- #
189
- # Give all parodies of a doujinshi
190
- #
191
- # @since 0.1.0
192
- # @see Doujinshi#tags
193
- #
194
- def parodies
195
- res = @client.body.match(%r{Parodies:\s+<span class="tags">(.+)<\/span>})
196
- return [] if res.nil?
197
-
198
- parse_tags(res[1])
199
- end
200
-
201
- #
202
- # Give a counter of parodies
203
- #
204
- # @since 0.1.0
205
- # @see Doujinshi#count_tags
206
- #
207
- def count_parodies
208
- res = @client.body.match(%r{Parodies:\s+<span class="tags">(.+)<\/span>})
209
-
210
- res.nil? ? 0 : parse_tags(res[1]).length
211
- end
212
-
213
- #
214
- # Check if a particular doujinshi have some parodies
215
- #
216
- # @since 0.1.0
217
- # @see Doujinshi#tags?
218
- #
219
- def parodies?
220
- !@client.body.match(%r{Parodies:\s+<span class="tags">(.+)<\/span>}).nil?
221
- end
222
-
223
- #
224
- # Give all characters of a doujinshi
225
- #
226
- # @since 0.1.0
227
- # @see Doujinshi#tags
228
- #
229
- def characters
230
- res = @client.body.match(%r{Characters:\s+<span class="tags">(.+)<\/span>})
231
- return [] if res.nil?
232
-
233
- parse_tags(res[1])
234
- end
235
-
236
- #
237
- # Give a counter of characters
238
- #
239
- # @since 0.1.0
240
- # @see Doujinshi#count_tags
241
- #
242
- def count_characters
243
- res = @client.body.match(%r{Characters:\s+<span class="tags">(.+)<\/span>})
244
-
245
- res.nil? ? 0 : parse_tags(res[1]).length
246
- end
247
-
248
- #
249
- # Check if a particular doujinshi have some characters
250
- #
251
- # @since 0.1.0
252
- # @see Doujinshi#tags?
253
- #
254
- def characters?
255
- !@client.body.match(%r{Characters:\s+<span class="tags">(.+)<\/span>}).nil?
256
- end
257
-
258
- #
259
- # Give all artists of a doujinshi
260
- #
261
- # @since 0.1.0
262
- # @see Doujinshi#tags
263
- #
264
- def artists
265
- res = @client.body.match(%r{Artists:\s+<span class="tags">(.+)<\/span>})
266
- return [] if res.nil?
267
-
268
- parse_tags(res[1])
269
- end
270
-
271
- #
272
- # Give a counter of artists
273
- #
274
- # @since 0.1.0
275
- # @see Doujinshi#count_tags
276
- #
277
- def count_artists
278
- res = @client.body.match(%r{Artists:\s+<span class="tags">(.+)<\/span>})
279
-
280
- res.nil? ? 0 : parse_tags(res[1]).length
281
- end
282
-
283
- #
284
- # Check if a particular doujinshi have some artists
285
- #
286
- # @since 0.1.0
287
- # @see Doujinshi#tags?
288
- #
289
- def artists?
290
- !@client.body.match(%r{Artists:\s+<span class="tags">(.+)<\/span>}).nil?
291
- end
64
+ %w[tags parodies characters artists groups languages categories].each do |method|
65
+ define_method method do
66
+ return instance_variable_get("@#{method}") if instance_variable_defined?("@#{method}")
292
67
 
293
- #
294
- # Give all groups of a doujinshi
295
- #
296
- # @since 0.1.0
297
- # @see Doujinshi#tags
298
- #
299
- def groups
300
- res = @client.body.match(%r{Groups:\s+<span class="tags">(.+)<\/span>})
301
- return [] if res.nil?
302
-
303
- parse_tags(res[1])
304
- end
68
+ res = client.body.match(%r{#{method.capitalize}:\s*<span class="tags">(.+)<\/span>})
69
+ return [] if res.nil?
305
70
 
306
- #
307
- # Give a counter of groups
308
- #
309
- # @since 0.1.0
310
- # @see Doujinshi#count_tags
311
- #
312
- def count_groups
313
- res = @client.body.match(%r{Groups:\s+<span class="tags">(.+)<\/span>})
71
+ instance_variable_set("@#{method}", parsing_informations(res[1]))
72
+ end
314
73
 
315
- res.nil? ? 0 : parse_tags(res[1]).length
316
- end
74
+ define_method "count_#{method}" do
75
+ send(method).size
76
+ end
317
77
 
318
- #
319
- # Check if a particular doujinshi have some groups
320
- #
321
- # @since 0.1.0
322
- # @see Doujinshi#tags?
323
- #
324
- def groups?
325
- !@client.body.match(%r{Groups:\s+<span class="tags">(.+)<\/span>}).nil?
78
+ define_method "#{method}?" do
79
+ !send(method).empty?
80
+ end
326
81
  end
327
82
 
328
- #
329
- # Give all languages of a doujinshi
330
- #
331
- # @since 0.1.0
332
- # @see Doujinshi#tags
333
- #
334
- def languages
335
- res = @client.body.match(%r{Languages:\s+<span class="tags">(.+)<\/span>})
336
- return [] if res.nil?
337
-
338
- parse_tags(res[1])
339
- end
83
+ private
340
84
 
341
- #
342
- # Give a counter of languages
343
- #
344
- # @since 0.1.0
345
- # @see Doujinshi#count_tags
346
- #
347
- def count_languages
348
- res = @client.body.match(%r{Languages:\s+<span class="tags">(.+)<\/span>})
85
+ def parsing_informations(res)
86
+ res.split(%r{<a(.+?)<\/a>}).reject(&:empty?).map do |line|
87
+ id = parse_id(line)
88
+ name = parse_name(line)
89
+ count = parse_count(line)
90
+ url = parse_url(line)
349
91
 
350
- res.nil? ? 0 : parse_tags(res[1]).length
92
+ OpenStruct.new(id: id, name: name, count: count, url: url)
93
+ end
351
94
  end
352
95
 
353
- #
354
- # Check if a particular doujinshi have some languages
355
- #
356
- # @since 0.1.0
357
- # @see Doujinshi#tags?
358
- #
359
- def languages?
360
- !@client.body.match(%r{Languages:\s+<span class="tags">(.+)<\/span>}).nil?
96
+ def parse_id(line)
97
+ line.match(/tag-(\d+)/)[1]
361
98
  end
362
99
 
363
- #
364
- # Give all categories of a doujinshi
365
- #
366
- # @since 0.1.0
367
- # @see Doujinshi#tags
368
- #
369
- def categories
370
- res = @client.body.match(%r{Categories:\s+<span class="tags">(.+)<\/span>})
371
- return [] if res.nil?
372
-
373
- parse_tags(res[1])
100
+ def parse_name(line)
101
+ line.match(/class="name">(.+?)</)[1].strip
374
102
  end
375
103
 
376
- #
377
- # Give a counter of categories
378
- #
379
- # @since 0.1.0
380
- # @see Doujinshi#count_tags
381
- #
382
- def count_categories
383
- res = @client.body.match(%r{Categories:\s+<span class="tags">(.+)<\/span>})
104
+ def parse_count(line)
105
+ count = line.match(/class="count">(\d+.)</)[1]
384
106
 
385
- res.nil? ? 0 : parse_tags(res[1]).length
107
+ count[-1] == 'K' ? count.to_i * 1000 : count.to_i
386
108
  end
387
109
 
388
- #
389
- # Check if a particular doujinshi have some categories
390
- #
391
- # @since 0.1.0
392
- # @see Doujinshi#tags?
393
- #
394
- def categories?
395
- !@client.body.match(%r{Categories:\s+<span class="tags">(.+)<\/span>}).nil?
110
+ def parse_url(line)
111
+ line.match(/href=\"(.+?)\"/)[1]
396
112
  end
113
+ end
397
114
 
398
- #
399
- # @private
400
- #
401
-
402
- private
403
-
404
- def parse_tags(res)
405
- res.split(%r{<a(.+?)<\/a>}).reject(&:empty?).map do |line|
406
- id = line.match(/tag-(\d+)/)[1]
407
- name = line.match(/">(.+?)</)[1].strip
408
- count = line.match(/class="count">(\d+.)</)[1]
409
- url = line.match(/href=\"(.+?)\"/)[1]
410
-
411
- count = count[-1] == 'K' ? count.to_i * 1000 : count.to_i
115
+ %w[tag parody character artist group language category].each do |class_name|
116
+ c = Class.new do
117
+ def self.count(keyword)
118
+ class_name = name.split('::').last.downcase
119
+ keyword = keyword.tr(' ', '-')
120
+ @client = Net::HTTP.get_response(URI("https://nhentai.net/#{class_name}/#{keyword}/"))
121
+ return unless exists?
412
122
 
413
- Info.new(id, name, count, url)
123
+ @client.body.match(%r{<a.*class="count">(.*)<\/span><\/a>})[1].to_i
414
124
  end
415
- end
416
- end
417
125
 
418
- class Tag
419
- #
420
- # List all doujinshi of the page of a given tag
421
- #
422
- # @param [String] keyword of the research
423
- # @param [Integer] sort optional, 1 is sorting by time, 2 is by popularity
424
- # @param [Integer] page each page can return 25 doujinshi
425
- # @return [Array] array of Info
426
- # @since 0.2.0
427
- #
428
- def self.listing(keyword, sort = 1, page = 1)
429
- keyword.tr!(' ', '-')
430
- sort = sort == 1 ? '' : 'popular'
431
- client = Net::HTTP.get_response(URI("https://nhentai.net/tag/#{keyword}/#{sort}?page=#{page}"))
432
- res = client.body.split(%r{<div class="gallery".+?>(.+)</div>}).select { |line| line.include?('<a href="/g/') }
433
-
434
- parse_tags(res)
435
- end
126
+ def self.listing(keyword, sort = 1, page = 1)
127
+ class_name = name.split('::').last.downcase
128
+ keyword = keyword.tr(' ', '-')
129
+ sort = sort == 1 ? '' : 'popular'
130
+ @client = Net::HTTP.get_response(URI("https://nhentai.net/#{class_name}/#{keyword}/#{sort}?page=#{page}"))
131
+ return unless exists?
436
132
 
437
- #
438
- # @private
439
- #
440
- def self.parse_tags(res)
441
- res.map do |line|
442
- id = line.match(%r{/g/(\d+)/})[1]
443
- name = line.match(%r{<div class="caption">(.+)</div>})[1].strip
444
- count = 1
445
- url = "/g/#{id}"
446
-
447
- Info.new(id, name, count, url)
133
+ res = @client.body.split(%r{<div class="gallery".+?>(.*?)<\/div>}).select { |line| line.include?('<a href="/g/') }
134
+ parse_tags(res)
448
135
  end
449
- end
450
- end
451
-
452
- class Parody < Tag
453
- #
454
- # List all doujinshi of the page of a given parody
455
- #
456
- # @since 0.2.0
457
- # @see Tag#listing
458
- #
459
- def self.listing(keyword, sort = 1, page = 1)
460
- keyword.tr!(' ', '-')
461
- sort = sort == 1 ? '' : 'popular'
462
- client = Net::HTTP.get_response(URI("https://nhentai.net/parody/#{keyword}/#{sort}?page=#{page}"))
463
- res = client.body.split(%r{<div class="gallery".+?>(.+)</div>}).select { |line| line.include?('<a href="/g/') }
464
-
465
- parse_tags(res)
466
- end
467
- end
468
136
 
469
- class Character < Tag
470
- #
471
- # List all doujinshi of the page of a given character
472
- #
473
- # @since 0.2.0
474
- # @see Tag#listing
475
- #
476
- def self.listing(keyword, sort = 1, page = 1)
477
- keyword.tr!(' ', '-')
478
- sort = sort == 1 ? '' : 'popular'
479
- client = Net::HTTP.get_response(URI("https://nhentai.net/character/#{keyword}/#{sort}?page=#{page}"))
480
- res = client.body.split(%r{<div class="gallery".+?>(.+)</div>}).select { |line| line.include?('<a href="/g/') }
481
-
482
- parse_tags(res)
483
- end
484
- end
137
+ private
485
138
 
486
- class Artist < Tag
487
- #
488
- # List all doujinshi of the page of a given artists
489
- #
490
- # @since 0.2.0
491
- # @see Tag#listing
492
- #
493
- def self.listing(keyword, sort = 1, page = 1)
494
- keyword.tr!(' ', '-')
495
- sort = sort == 1 ? '' : 'popular'
496
- client = Net::HTTP.get_response(URI("https://nhentai.net/artist/#{keyword}/#{sort}?page=#{page}"))
497
- res = client.body.split(%r{<div class="gallery".+?>(.+)</div>}).select { |line| line.include?('<a href="/g/') }
498
-
499
- parse_tags(res)
500
- end
501
- end
139
+ def self.exists?
140
+ @client.code == '200'
141
+ end
502
142
 
503
- class Group < Tag
504
- #
505
- # List all doujinshi of the page of a given group
506
- #
507
- # @since 0.2.0
508
- # @see Tag#listing
509
- #
510
- def self.listing(keyword, sort = 1, page = 1)
511
- keyword.tr!(' ', '-')
512
- sort = sort == 1 ? '' : 'popular'
513
- client = Net::HTTP.get_response(URI("https://nhentai.net/group/#{keyword}/#{sort}?page=#{page}"))
514
- res = client.body.split(%r{<div class="gallery".+?>(.+)</div>}).select { |line| line.include?('<a href="/g/') }
515
-
516
- parse_tags(res)
517
- end
518
- end
143
+ def self.parse_tags(res)
144
+ res.map do |line|
145
+ id = line.match(%r{/g/(\d+)/})[1]
146
+ name = line.match(/<div class="caption">(.+)/)[1].strip
147
+ url = "/g/#{id}"
519
148
 
520
- class Language < Tag
521
- #
522
- # List all doujinshi of the page of a given language
523
- #
524
- # @since 0.2.0
525
- # @see Tag#listing
526
- #
527
- def self.listing(keyword, sort = 1, page = 1)
528
- keyword.tr!(' ', '-')
529
- sort = sort == 1 ? '' : 'popular'
530
- client = Net::HTTP.get_response(URI("https://nhentai.net/language/#{keyword}/#{sort}?page=#{page}"))
531
- res = client.body.split(%r{<div class="gallery".+?>(.+)</div>}).select { |line| line.include?('<a href="/g/') }
532
-
533
- parse_tags(res)
149
+ OpenStruct.new(id: id, name: name, url: url)
150
+ end
151
+ end
534
152
  end
535
- end
536
153
 
537
- class Category < Tag
538
- #
539
- # List all doujinshi of the page of a given category
540
- #
541
- # @since 0.2.0
542
- # @see Tag#listing
543
- #
544
- def self.listing(keyword, sort = 1, page = 1)
545
- keyword.tr!(' ', '-')
546
- sort = sort == 1 ? '' : 'popular'
547
- client = Net::HTTP.get_response(URI("https://nhentai.net/category/#{keyword}/#{sort}?page=#{page}"))
548
- res = client.body.split(%r{<div class="gallery".+?>(.+)</div>}).select { |line| line.include?('<a href="/g/') }
549
-
550
- parse_tags(res)
551
- end
154
+ Kernel.const_set(class_name.capitalize, c)
552
155
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nhentai-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gael Roussel
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-17 00:00:00.000000000 Z
11
+ date: 2022-05-14 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
14
  email: gaelroussel@protonmail.com
@@ -21,9 +21,8 @@ homepage: https://rubygems.org/gems/nhentai-api
21
21
  licenses:
22
22
  - MIT
23
23
  metadata:
24
- documentation_uri: https://www.rubydoc.info/github/groussel42/nhentai-api
25
24
  source_code_uri: https://github.com/Mraiih/nhentai-api
26
- post_install_message:
25
+ post_install_message:
27
26
  rdoc_options: []
28
27
  require_paths:
29
28
  - lib
@@ -38,9 +37,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
38
37
  - !ruby/object:Gem::Version
39
38
  version: '0'
40
39
  requirements: []
41
- rubyforge_project:
42
- rubygems_version: 2.7.6
43
- signing_key:
40
+ rubygems_version: 3.3.3
41
+ signing_key:
44
42
  specification_version: 4
45
43
  summary: nhentai-api is a basic and easy to use API for nhentai.net
46
44
  test_files: []