viddl-rb 1.1.0 → 1.1.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: e36d0776aad4ecbf56dad9546a7f3a0236deef45
4
- data.tar.gz: a80850fff961a4fe51021e3b30729640ba25d960
3
+ metadata.gz: 6e6d7c34a048f529044ad34e45e5a0cbd7c8bb40
4
+ data.tar.gz: d8b4e60fd73ca136332b77f2c7b7b51035f4f584
5
5
  SHA512:
6
- metadata.gz: aed20ff2a353ca907dac6b576f1c84f975a9fc28db5333b48d683e1b27bb5b997f5ade8fce3d7fca2ddcb76ec13d2595979de08768cd4b10abfbe4c14afba9de
7
- data.tar.gz: 00460cb0524433f00653f10be86b773510d8afc0c0c847b82dd8f385ce37445de72ddec79786838e75e00a1ea54b5e006fc0d294777fa3d97c48125b74c4d3d4
6
+ metadata.gz: cf74b3c11632db917939a39bb1b4658beb964f846bca0919e097a6ddaece1e75d97f36e3bf27deaaee803213c537a70b74c1ee97bee3e3493f2bffbdeac32387
7
+ data.tar.gz: 41f831d26aa16948e1b9dd6a529b5f56b247f664a08aef4022591f3a53f2def1e6ccbf7e5000c2358315ceaf946a255968f38df712ddb6fc7332f40352ee1589
@@ -5,21 +5,31 @@
5
5
  class Driver
6
6
 
7
7
  def initialize(param_hash)
8
+ @urls = param_hash[:urls]
9
+ param_hash.delete :urls
8
10
  @params = param_hash
9
11
  @downloader = Downloader.new
10
12
  end
11
13
 
12
14
  #starts the downloading process or print just the urls or names.
13
15
  def start
14
- queue = get_download_queue
16
+ @urls.each do |url|
17
+ @params[:url] = url
18
+ puts "\nAnalyzing URL: #{url}"
19
+ begin
20
+ queue = get_download_queue
15
21
 
16
- if @params[:url_only]
17
- queue.each { |url_name| puts url_name[:url] }
18
- elsif @params[:title_only]
19
- queue.each { |url_name| puts url_name[:name] }
20
- else
21
- @downloader.download(queue, @params)
22
- end
22
+ if @params[:url_only]
23
+ queue.each { |url_name| puts url_name[:url] }
24
+ elsif @params[:title_only]
25
+ queue.each { |url_name| puts url_name[:name] }
26
+ else
27
+ @downloader.download(queue, @params)
28
+ end
29
+ rescue => e
30
+ puts e.message
31
+ end
32
+ end
23
33
  end
24
34
 
25
35
  private
@@ -8,7 +8,7 @@ class ParameterParser
8
8
  DEFAULT_SAVE_DIR = "."
9
9
 
10
10
  #returns a hash with the parameters in it:
11
- # :url => the video url
11
+ # :urls => array of the video urls
12
12
  # :extract_audio => should attempt to extract audio? (true/false)
13
13
  # :skip_failed => should skip failed downloads? (true/false)
14
14
  # :url_only => do not download, only print the urls to stdout
@@ -98,13 +98,8 @@ class ParameterParser
98
98
  optparse.parse!(args)
99
99
  # exit if no video url
100
100
  print_help_and_exit(optparse) if args.empty?
101
- # the url is the only element left
102
- url = args.first
103
- # Seems like some users like to pass non protocol prefixed URIs
104
- url = "http://#{url}" unless url.start_with?('http')
105
- # raise exception if invalid url
106
- validate_url!(url)
107
- options[:url] = url
101
+ # remaining elements in args will be urls
102
+ options[:urls] = validate_urls args
108
103
  options
109
104
  end
110
105
 
@@ -113,11 +108,8 @@ class ParameterParser
113
108
  exit(0)
114
109
  end
115
110
 
116
- def self.validate_url!(url)
117
- unless url =~ /^http/
118
- raise OptionParser::InvalidArgument.new(
119
- "please include 'http' with your URL e.g. http://www.youtube.com/watch?v=QH2-TGUlwu4")
120
- end
111
+ def self.validate_urls(urls)
112
+ urls.map {|url| url.start_with?("http") ? url : "http://#{url}"}
121
113
  end
122
114
 
123
115
  def self.validate_quality_options!(width, height, extension, quality)
@@ -26,7 +26,6 @@ begin
26
26
  puts "Plugins loaded: #{ViddlRb::PluginBase.registered_plugins.inspect}"
27
27
 
28
28
  puts "Will try to extract audio: #{params[:extract_audio] == true}."
29
- puts "Analyzing URL: #{params[:url]}"
30
29
 
31
30
  driver = Driver.new(params)
32
31
  driver.start # starts the download process
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: viddl-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc Seeger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-01 00:00:00.000000000 Z
11
+ date: 2015-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri