mediainfo 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog +11 -3
- data/README.markdown +10 -4
- data/lib/mediainfo.rb +4 -3
- data/lib/mediainfo/string.rb +13 -7
- data/mediainfo.gemspec +2 -2
- data/test/mediainfo_string_test.rb +10 -2
- data/test/mediainfo_test.rb +3 -3
- metadata +3 -3
data/Changelog
CHANGED
@@ -1,7 +1,15 @@
|
|
1
|
+
v0.7.1 Tweakage
|
2
|
+
- Removed Mediainfo#parsed_response accessor which always returned nil after
|
3
|
+
multi-stream API updates
|
4
|
+
- Added Mediainfo::Stream#parsed_response reader to restore the ability to
|
5
|
+
access metadata not surfaced through explicit :mediainfo_attr_reader declarations
|
6
|
+
- Added more compatible shell escaping style [d--j]
|
7
|
+
|
1
8
|
v0.7.0 Multiple Stream Support
|
2
|
-
-
|
3
|
-
|
4
|
-
|
9
|
+
- updated API to support files with multiple streams of one type(NOTE: MAJOR API CHANGE!)
|
10
|
+
e.g. many Quicktime files have multiple video streams
|
11
|
+
- removed support for some top level accessors that implied certain track types
|
12
|
+
e.g. mediainfo.height would now most likely be mediainfo.video.height or mediainfo.image.height
|
5
13
|
|
6
14
|
v0.6.2 XML Configuration Examples
|
7
15
|
- added examples on how to configure XML back end
|
data/README.markdown
CHANGED
@@ -4,7 +4,7 @@ Mediainfo is a class wrapping [the mediainfo CLI](http://mediainfo.sourceforge.n
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
$ gem install mediainfo
|
7
|
+
$ gem install mediainfo
|
8
8
|
|
9
9
|
## Usage
|
10
10
|
|
@@ -16,7 +16,12 @@ You can specify an alternate path if necessary:
|
|
16
16
|
Mediainfo.path = "/opt/local/bin/mediainfo"
|
17
17
|
|
18
18
|
|
19
|
-
|
19
|
+
Now, from this point, I bet some *actual* usage examples would be great. Unfortunately,
|
20
|
+
I haven't really gotten around to proper documentation, yet. HOWEVER, please see the
|
21
|
+
very reasonable test suite accompanying the source code for this library. It contains
|
22
|
+
a bunch of relevant usage examples.
|
23
|
+
|
24
|
+
Moving on, REXML is used as the XML parser by default. If you'd like, you can
|
20
25
|
configure Mediainfo to use Hpricot or Nokogiri instead using one of
|
21
26
|
the following approaches:
|
22
27
|
|
@@ -53,5 +58,6 @@ generate XML output, and is no longer supported.
|
|
53
58
|
## Contributors
|
54
59
|
|
55
60
|
* Seth Thomas Rasmussen - [http://greatseth.com](http://greatseth.com)
|
56
|
-
* Peter Vandenberk
|
57
|
-
* Ned Campion
|
61
|
+
* Peter Vandenberk - [http://github.com/pvdb](http://github.com/pvdb)
|
62
|
+
* Ned Campion - [http://github.com/nedcampion](http://github.com/nedcampion)
|
63
|
+
* Daniel Jagszent - [http://github.com/d--j](http://github.com/d--j)
|
data/lib/mediainfo.rb
CHANGED
@@ -160,6 +160,8 @@ class Mediainfo
|
|
160
160
|
@parsed_response = { @stream_type => {} }
|
161
161
|
end
|
162
162
|
|
163
|
+
attr_reader :parsed_response
|
164
|
+
|
163
165
|
def [](k); @parsed_response[@stream_type][k]; end
|
164
166
|
def []=(k,v); @parsed_response[@stream_type][k] = v; end
|
165
167
|
|
@@ -321,8 +323,7 @@ class Mediainfo
|
|
321
323
|
|
322
324
|
###
|
323
325
|
|
324
|
-
attr_reader :raw_response, :
|
325
|
-
:full_filename, :filename, :path, :escaped_full_filename
|
326
|
+
attr_reader :raw_response, :full_filename, :filename, :path, :escaped_full_filename
|
326
327
|
|
327
328
|
###
|
328
329
|
|
@@ -343,7 +344,7 @@ class Mediainfo
|
|
343
344
|
raise ArgumentError, "need a path to a video file, got nil" unless @full_filename
|
344
345
|
raise ArgumentError, "need a path to a video file, #{@full_filename} does not exist" unless File.exist? @full_filename
|
345
346
|
|
346
|
-
@escaped_full_filename = @full_filename.
|
347
|
+
@escaped_full_filename = @full_filename.shell_escape_double_quotes
|
347
348
|
|
348
349
|
self.raw_response = mediainfo!
|
349
350
|
end
|
data/lib/mediainfo/string.rb
CHANGED
@@ -1,11 +1,17 @@
|
|
1
1
|
class String
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
# returns the string enclosed in double quotes.
|
3
|
+
# all characters in the string that could be harmful will be escaped.
|
4
|
+
#
|
5
|
+
# e.g.
|
6
|
+
# 'test'.shell_escape_double_quotes # => "test"
|
7
|
+
# '$\\'"`'.shell_escape_double_quotes # => "\$\\'\"\`"
|
8
|
+
#
|
9
|
+
# This should work in al POSIX compatible shells.
|
10
|
+
#
|
11
|
+
# see: http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_02_03
|
12
|
+
def shell_escape_double_quotes
|
13
|
+
'"'+gsub(/\\|"|\$|`/, '\\\\\0')+'"'
|
14
|
+
end unless method_defined?(:shell_escape_double_quotes)
|
9
15
|
|
10
16
|
# stolen from active_support/inflector
|
11
17
|
# TODO require "active_support/core_ext/string/inflections" when 3.0 is released
|
data/mediainfo.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{mediainfo}
|
5
|
-
s.version = "0.7.
|
5
|
+
s.version = "0.7.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Seth Thomas Rasmussen"]
|
9
|
-
s.date = %q{2010-04-
|
9
|
+
s.date = %q{2010-04-06}
|
10
10
|
s.description = %q{Mediainfo is a class wrapping the mediainfo CLI (http://mediainfo.sourceforge.net)}
|
11
11
|
s.email = %q{sethrasmussen@gmail.com}
|
12
12
|
s.extra_rdoc_files = ["LICENSE", "README.markdown", "lib/mediainfo.rb", "lib/mediainfo/attr_readers.rb", "lib/mediainfo/string.rb"]
|
@@ -3,10 +3,18 @@ require "mediainfo_test_helper"
|
|
3
3
|
|
4
4
|
class MediainfoStringTest < ActiveSupport::TestCase
|
5
5
|
test "escaping slashes" do
|
6
|
-
assert_equal '
|
6
|
+
assert_equal '"foo\\\bar"', 'foo\bar'.shell_escape_double_quotes
|
7
7
|
end
|
8
8
|
|
9
9
|
test "escaping quotes" do
|
10
|
-
assert_equal '
|
10
|
+
assert_equal '"foo\"bar"', 'foo"bar'.shell_escape_double_quotes
|
11
|
+
end
|
12
|
+
|
13
|
+
test "escaping ticks" do
|
14
|
+
assert_equal '"foo\`bar"', 'foo`bar'.shell_escape_double_quotes
|
15
|
+
end
|
16
|
+
|
17
|
+
test "escaping dollar signs" do
|
18
|
+
assert_equal '"foo\$bar"', 'foo$bar'.shell_escape_double_quotes
|
11
19
|
end
|
12
20
|
end
|
data/test/mediainfo_test.rb
CHANGED
@@ -100,7 +100,7 @@ class MediainfoTest < ActiveSupport::TestCase
|
|
100
100
|
test "retains last system command generated" do
|
101
101
|
p = File.expand_path "./test/fixtures/dinner.3g2.xml"
|
102
102
|
m = Mediainfo.new p
|
103
|
-
assert_equal "mediainfo
|
103
|
+
assert_equal "mediainfo \"#{p}\" --Output=XML", m.last_command
|
104
104
|
end
|
105
105
|
|
106
106
|
test "allows customization of path to mediainfo binary" do
|
@@ -109,7 +109,7 @@ class MediainfoTest < ActiveSupport::TestCase
|
|
109
109
|
assert_equal "mediainfo", Mediainfo.path
|
110
110
|
|
111
111
|
m = Mediainfo.new "/dev/null"
|
112
|
-
assert_equal "mediainfo
|
112
|
+
assert_equal "mediainfo \"/dev/null\" --Output=XML", m.last_command
|
113
113
|
|
114
114
|
Mediainfo.any_instance.stubs(:mediainfo_version).returns("0.7.25")
|
115
115
|
|
@@ -117,7 +117,7 @@ class MediainfoTest < ActiveSupport::TestCase
|
|
117
117
|
assert_equal "/opt/local/bin/mediainfo", Mediainfo.path
|
118
118
|
|
119
119
|
m = Mediainfo.new "/dev/null"
|
120
|
-
assert_equal "/opt/local/bin/mediainfo
|
120
|
+
assert_equal "/opt/local/bin/mediainfo \"/dev/null\" --Output=XML", m.last_command
|
121
121
|
end
|
122
122
|
|
123
123
|
test "can be initialized with a raw response" do
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 7
|
8
|
-
-
|
9
|
-
version: 0.7.
|
8
|
+
- 1
|
9
|
+
version: 0.7.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Seth Thomas Rasmussen
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-06 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|