nhentai-api 0.1.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nhentai-api.rb +390 -26
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32a8382ebb1c8c5d33c1ea5baa94070fc31c788e31c628c7708fa6b29d839d94
|
4
|
+
data.tar.gz: 1481e553fa7663d4898b07f60814413be9efb5ccd8c233bf84d0c08281edf934
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 585e38f3cb7d7397158535f4bca3dd10fde1fb70bcf4ecddff39eaee1178a6f1cb50ad668897e838087265ab1d61e1617bddbdcede672d1f8de46fd6a5945a7c
|
7
|
+
data.tar.gz: a5246ab1e9eec631fed5a883822e9190bf004e88840b6cc9d3a13cb516371019a61c77a7808d04eaebd325ba5a23e823c930351f16f5063164cc8b963fd5c2e5
|
data/lib/nhentai-api.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'net/http'
|
2
|
+
require 'time'
|
2
3
|
|
3
|
-
class
|
4
|
+
class Info
|
4
5
|
attr_reader :id, :name, :count, :url
|
5
6
|
|
6
7
|
def initialize(id, name, count, url)
|
@@ -17,172 +18,535 @@ class Doujinshi
|
|
17
18
|
def initialize(id)
|
18
19
|
@id = id
|
19
20
|
@client = Net::HTTP.get_response(URI("https://nhentai.net/g/#{@id}/"))
|
20
|
-
|
21
|
-
|
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
|
22
25
|
end
|
23
26
|
|
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
|
+
#
|
24
35
|
def exists?
|
25
|
-
@client.code == 200
|
36
|
+
@client.code == '200'
|
26
37
|
end
|
27
38
|
|
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
|
+
#
|
28
47
|
def title
|
29
|
-
@client.body.match(
|
48
|
+
@client.body.match(/"pretty">(.*?)</)[1]
|
30
49
|
end
|
31
50
|
|
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
|
+
#
|
32
59
|
def cover
|
33
|
-
|
60
|
+
res = @client.body.match(%r{https://t.nhentai.net/galleries/#{@media_id}/cover\.(.{3})"})
|
61
|
+
|
62
|
+
"https://t.nhentai.net/galleries/#{@media_id}/cover.#{res[1]}"
|
34
63
|
end
|
35
64
|
|
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
|
+
#
|
36
75
|
def page(page = 1)
|
37
76
|
res = @client.body.match(%r{https://t.nhentai.net/galleries/#{@media_id}/#{page}t\.(.{3})"})
|
38
77
|
|
39
78
|
"https://i.nhentai.net/galleries/#{@media_id}/#{page}.#{res[1]}"
|
40
79
|
end
|
41
80
|
|
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
|
+
#
|
42
89
|
def pages
|
43
90
|
(1..@count_pages).map { |page| page(page) }
|
44
91
|
end
|
45
92
|
|
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
|
+
#
|
46
103
|
def thumbnail(page = 1)
|
47
104
|
res = @client.body.match(%r{https://t.nhentai.net/galleries/#{@media_id}/(#{page}t\..{3})"})
|
48
105
|
|
49
106
|
"https://t.nhentai.net/galleries/#{@media_id}/#{res[1]}"
|
50
107
|
end
|
51
108
|
|
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
|
+
#
|
52
117
|
def thumbnails
|
53
118
|
(1..@count_pages).map { |page| thumbnail(page) }
|
54
119
|
end
|
55
120
|
|
56
|
-
|
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
|
+
def count_favorites
|
57
130
|
regex = %r{<span>Favorite <span class="nobold">.(\d+).<\/span><\/span>}
|
58
131
|
|
59
132
|
@client.body.match(regex)[1].to_i
|
60
133
|
end
|
61
134
|
|
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
|
+
#
|
62
143
|
def upload_date
|
63
|
-
Time.
|
64
|
-
end
|
65
|
-
|
66
|
-
def parse_tags(res)
|
67
|
-
res.split(%r{<a(.+?)<\/a>}).reject(&:empty?).map do |line|
|
68
|
-
id = line.match(/tag-(\d+)/)[1]
|
69
|
-
name = line.match(/">(.+?)</)[1].strip
|
70
|
-
count = line.match(/\((.+?)\)</)[1].tr(',', '').to_i
|
71
|
-
url = line.match(/href=\"(.+?)\"/)[1]
|
72
|
-
|
73
|
-
Tag.new(id, name, count, url)
|
74
|
-
end
|
144
|
+
Time.iso8601(@client.body.match(/<time .+ datetime="(.*?)"/)[1])
|
75
145
|
end
|
76
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
|
+
#
|
77
155
|
def tags
|
78
156
|
res = @client.body.match(%r{Tags:\s*<span class="tags">(.+)<\/span>})
|
157
|
+
return [] if res.nil?
|
79
158
|
|
80
159
|
parse_tags(res[1])
|
81
160
|
end
|
82
161
|
|
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
|
+
#
|
83
170
|
def count_tags
|
84
171
|
res = @client.body.match(%r{Tags:\s*<span class="tags">(.+)<\/span>})
|
85
172
|
|
86
|
-
res.nil? ? 0 : parse_tags(res[1]).
|
173
|
+
res.nil? ? 0 : parse_tags(res[1]).length
|
87
174
|
end
|
88
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
|
+
#
|
89
184
|
def tags?
|
90
185
|
!@client.body.match(%r{Tags:\s*<span class="tags">(.+)<\/span>}).nil?
|
91
186
|
end
|
92
187
|
|
188
|
+
#
|
189
|
+
# Give all parodies of a doujinshi
|
190
|
+
#
|
191
|
+
# @since 0.1.0
|
192
|
+
# @see Doujinshi#tags
|
193
|
+
#
|
93
194
|
def parodies
|
94
195
|
res = @client.body.match(%r{Parodies:\s+<span class="tags">(.+)<\/span>})
|
196
|
+
return [] if res.nil?
|
95
197
|
|
96
198
|
parse_tags(res[1])
|
97
199
|
end
|
98
200
|
|
201
|
+
#
|
202
|
+
# Give a counter of parodies
|
203
|
+
#
|
204
|
+
# @since 0.1.0
|
205
|
+
# @see Doujinshi#count_tags
|
206
|
+
#
|
99
207
|
def count_parodies
|
100
208
|
res = @client.body.match(%r{Parodies:\s+<span class="tags">(.+)<\/span>})
|
101
209
|
|
102
|
-
res.nil? ? 0 : parse_tags(res[1]).
|
210
|
+
res.nil? ? 0 : parse_tags(res[1]).length
|
103
211
|
end
|
104
212
|
|
213
|
+
#
|
214
|
+
# Check if a particular doujinshi have some parodies
|
215
|
+
#
|
216
|
+
# @since 0.1.0
|
217
|
+
# @see Doujinshi#tags?
|
218
|
+
#
|
105
219
|
def parodies?
|
106
220
|
!@client.body.match(%r{Parodies:\s+<span class="tags">(.+)<\/span>}).nil?
|
107
221
|
end
|
108
222
|
|
223
|
+
#
|
224
|
+
# Give all characters of a doujinshi
|
225
|
+
#
|
226
|
+
# @since 0.1.0
|
227
|
+
# @see Doujinshi#tags
|
228
|
+
#
|
109
229
|
def characters
|
110
230
|
res = @client.body.match(%r{Characters:\s+<span class="tags">(.+)<\/span>})
|
231
|
+
return [] if res.nil?
|
111
232
|
|
112
233
|
parse_tags(res[1])
|
113
234
|
end
|
114
235
|
|
236
|
+
#
|
237
|
+
# Give a counter of characters
|
238
|
+
#
|
239
|
+
# @since 0.1.0
|
240
|
+
# @see Doujinshi#count_tags
|
241
|
+
#
|
115
242
|
def count_characters
|
116
243
|
res = @client.body.match(%r{Characters:\s+<span class="tags">(.+)<\/span>})
|
117
244
|
|
118
|
-
res.nil? ? 0 : parse_tags(res[1]).
|
245
|
+
res.nil? ? 0 : parse_tags(res[1]).length
|
119
246
|
end
|
120
247
|
|
248
|
+
#
|
249
|
+
# Check if a particular doujinshi have some characters
|
250
|
+
#
|
251
|
+
# @since 0.1.0
|
252
|
+
# @see Doujinshi#tags?
|
253
|
+
#
|
121
254
|
def characters?
|
122
255
|
!@client.body.match(%r{Characters:\s+<span class="tags">(.+)<\/span>}).nil?
|
123
256
|
end
|
124
257
|
|
258
|
+
#
|
259
|
+
# Give all artists of a doujinshi
|
260
|
+
#
|
261
|
+
# @since 0.1.0
|
262
|
+
# @see Doujinshi#tags
|
263
|
+
#
|
125
264
|
def artists
|
126
265
|
res = @client.body.match(%r{Artists:\s+<span class="tags">(.+)<\/span>})
|
266
|
+
return [] if res.nil?
|
127
267
|
|
128
268
|
parse_tags(res[1])
|
129
269
|
end
|
130
270
|
|
271
|
+
#
|
272
|
+
# Give a counter of artists
|
273
|
+
#
|
274
|
+
# @since 0.1.0
|
275
|
+
# @see Doujinshi#count_tags
|
276
|
+
#
|
131
277
|
def count_artists
|
132
278
|
res = @client.body.match(%r{Artists:\s+<span class="tags">(.+)<\/span>})
|
133
279
|
|
134
|
-
res.nil? ? 0 : parse_tags(res[1]).
|
280
|
+
res.nil? ? 0 : parse_tags(res[1]).length
|
135
281
|
end
|
136
282
|
|
283
|
+
#
|
284
|
+
# Check if a particular doujinshi have some artists
|
285
|
+
#
|
286
|
+
# @since 0.1.0
|
287
|
+
# @see Doujinshi#tags?
|
288
|
+
#
|
137
289
|
def artists?
|
138
290
|
!@client.body.match(%r{Artists:\s+<span class="tags">(.+)<\/span>}).nil?
|
139
291
|
end
|
140
292
|
|
293
|
+
#
|
294
|
+
# Give all groups of a doujinshi
|
295
|
+
#
|
296
|
+
# @since 0.1.0
|
297
|
+
# @see Doujinshi#tags
|
298
|
+
#
|
141
299
|
def groups
|
142
300
|
res = @client.body.match(%r{Groups:\s+<span class="tags">(.+)<\/span>})
|
301
|
+
return [] if res.nil?
|
143
302
|
|
144
303
|
parse_tags(res[1])
|
145
304
|
end
|
146
305
|
|
306
|
+
#
|
307
|
+
# Give a counter of groups
|
308
|
+
#
|
309
|
+
# @since 0.1.0
|
310
|
+
# @see Doujinshi#count_tags
|
311
|
+
#
|
147
312
|
def count_groups
|
148
313
|
res = @client.body.match(%r{Groups:\s+<span class="tags">(.+)<\/span>})
|
149
314
|
|
150
|
-
res.nil? ? 0 : parse_tags(res[1]).
|
315
|
+
res.nil? ? 0 : parse_tags(res[1]).length
|
151
316
|
end
|
152
317
|
|
318
|
+
#
|
319
|
+
# Check if a particular doujinshi have some groups
|
320
|
+
#
|
321
|
+
# @since 0.1.0
|
322
|
+
# @see Doujinshi#tags?
|
323
|
+
#
|
153
324
|
def groups?
|
154
325
|
!@client.body.match(%r{Groups:\s+<span class="tags">(.+)<\/span>}).nil?
|
155
326
|
end
|
156
327
|
|
328
|
+
#
|
329
|
+
# Give all languages of a doujinshi
|
330
|
+
#
|
331
|
+
# @since 0.1.0
|
332
|
+
# @see Doujinshi#tags
|
333
|
+
#
|
157
334
|
def languages
|
158
335
|
res = @client.body.match(%r{Languages:\s+<span class="tags">(.+)<\/span>})
|
336
|
+
return [] if res.nil?
|
159
337
|
|
160
338
|
parse_tags(res[1])
|
161
339
|
end
|
162
340
|
|
341
|
+
#
|
342
|
+
# Give a counter of languages
|
343
|
+
#
|
344
|
+
# @since 0.1.0
|
345
|
+
# @see Doujinshi#count_tags
|
346
|
+
#
|
163
347
|
def count_languages
|
164
348
|
res = @client.body.match(%r{Languages:\s+<span class="tags">(.+)<\/span>})
|
165
349
|
|
166
|
-
res.nil? ? 0 : parse_tags(res[1]).
|
350
|
+
res.nil? ? 0 : parse_tags(res[1]).length
|
167
351
|
end
|
168
352
|
|
353
|
+
#
|
354
|
+
# Check if a particular doujinshi have some languages
|
355
|
+
#
|
356
|
+
# @since 0.1.0
|
357
|
+
# @see Doujinshi#tags?
|
358
|
+
#
|
169
359
|
def languages?
|
170
360
|
!@client.body.match(%r{Languages:\s+<span class="tags">(.+)<\/span>}).nil?
|
171
361
|
end
|
172
362
|
|
363
|
+
#
|
364
|
+
# Give all categories of a doujinshi
|
365
|
+
#
|
366
|
+
# @since 0.1.0
|
367
|
+
# @see Doujinshi#tags
|
368
|
+
#
|
173
369
|
def categories
|
174
370
|
res = @client.body.match(%r{Categories:\s+<span class="tags">(.+)<\/span>})
|
371
|
+
return [] if res.nil?
|
175
372
|
|
176
373
|
parse_tags(res[1])
|
177
374
|
end
|
178
375
|
|
376
|
+
#
|
377
|
+
# Give a counter of categories
|
378
|
+
#
|
379
|
+
# @since 0.1.0
|
380
|
+
# @see Doujinshi#count_tags
|
381
|
+
#
|
179
382
|
def count_categories
|
180
383
|
res = @client.body.match(%r{Categories:\s+<span class="tags">(.+)<\/span>})
|
181
384
|
|
182
|
-
res.nil? ? 0 : parse_tags(res[1]).
|
385
|
+
res.nil? ? 0 : parse_tags(res[1]).length
|
183
386
|
end
|
184
387
|
|
388
|
+
#
|
389
|
+
# Check if a particular doujinshi have some categories
|
390
|
+
#
|
391
|
+
# @since 0.1.0
|
392
|
+
# @see Doujinshi#tags?
|
393
|
+
#
|
185
394
|
def categories?
|
186
395
|
!@client.body.match(%r{Categories:\s+<span class="tags">(.+)<\/span>}).nil?
|
187
396
|
end
|
397
|
+
|
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
|
412
|
+
|
413
|
+
Info.new(id, name, count, url)
|
414
|
+
end
|
415
|
+
end
|
416
|
+
end
|
417
|
+
|
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
|
436
|
+
|
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)
|
448
|
+
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
|
+
|
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
|
485
|
+
|
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
|
502
|
+
|
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
|
519
|
+
|
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)
|
534
|
+
end
|
535
|
+
end
|
536
|
+
|
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
|
188
552
|
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.
|
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:
|
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:
|
14
|
+
email: gaelroussel@protonmail.com
|
15
15
|
executables: []
|
16
16
|
extensions: []
|
17
17
|
extra_rdoc_files: []
|
@@ -21,7 +21,8 @@ homepage: https://rubygems.org/gems/nhentai-api
|
|
21
21
|
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/Mraiih/nhentai-api
|
25
26
|
post_install_message:
|
26
27
|
rdoc_options: []
|
27
28
|
require_paths:
|
@@ -37,7 +38,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
38
|
- !ruby/object:Gem::Version
|
38
39
|
version: '0'
|
39
40
|
requirements: []
|
40
|
-
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 2.7.6
|
41
43
|
signing_key:
|
42
44
|
specification_version: 4
|
43
45
|
summary: nhentai-api is a basic and easy to use API for nhentai.net
|