viddl-rb 0.61 → 0.63

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.
data/Gemfile.lock CHANGED
@@ -1,15 +1,16 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- viddl-rb (0.6)
4
+ viddl-rb (0.61)
5
5
  nokogiri
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
- mime-types (1.17.2)
11
- minitest (2.11.3)
12
- nokogiri (1.5.0)
10
+ mime-types (1.18)
11
+ minitest (2.12.1)
12
+ nokogiri (1.5.2)
13
+ nokogiri (1.5.2-java)
13
14
  rake (0.9.2.2)
14
15
  rest-client (1.6.7)
15
16
  mime-types (>= 1.16)
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  __viddl-rb:__
2
2
  Created by Marc Seeger (@rb2k)
3
3
  Repo: http://github.com/rb2k/viddl-rb
4
- [![Build Status](https://secure.travis-ci.org/rb2k/viddl-rb.png)](http://travis-ci.org/rb2k/viddl-rb)
4
+ [![Build Status](https://secure.travis-ci.org/rb2k/viddl-rb.png)](http://travis-ci.org/rb2k/viddl-rb) [![Dependency Status](https://gemnasium.com/rb2k/viddl-rb.png)](https://gemnasium.com/rb2k/viddl-rb)
5
5
 
6
6
 
7
7
 
@@ -31,4 +31,5 @@ __Contributors:__
31
31
  * [kl](https://github.com/kl): Windows support (who knew!), bug fixes, veoh plugin, metacafe plugin
32
32
  * [divout](https://github.com/divout) aka Ivan K: blip.tv plugin, bugfixes
33
33
  * Sniper: bugfixes
34
- * [Serabe](https://github.com/Serabe) aka Sergio Arbeo: packaging viddl as a binary
34
+ * [Serabe](https://github.com/Serabe) aka Sergio Arbeo: packaging viddl as a binary
35
+ * [laserlemon](https://github.com/laserlemon): Adding gemnasium images to readme
@@ -1,4 +1,5 @@
1
1
  class DownloadHelper
2
+
2
3
  #usually not called directly
3
4
  def self.fetch_file(uri)
4
5
 
@@ -21,24 +22,33 @@ class DownloadHelper
21
22
  end
22
23
 
23
24
  #simple helper that will save a file from the web and save it with a progress bar
24
- def self.save_file(file_uri, file_name)
25
+ def self.save_file(file_uri, file_name, amount_of_retries = 6)
26
+ trap("SIGINT") { puts "goodbye"; exit }
25
27
  unescaped_uri = CGI::unescape(file_uri)
26
- result = false
27
- if os_has?("wget")
28
- puts "using wget"
29
- result = system("wget \"#{unescaped_uri}\" -O #{file_name}")
30
- elsif os_has?("curl")
31
- puts "using curl"
32
- #-L means: follow redirects, We set an agent because Vimeo seems to want one
33
- result = system("curl -A 'Wget/1.8.1' -L \"#{unescaped_uri}\" -o #{file_name}")
34
- else
35
- puts "using net/http"
36
- open(file_name, 'wb') { |file|
37
- file.write(fetch_file(unescaped_uri)); puts
38
- }
39
- result = true
40
- end
41
- result
28
+ #Some providers seem to flake out every now end then
29
+ amount_of_retries.times do |i|
30
+ if os_has?("wget")
31
+ puts "using wget"
32
+ `wget \"#{unescaped_uri}\" -O #{file_name}`
33
+ elsif os_has?("curl")
34
+ puts "using curl"
35
+ #-L means: follow redirects, We set an agent because Vimeo seems to want one
36
+ `curl -A 'Wget/1.8.1' -L \"#{unescaped_uri}\" -o #{file_name}`
37
+ else
38
+ puts "using net/http"
39
+ open(file_name, 'wb') { |file|
40
+ file.write(fetch_file(unescaped_uri)); puts
41
+ }
42
+ end
43
+ #we were successful, we're outta here
44
+ if $? == 0
45
+ break
46
+ else
47
+ puts "Download seems to have failed (retrying, attempt #{i+1}/#{amount_of_retries})"
48
+ sleep 2
49
+ end
50
+ end
51
+ $? == 0
42
52
  end
43
53
 
44
54
  #checks to see whether the os has a certain utility like wget or curl
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: viddl-rb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 113
4
+ hash: 117
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 61
9
- version: "0.61"
8
+ - 63
9
+ version: "0.63"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Marc Seeger