nyaa_anime 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7b5f76e31eb304f9bd2da100db4ba61e7e8c7f9e
4
- data.tar.gz: 98401204f42c1eef222d04311f11d393e8fa3d97
3
+ metadata.gz: d114871e4368e1d3fbee2e706f31592009178192
4
+ data.tar.gz: f5716d1fbf597abc7a6de8872672ca53472696aa
5
5
  SHA512:
6
- metadata.gz: 5bb5df18e96208711349295ff4c72e2a7b29566a8020d6fd1ed0a4a7fe03b454f4f3919e6075db8295617d093f077a08ceb876b56ab338fbdd2dd2735995ef17
7
- data.tar.gz: 41dd13be4176515d507aa2f2403600f245821a99cf655cd1761d2f4a0c617a69b1e7a9d817db888c559d90b554fe50a93b9cd1cfa3232935f779b7afc57f6cd5
6
+ metadata.gz: d4d325d829bd96a04090c6719e4064f31dbbb59713e9c1e4d6f00bc654ef1cb5d515859b44bb40ee40e291b3518dc28030821b0a4f5d4ced559413b94874c5f3
7
+ data.tar.gz: 7a1b51b5b736fc67164e523009a59432189ede39f474167f1e7d298664d1188e5d38e98ee7fd7b293c0e0eef7a5a245f92e61172c4381563ca26f97b76014142
@@ -31,10 +31,18 @@ class NyaaAnime
31
31
  if page_urls.count == MAX_PAGE_COUNT - 1
32
32
  puts "Truncating at #{MAX_PAGE_COUNT} pages." unless quiet
33
33
  end
34
- Parallel.each(page_urls) do |url|
35
- results = Nokogiri::HTML(open(url)).css('.tlistrow')
36
- titles.concat results.css('.tlistname a').map { |a| a.content }
37
- dl_urls.concat results.css('.tlistdownload a').map { |a| a.attr('href') }
34
+ if page_urls.count > 1
35
+ page_titles = [nil] * (page_urls.count - 1)
36
+ page_dl_urls = [nil] * (page_urls.count - 1)
37
+ Parallel.each_with_index(page_urls, in_threads: 10) do |url, i|
38
+ r = Nokogiri::HTML(open(url)).css('.tlistrow')
39
+ page_titles[i] = r.css('.tlistname a').map { |a| a.content }
40
+ page_dl_urls[i] = r.css('.tlistdownload a').map { |a| a.attr('href') }
41
+ print "."
42
+ end
43
+ print "\n"
44
+ page_titles.each { |pt| titles.concat pt }
45
+ page_dl_urls.each { |pd| dl_urls.concat pd }
38
46
  end
39
47
  titles.each_with_index { |t, i| @downloads[t] = dl_urls[i] }
40
48
  @titles = titles.sort!
@@ -161,11 +169,11 @@ class NyaaAnime
161
169
  end
162
170
 
163
171
  def download_all
164
- Parallel.map(@titles) { |t| download(t) }
172
+ Parallel.map(@titles, in_threads: 10) { |t| download(t) }
165
173
  end
166
174
 
167
175
  def download_all_new
168
- Parallel.map(@new_titles) { |t| download(t) }
176
+ Parallel.map(@new_titles, in_threads: 10) { |t| download(t) }
169
177
  end
170
178
 
171
179
  def download_count
@@ -1,3 +1,3 @@
1
1
  class NyaaAnime
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nyaa_anime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Tsubaki Wu