youtube-dl.rb 0.1.0 → 0.1.1
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.
- checksums.yaml +4 -4
- data/.travis.yml +5 -2
- data/README.md +5 -0
- data/lib/youtube-dl/options.rb +37 -11
- data/lib/youtube-dl/runner.rb +9 -0
- data/lib/youtube-dl/support.rb +1 -0
- data/lib/youtube-dl/version.rb +1 -1
- data/test/youtube-dl/options_test.rb +8 -0
- data/vendor/bin/youtube-dl +0 -0
- data/vendor/bin/youtube-dl.exe +0 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7c86b235fb38c06bc33f5984e8993d166da84c8
|
4
|
+
data.tar.gz: 3711e90fbc95e01c0f1175ccdf2833c1f188908d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aad917d66ff21d4ecb11bf1f8228c1091dd9b618ab56cded145ed0bac9ef4685d6098860cbeb06cf5c66d7abd651259fe76fc157af82934ab1cc02e4f34b8795
|
7
|
+
data.tar.gz: dea3940ed3ef94ad31e38f177c4b6824ec11f086038d014e590425d15d5760767b29614ca01948bf4b406854c60e5c8b7932b0f302367d31ef18b9826d5c57bb
|
data/.travis.yml
CHANGED
@@ -2,6 +2,9 @@ before_install: 'sudo chmod 755 ./vendor/bin/youtube-dl'
|
|
2
2
|
rvm:
|
3
3
|
- 1.9.3 # EOL, but still supporting
|
4
4
|
- 2.0.0 # Oldest stable
|
5
|
-
- 2.2.
|
6
|
-
|
5
|
+
- 2.2.3 # Current stable
|
6
|
+
- jruby-head # JRuby
|
7
7
|
- rbx-2 # Rubinius
|
8
|
+
|
9
|
+
notifications:
|
10
|
+
slack: layer8x:cvixULdjCINfq7u9Zs1rS0VY
|
data/README.md
CHANGED
@@ -5,8 +5,13 @@ Ruby wrapper for [youtube-dl](http://rg3.github.io/youtube-dl/).
|
|
5
5
|
[](https://travis-ci.org/layer8x/youtube-dl.rb)
|
6
6
|
[](https://codeclimate.com/github/layer8x/youtube-dl.rb)
|
7
7
|
[](https://codeclimate.com/github/layer8x/youtube-dl.rb/coverage)
|
8
|
+
[](https://hakiri.io/github/layer8x/youtube-dl.rb/master)
|
9
|
+
[](http://inch-ci.org/github/layer8x/youtube-dl.rb)
|
10
|
+
[](https://gemnasium.com/layer8x/youtube-dl.rb)
|
11
|
+
|
8
12
|
[](http://waffle.io/layer8x/youtube-dl.rb)
|
9
13
|
|
14
|
+
|
10
15
|
## Install the gem
|
11
16
|
|
12
17
|
Add this line to your application's Gemfile:
|
data/lib/youtube-dl/options.rb
CHANGED
@@ -17,12 +17,20 @@ module YoutubeDL
|
|
17
17
|
end
|
18
18
|
alias_method :to_h, :to_hash
|
19
19
|
|
20
|
+
# Iterate through the paramized keys and values.
|
21
|
+
#
|
22
|
+
# @yield [paramized_key, value]
|
23
|
+
#
|
24
|
+
# TODO: Enumerable?
|
20
25
|
def each_paramized
|
21
26
|
@store.each do |key, value|
|
22
27
|
yield(paramize(key), value)
|
23
28
|
end
|
24
29
|
end
|
25
30
|
|
31
|
+
# Iterate through the keys and their paramized counterparts.
|
32
|
+
#
|
33
|
+
# @yield [key, paramized_key]
|
26
34
|
def each_paramized_key
|
27
35
|
@store.each_key do |key|
|
28
36
|
yield(key, paramize(key))
|
@@ -30,16 +38,25 @@ module YoutubeDL
|
|
30
38
|
end
|
31
39
|
|
32
40
|
# Set options using a block
|
41
|
+
#
|
42
|
+
# @yield [config] self
|
43
|
+
# TODO: support calling without arguments
|
33
44
|
def configure(&block)
|
34
45
|
block.call(self)
|
35
46
|
end
|
36
47
|
|
37
48
|
# Get option with brackets syntax
|
49
|
+
#
|
50
|
+
# @param key [Object] key
|
51
|
+
# @return [Object] value
|
38
52
|
def [](key)
|
39
53
|
@store[key.to_sym]
|
40
54
|
end
|
41
55
|
|
42
56
|
# Set option with brackets syntax
|
57
|
+
#
|
58
|
+
# @param key [Object] key
|
59
|
+
# @param value [Object] value
|
43
60
|
def []=(key, value)
|
44
61
|
@store[key.to_sym] = value
|
45
62
|
end
|
@@ -54,15 +71,34 @@ module YoutubeDL
|
|
54
71
|
end
|
55
72
|
end
|
56
73
|
|
74
|
+
# Calls a block to do operations on keys
|
75
|
+
# See sanitize_keys! for examples
|
76
|
+
#
|
77
|
+
# @param block [Proc] Block with operations on keys
|
78
|
+
# @yieldparam key [Object] Original key
|
79
|
+
# @yieldreturn [Object] Manipulated key
|
80
|
+
def manipulate_keys!(&block)
|
81
|
+
@store.keys.each do |old_name|
|
82
|
+
new_name = block.call(old_name)
|
83
|
+
unless new_name == old_name
|
84
|
+
@store[new_name] = @store[old_name]
|
85
|
+
@store.delete(old_name)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
57
90
|
# Symbolizes and sanitizes keys in the option store
|
58
91
|
def sanitize_keys!
|
59
92
|
# Symbolize
|
60
93
|
manipulate_keys! { |key_name| key_name.is_a?(Symbol) ? key_name : key_name.to_sym }
|
61
94
|
|
62
|
-
# Underscoreize
|
95
|
+
# Underscoreize (because Cocaine doesn't like hyphens)
|
63
96
|
manipulate_keys! { |key_name| key_name.to_s.tr('-', '_').to_sym }
|
64
97
|
end
|
65
98
|
|
99
|
+
# Symbolizes and sanitizes keys and returns a copy of self
|
100
|
+
#
|
101
|
+
# @return [YoutubeDL::Options] Options with sanitized keys.
|
66
102
|
def sanitize_keys
|
67
103
|
safe_copy = self.dup
|
68
104
|
safe_copy.sanitize_keys!
|
@@ -77,15 +113,5 @@ module YoutubeDL
|
|
77
113
|
def paramize(key)
|
78
114
|
key.to_s.tr("_", '-')
|
79
115
|
end
|
80
|
-
|
81
|
-
def manipulate_keys!(&block)
|
82
|
-
@store.keys.each do |old_name|
|
83
|
-
new_name = block.call(old_name)
|
84
|
-
unless new_name == old_name
|
85
|
-
@store[new_name] = @store[old_name]
|
86
|
-
@store.delete(old_name)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
116
|
end
|
91
117
|
end
|
data/lib/youtube-dl/runner.rb
CHANGED
@@ -46,7 +46,12 @@ module YoutubeDL
|
|
46
46
|
end
|
47
47
|
alias_method :download, :run
|
48
48
|
|
49
|
+
# Returns a list of supported formats for the video in the form of
|
50
|
+
# [{:format_code => '000', :extension => 'avi', :resolution => '320x240', :note => 'More details about the format'}]
|
51
|
+
#
|
52
|
+
# @return [Array] Format list
|
49
53
|
def formats
|
54
|
+
# TODO: Move formats to its own model?
|
50
55
|
parse_format_output(cocaine_line("--list-formats #{quoted(url)}").run)
|
51
56
|
end
|
52
57
|
|
@@ -68,6 +73,10 @@ module YoutubeDL
|
|
68
73
|
commands.join(' ')
|
69
74
|
end
|
70
75
|
|
76
|
+
# Helper to add quotes to beginning and end of a URL.
|
77
|
+
#
|
78
|
+
# @param url [String] Raw URL
|
79
|
+
# @return [String] Quoted URL
|
71
80
|
def quoted(url)
|
72
81
|
"\"#{url}\""
|
73
82
|
end
|
data/lib/youtube-dl/support.rb
CHANGED
@@ -11,6 +11,7 @@ module YoutubeDL
|
|
11
11
|
if $?.exitstatus == 0 # $? is an object with information on that last command run with backticks.
|
12
12
|
system_path.strip
|
13
13
|
else
|
14
|
+
# TODO: Search vendor bin for executable before just saying it's there.
|
14
15
|
vendor_path = File.absolute_path("#{__FILE__}/../../../vendor/bin/#{exe}")
|
15
16
|
File.chmod(775, vendor_path) unless File.executable?(vendor_path) # Make sure vendor binary is executable
|
16
17
|
vendor_path
|
data/lib/youtube-dl/version.rb
CHANGED
@@ -80,4 +80,12 @@ describe YoutubeDL::Options do
|
|
80
80
|
@options.store['some-key'] = "some_value"
|
81
81
|
assert_instance_of YoutubeDL::Options, @options.sanitize_keys
|
82
82
|
end
|
83
|
+
|
84
|
+
it 'should manipulate keys' do
|
85
|
+
@options.some_key = 'value'
|
86
|
+
@options.manipulate_keys! do |key|
|
87
|
+
key.to_s.upcase
|
88
|
+
end
|
89
|
+
assert_equal({'SOME_KEY' => 'value'}, @options.store)
|
90
|
+
end
|
83
91
|
end
|
data/vendor/bin/youtube-dl
CHANGED
Binary file
|
data/vendor/bin/youtube-dl.exe
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: youtube-dl.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sapslaj
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-09-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cocaine
|