viddl-rb 0.82 → 0.84

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- viddl-rb (0.81)
4
+ viddl-rb (0.82)
5
5
  mechanize
6
6
  nokogiri (~> 1.5.0)
7
7
  progressbar
data/README.md CHANGED
@@ -1,20 +1,23 @@
1
- __viddl-rb:__
2
- Initially created by Marc Seeger (@rb2k)
3
- Repo: http://github.com/rb2k/viddl-rb
1
+ __viddl-rb:__
2
+ Initially created by Marc Seeger ([@rb2k](github.com/rb2k))
3
+
4
+ Repo: http://github.com/rb2k/viddl-rb
5
+
4
6
  [![Gem Version](https://badge.fury.io/rb/viddl-rb.png)](http://badge.fury.io/rb/viddl-rb)[![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
7
 
6
8
  __Installation:__
7
9
 
8
- gem install viddl-rb
10
+ `gem install viddl-rb`
9
11
 
10
12
  __Usage:__
11
13
 
12
- Download a video:
14
+ Download a video:
13
15
  ```viddl-rb http://www.youtube.com/watch?v=QH2-TGUlwu4```
14
16
 
15
17
  Viddl-rb supports the following command line options:
16
18
  ```
17
19
  -e, --extract-audio Save video audio to file
20
+ -a, --abort-on-failure Abort download queue if one of the videos fail to download
18
21
  -u, --url-only Prints url without downloading
19
22
  -t, --title-only Prints title without downloading
20
23
  -f, --filter REGEX Filters a video playlist according to the regex (Youtube only right now)
@@ -24,26 +27,26 @@ Viddl-rb supports the following command line options:
24
27
  -h, --help Displays the help screen
25
28
  ```
26
29
 
27
- Download a video and extract the audio:
30
+ Download a video and extract the audio:
28
31
  ```viddl-rb http://www.youtube.com/watch?v=QH2-TGUlwu4 --extract-audio```
29
32
 
30
33
  In both cases we'll name the output file according to the video title.
31
34
 
32
- Setting the video save directory:
35
+ Setting the video save directory:
33
36
  ```viddl-rb http://vimeo.com/38372260 --save-dir C:/myvideos```
34
37
 
35
38
  The --save-dir option works with both absolute and relative paths (relative based on the directory viddl-rb is run from).
36
39
  If you want to save to a folder with spaces in it, you have to quote the path like this: --save-dir "C:/my videos"
37
40
 
38
- __Youtube plugin specifics:__
41
+ __Youtube plugin specifics:__
39
42
 
40
- Download all videos on a playlist:
43
+ Download all videos on a playlist:
41
44
  ```viddl-rb http://www.youtube.com/playlist?list=PL7E8DA0A515924126```
42
45
 
43
- Download all videos from a user:
46
+ Download all videos from a user:
44
47
  ```viddl-rb http://www.youtube.com/user/tedtalksdirector```
45
48
 
46
- Filter videos to download from a user/playlist:
49
+ Filter videos to download from a user/playlist:
47
50
  ```viddl-rb http://www.youtube.com/user/tedtalksdirector --filter /internet/i```
48
51
 
49
52
  The --filter argument accepts a regular expression and will only download videos where the title matches the regex.
@@ -62,7 +65,7 @@ The ViddlRb module has the following module public methods:
62
65
 
63
66
  * __get_urls_names(url)__
64
67
  -- Returns an array of one or more hashes that has the keys :url which
65
- points to the download url and :name which points to the name
68
+ points to the download url and :name which points to the name
66
69
  (which is a filename safe version of the video title with a file extension).
67
70
  Returns nil if the url is not recognized by any plugins.
68
71
 
@@ -90,8 +93,8 @@ require 'viddl-rb'
90
93
  ViddlRb.io = $stdout # plugins will now write their output to $stdout
91
94
  ```
92
95
 
93
- All the __get__ methods in the ViddlRb module will raise either a ViddlRb::PluginError or a ViddlRb::DownloadError if the plugin fails.
94
- A ViddlRb::PluginError is raised if the plugin fails in an unexpected way, and a ViddlRb::DownloadError is raised if the video could not be downloaded for some reason.
96
+ All the __get__ methods in the ViddlRb module will raise either a ViddlRb::PluginError or a ViddlRb::DownloadError if the plugin fails.
97
+ A ViddlRb::PluginError is raised if the plugin fails in an unexpected way, and a ViddlRb::DownloadError is raised if the video could not be downloaded for some reason.
95
98
  An example of that is if a Youtube video is not embeddable - then it can't be downloaded.
96
99
 
97
100
  ```ruby
@@ -107,7 +110,7 @@ end
107
110
 
108
111
  __Requirements:__
109
112
 
110
- * curl/wget or the [progress bar](http://github.com/nex3/ruby-progressbar/) gem
113
+ * curl/wget or the [progress bar](http://github.com/nex3/ruby-progressbar/) gem
111
114
  * [Nokogiri](http://nokogiri.org/)
112
115
  * [Mechanize](http://mechanize.rubyforge.org/)
113
116
  * ffmpeg if you want to extract audio tracks from the videos
@@ -115,8 +118,9 @@ __Requirements:__
115
118
  __Co Maintainer:__
116
119
  * [kl](https://github.com/kl): Windows support (who knew!), bug fixes, veoh plugin, metacafe plugin, refactoring it into a library, ...
117
120
 
118
- __Contributors:__
121
+ __Contributors:__
119
122
  * [divout](https://github.com/divout) aka Ivan K: blip.tv plugin, bugfixes
120
123
  * Sniper: bugfixes
121
124
  * [Serabe](https://github.com/Serabe) aka Sergio Arbeo: packaging viddl as a binary
122
125
  * [laserlemon](https://github.com/laserlemon): Adding gemnasium images to readme
126
+ * [farleyknight](https://github.com/farleyknight): Various small fixes and improvements
@@ -10,7 +10,11 @@ class Downloader
10
10
 
11
11
  result = ViddlRb::DownloadHelper.save_file(url, name, :save_dir => params[:save_dir], :tool => params[:tool])
12
12
  unless result
13
- raise DownloadFailedError, "Download for #{name} failed."
13
+ if params[:abort_on_failure]
14
+ raise DownloadFailedError, "Download for #{name} failed."
15
+ else
16
+ puts "Download for #{name} failed. Moving onto next file."
17
+ end
14
18
  else
15
19
  puts "Download for #{name} successful."
16
20
  ViddlRb::AudioHelper.extract(name, params[:save_dir]) if params[:extract_audio]
@@ -10,6 +10,7 @@ class ParameterParser
10
10
  #returns a hash with the parameters in it:
11
11
  # :url => the video url
12
12
  # :extract_audio => should attempt to extract audio? (true/false)
13
+ # :skip_failed => should skip failed downloads? (true/false)
13
14
  # :url_only => do not download, only print the urls to stdout
14
15
  # :title_only => do not download, only print the titles to stdout
15
16
  # :playlist_filter => a regular expression used to filter playlists
@@ -21,6 +22,7 @@ class ParameterParser
21
22
  # Default option values are set here
22
23
  options = {
23
24
  :extract_audio => false,
25
+ :abort_on_failure => false,
24
26
  :url_only => false,
25
27
  :title_only => false,
26
28
  :playlist_filter => nil,
@@ -40,6 +42,10 @@ class ParameterParser
40
42
  end
41
43
  end
42
44
 
45
+ opts.on("-a", "--abort-on-failure", "Abort download queue if one of the videos fail to download") do
46
+ options[:abort_on_failure] = true
47
+ end
48
+
43
49
  opts.on("-u", "--url-only", "Prints url without downloading") do
44
50
  options[:url_only] = true
45
51
  end
@@ -68,8 +74,8 @@ class ParameterParser
68
74
  end
69
75
  end
70
76
 
71
- opts.on("-q", "--quality QUALITY",
72
- "Specifies the video format and resolution in the following way => resolution:extension (e.g. 720:mp4)") do |quality|
77
+ opts.on("-q", "--quality QUALITY",
78
+ "Specifies the video format and resolution in the following way => resolution:extension (e.g. 720:mp4)") do |quality|
73
79
  if match = quality.match(/(\d+):(.*)/)
74
80
  res = match[1]
75
81
  ext = match[2]
@@ -91,7 +97,7 @@ class ParameterParser
91
97
  print_help_and_exit(optparse) if args.empty? # exit if no video url
92
98
  url = args.first # the url is the only element left
93
99
  validate_url!(url) # raise exception if invalid url
94
- options[:url] = url
100
+ options[:url] = url
95
101
  options
96
102
  end
97
103
 
@@ -103,7 +109,7 @@ class ParameterParser
103
109
  def self.validate_url!(url)
104
110
  unless url =~ /^http/
105
111
  raise OptionParser::InvalidArgument.new(
106
- "please include 'http' with your URL e.g. http://www.youtube.com/watch?v=QH2-TGUlwu4")
112
+ "please include 'http' with your URL e.g. http://www.youtube.com/watch?v=QH2-TGUlwu4")
107
113
  end
108
114
  end
109
115
  end
@@ -7,7 +7,7 @@ module ViddlRb
7
7
  no_ext_filename = file_path.split('.')[0..-1][0]
8
8
  #capture stderr because ffmpeg expects an output param and will error out
9
9
  puts "Gathering information about the downloaded file."
10
- file_info = Open3.popen3("ffmpeg -i #{file_path}") {|stdin, stdout, stderr, wait_thr| stderr.read }
10
+ file_info = Open3.popen3("ffmpeg -i #{File.join(save_dir, file_path)}") {|stdin, stdout, stderr, wait_thr| stderr.read }
11
11
  puts "Done gathering information about the downloaded file."
12
12
 
13
13
  if !file_info.to_s.empty?
@@ -18,11 +18,11 @@ module ViddlRb
18
18
  else
19
19
  raise "ERROR: Couldn't find any audio:\n#{file_info.inspect}"
20
20
  end
21
-
21
+
22
22
  extension_mapper = {
23
- 'aac' => 'm4a',
24
- 'mp3' => 'mp3',
25
- 'vorbis' => 'ogg'
23
+ 'aac' => 'm4a',
24
+ 'mp3' => 'mp3',
25
+ 'vorbis' => 'ogg'
26
26
  }
27
27
 
28
28
  if extension_mapper.key?(audio_format)
@@ -37,7 +37,7 @@ module ViddlRb
37
37
  puts "Audio file seems to exist already, removing it before extraction."
38
38
  File.delete(output_filename)
39
39
  end
40
- Open3.popen3("ffmpeg -i #{file_path} -vn -acodec copy #{output_filename}") { |stdin, stdout, stderr, wait_thr| stdout.read }
40
+ Open3.popen3("ffmpeg -i #{File.join(save_dir, file_path)} -vn -acodec copy #{output_filename}") { |stdin, stdout, stderr, wait_thr| stdout.read }
41
41
  puts "Done extracting audio to #{output_filename}"
42
42
  else
43
43
  raise "ERROR: Error while checking audio track of #{file_path}"
@@ -34,7 +34,7 @@ module ViddlRb
34
34
 
35
35
  #recursively get the final location (after following all redirects) for an url.
36
36
  def self.get_final_location(url)
37
- Net::HTTP.get_response(URI(url)) do |res|
37
+ Net::HTTP.get_response(URI.parse(url)) do |res|
38
38
  location = res["location"]
39
39
  return url if location.nil?
40
40
  return get_final_location(location)
data/plugins/youtube.rb CHANGED
@@ -81,8 +81,7 @@ class Youtube < PluginBase
81
81
  file_name = PluginBase.make_filename_safe(title) + "." + VIDEO_FORMATS[selected_format][:extension]
82
82
 
83
83
  # cleaning
84
- clean_url = urls_formats[selected_format].gsub(/\\u0026[^&]*/, "")
85
-
84
+ clean_url = urls_formats[selected_format].gsub(/\\u0026[^&]*/, "").split(',type=video').first
86
85
  {:url => clean_url, :name => file_name}
87
86
  end
88
87
 
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: 175
4
+ hash: 163
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 82
9
- version: "0.82"
8
+ - 84
9
+ version: "0.84"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Marc Seeger
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2013-08-21 00:00:00 Z
17
+ date: 2013-09-02 00:00:00 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: nokogiri