youtube-dl.rb 0.1.0 → 0.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: dc95699d01465f5cb0881852a1e8d37e1a9c0794
4
- data.tar.gz: ab8b547a79cfa7a04ac8e3c56ab46da1f7df31dd
3
+ metadata.gz: d7c86b235fb38c06bc33f5984e8993d166da84c8
4
+ data.tar.gz: 3711e90fbc95e01c0f1175ccdf2833c1f188908d
5
5
  SHA512:
6
- metadata.gz: f4620ff0634fd5cfad55178b623ccc267e57576f4ab5f79fb8f1f967cd926c3f9e3062f5b26fd994de52c1536813c94ec5be2c0f33fecbc1d8f70d9f3fa403e9
7
- data.tar.gz: 5f3f979b7fa7ea34cdf7f170d5a2e2466502ad753704baa11a065016e0ddac735bbab08fbfdacd2d7c0403c95651f02c7d6bde175841d5d473a78d1aa7ae07f6
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.2 # Current stable
6
- # - jruby-19mode # JRuby
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
  [![Build Status](https://travis-ci.org/layer8x/youtube-dl.rb.svg?branch=master)](https://travis-ci.org/layer8x/youtube-dl.rb)
6
6
  [![Code Climate](https://codeclimate.com/github/layer8x/youtube-dl.rb/badges/gpa.svg)](https://codeclimate.com/github/layer8x/youtube-dl.rb)
7
7
  [![Test Coverage](https://codeclimate.com/github/layer8x/youtube-dl.rb/badges/coverage.svg)](https://codeclimate.com/github/layer8x/youtube-dl.rb/coverage)
8
+ [![security](https://hakiri.io/github/layer8x/youtube-dl.rb/master.svg)](https://hakiri.io/github/layer8x/youtube-dl.rb/master)
9
+ [![Inline docs](http://inch-ci.org/github/layer8x/youtube-dl.rb.svg?branch=master)](http://inch-ci.org/github/layer8x/youtube-dl.rb)
10
+ [![Dependency Status](https://gemnasium.com/layer8x/youtube-dl.rb.svg)](https://gemnasium.com/layer8x/youtube-dl.rb)
11
+
8
12
  [![Stories in Ready](https://badge.waffle.io/layer8x/youtube-dl.rb.svg?label=ready&title=Ready)](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:
@@ -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
@@ -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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module YoutubeDL
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -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
Binary file
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.0
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-08-31 00:00:00.000000000 Z
12
+ date: 2015-09-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cocaine