cherrypicker 0.3.12 → 0.3.13

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.
@@ -46,8 +46,11 @@ module Cherrypicker
46
46
  uri = URI.parse(@link.to_s)
47
47
  http = Net::HTTP.new(uri.host, uri.port)
48
48
  http.use_ssl = true if uri.scheme == "https"
49
+ http.open_timeout = 3 # seconds
50
+ http.read_timeout = 3 # seconds
49
51
  request = Net::HTTP::Get.new(uri.request_uri)
50
52
  request.initialize_http_header({"User-Agent" => Cherrypicker::random_agent})
53
+
51
54
  unless (uri.host.include? 'youtube.com') && (uri.request_uri.include? 'videoplayback') #youtube throws EOFError
52
55
  head = http.request_head(URI.escape(uri.path))
53
56
  case head
@@ -57,7 +60,8 @@ module Cherrypicker
57
60
  @size = head['content-length'] if @size.nil? && head['content-length'].to_i > 1024
58
61
  end
59
62
  end
60
- puts "unknown file size for #{@filename}" if @size.nil?
63
+
64
+ puts "unknown file size for #{@filename} but downloading..." if @size.nil?
61
65
  http.request(request) do |response|
62
66
  bar = ProgressBar.new((@filename ||= File.basename(uri.path)), @size.to_i) unless @size.nil?
63
67
  bar.format_arguments=[:title, :percentage, :bar, :stat_for_file_transfer] unless @size.nil?
@@ -70,6 +74,7 @@ module Cherrypicker
70
74
  end
71
75
  end
72
76
  end
77
+
73
78
  @finished = true
74
79
  puts
75
80
  puts "download completed"
@@ -58,17 +58,10 @@ module Cherrypicker
58
58
  format_ext["5"] = ["flv", "old default?"]
59
59
 
60
60
  download_url = video_info_hash["fmt_url_map"][formats.first]
61
- @filename = video_info_hash["title"].delete("\"'").gsub(/[^0-9A-Za-z]/, '_') + "." + format_ext[formats.first].first
61
+ @filename = video_info_hash["title"].delete("\"'").gsub(/[^0-9A-Za-z]/, '_') + "." + format_ext[formats.first].first
62
+ @download_url = download_url
63
+ end
62
64
 
63
- #there might be a redirect let check
64
- reply = Cherrypicker::remote_query("#{download_url}")
65
- if reply.response['location']
66
- @download_url = reply.response['location']
67
- else
68
- @download_url = download_url
69
- end
70
- end
71
-
72
65
  def download
73
66
  Cherrypicker::download_file(@download_url, :location => @location, :filename => @filename)
74
67
  end
@@ -1,3 +1,3 @@
1
1
  module Cherrypicker
2
- VERSION = "0.3.12"
2
+ VERSION = "0.3.13"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: cherrypicker
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.12
5
+ version: 0.3.13
6
6
  platform: ruby
7
7
  authors:
8
8
  - Karl Entwistle