mediainfo-ruby 0.1.6 → 0.1.9
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.
- data.tar.gz.sig +0 -0
- data/Rakefile +1 -1
- data/lib/mediainfo-ruby.rb +46 -19
- data/mediainfo-ruby.gemspec +2 -2
- data/spec/mediainfo_spec.rb +25 -15
- metadata +4 -4
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new("mediainfo-ruby", "0.1.
|
5
|
+
Echoe.new("mediainfo-ruby", "0.1.9") do |p|
|
6
6
|
p.description = "MediaInfo Ruby Bridge. Call MediaInfo lib directly"
|
7
7
|
p.url = "http://github.com/hackerdude/mediainfo-ruby"
|
8
8
|
p.author = "David Martinez"
|
data/lib/mediainfo-ruby.rb
CHANGED
@@ -5,6 +5,15 @@ puts "Loading mediainfo"
|
|
5
5
|
require "mediainfo_ruby"
|
6
6
|
|
7
7
|
module MediaInfoRubyisms_Streams
|
8
|
+
ThingsWithMultipleStreams = [:video, :audio]
|
9
|
+
|
10
|
+
# Set to true if you want empty values
|
11
|
+
attr_reader :empty_values
|
12
|
+
|
13
|
+
attr_reader :include_deprecated
|
14
|
+
|
15
|
+
attr_reader :include_inform
|
16
|
+
|
8
17
|
# A symbol map to translate from the Rubyisms we use on mediainfo-ruby
|
9
18
|
# to the constants libmediainfo uses.
|
10
19
|
StreamKindSymbolsMap = {
|
@@ -47,12 +56,13 @@ module MediaInfoRubyisms_Streams
|
|
47
56
|
# value is the help for that option.
|
48
57
|
# By default, anything marked as deprecated in the underlying
|
49
58
|
# library is removed.
|
50
|
-
def option_definitions
|
51
|
-
option_map = {}
|
59
|
+
def option_definitions
|
60
|
+
option_map = {:general=>{}}
|
52
61
|
current = :general
|
53
62
|
switching = true
|
54
63
|
current_map = option_map[:general]
|
55
|
-
|
64
|
+
|
65
|
+
option_defs = parameters_csv.each_line{|row|
|
56
66
|
if row.strip == ""
|
57
67
|
switching = true
|
58
68
|
else
|
@@ -67,40 +77,57 @@ module MediaInfoRubyisms_Streams
|
|
67
77
|
else
|
68
78
|
key = kv[0]
|
69
79
|
value = kv[1].nil? ? nil : kv[1].chomp
|
70
|
-
current_map[key] = value unless
|
80
|
+
current_map[key] = value unless ! (self.include_deprecated ) && kv[1].nil? ? false : kv[1].include?("Deprecated")
|
71
81
|
end
|
72
82
|
end
|
73
83
|
}
|
74
84
|
option_map
|
75
85
|
end
|
76
86
|
|
87
|
+
def parameters_csv
|
88
|
+
params_csv = self.option("Info_Parameters_CSV", "")
|
89
|
+
if RUBY_PLATFORM =~ /darwin/
|
90
|
+
params_csv = params_csv.gsub("\r", "\n")
|
91
|
+
end
|
92
|
+
params_csv
|
93
|
+
end
|
94
|
+
|
77
95
|
# It introspects a video. This means returning a map of all the
|
78
96
|
# values for a definition. By default empty values are not returned.
|
79
97
|
# Send with true to return empty values
|
80
|
-
def introspect
|
98
|
+
def introspect
|
81
99
|
results = {}
|
82
100
|
self.option_definitions.each{|topic, topic_parameters|
|
83
101
|
kind_constant = StreamKindSymbolsMap[topic]
|
84
102
|
if ! kind_constant.nil?
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
if empty_values == true || value.length > 0
|
92
|
-
results[topic][key] = value
|
93
|
-
end
|
94
|
-
if key == "Inform"
|
95
|
-
results[topic].delete(key) if ! include_inform
|
96
|
-
end
|
97
|
-
# self.get(kind_constant, 1,0, key) # Something like this
|
98
|
-
}
|
103
|
+
if ThingsWithMultipleStreams.include?(topic)
|
104
|
+
streams = self.send("#{topic.to_s}_streams".to_sym)
|
105
|
+
results[topic] = 0.upto(streams-1).collect{|ix| introspect_topic(kind_constant, topic_parameters, ix) }
|
106
|
+
else
|
107
|
+
results[topic] = introspect_topic(kind_constant, topic_parameters)
|
108
|
+
end
|
99
109
|
end
|
100
110
|
}
|
101
111
|
results
|
102
112
|
end
|
103
113
|
|
114
|
+
private
|
115
|
+
def introspect_topic(kind_constant, topic_parameters, stream_index=0)
|
116
|
+
result = {}
|
117
|
+
topic_parameters.each{|key, value|
|
118
|
+
value = self.get_value(kind_constant, stream_index, key, MediaInfoLib_InfoKind::Text, MediaInfoLib_InfoKind::Name)
|
119
|
+
|
120
|
+
if self.empty_values == true || value.length > 0
|
121
|
+
result[key] = value
|
122
|
+
end
|
123
|
+
if key == "Inform"
|
124
|
+
result.delete(key) if ! self.include_inform
|
125
|
+
end
|
126
|
+
# self.get(kind_constant, 1,0, key) # Something like this
|
127
|
+
}
|
128
|
+
result
|
129
|
+
end
|
130
|
+
|
104
131
|
end
|
105
132
|
|
106
133
|
class MediaInfoLib::MediaInfo
|
data/mediainfo-ruby.gemspec
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{mediainfo-ruby}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.9"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["David Martinez"]
|
9
9
|
s.cert_chain = ["/Users/david/.ssh/gem-public_cert.pem"]
|
10
|
-
s.date = %q{2010-07-
|
10
|
+
s.date = %q{2010-07-19}
|
11
11
|
s.description = %q{MediaInfo Ruby Bridge. Call MediaInfo lib directly}
|
12
12
|
s.email = %q{}
|
13
13
|
s.extensions = ["ext/mediainfo_ruby/extconf.rb"]
|
data/spec/mediainfo_spec.rb
CHANGED
@@ -10,49 +10,59 @@ describe MediaInfoLib::MediaInfo do
|
|
10
10
|
puts "Please put some video files on spec/fixtures to test"
|
11
11
|
end
|
12
12
|
end
|
13
|
+
it "Can get the option definitions for a file" do
|
14
|
+
@mediainfo = MediaInfoLib::MediaInfo.new
|
15
|
+
definitions = @mediainfo.option_definitions
|
16
|
+
[:general, :audio, :video, :text, :chapters, :menu, :text, :image].each{|topic|
|
17
|
+
# All these topics should be there
|
18
|
+
definitions.keys.should include(topic)
|
19
|
+
# All these topics should have more than one item
|
20
|
+
definitions[topic].keys.length.should > 0
|
21
|
+
}
|
22
|
+
#pp definitions
|
23
|
+
end
|
13
24
|
context "When getting video files" do
|
14
25
|
before(:each) do
|
15
|
-
@mediainfo = MediaInfoLib::MediaInfo.new
|
16
26
|
end
|
17
27
|
after(:each) do
|
18
|
-
@mediainfo.close
|
19
28
|
end
|
20
29
|
it "Can open local files" do
|
21
30
|
@video_files.each{|video|
|
31
|
+
@mediainfo = MediaInfoLib::MediaInfo.new
|
22
32
|
@mediainfo.open("#{VIDEO_FIXTURES}/#{video}").should > 0
|
23
33
|
@mediainfo.inform.length.should > 0
|
34
|
+
@mediainfo.close
|
24
35
|
}
|
25
36
|
end
|
26
37
|
it "Can get info from files" do
|
27
38
|
@video_files.each{|video|
|
39
|
+
@mediainfo = MediaInfoLib::MediaInfo.new
|
28
40
|
@mediainfo.open("#{VIDEO_FIXTURES}/#{video}").should > 0
|
29
41
|
@mediainfo.streams.should > 0
|
30
42
|
@mediainfo.streams.should < 1000
|
31
43
|
#@mediainfo.get(MediaInfoLib_StreamKind::General,1,0,MediaInfoLib_InfoKind::Name).should_not be_nil
|
32
44
|
}
|
33
45
|
end
|
34
|
-
it "Can get the option definitions for a file" do
|
35
|
-
definitions = @mediainfo.option_definitions
|
36
|
-
[:general, :audio, :video, :text, :chapters, :menu, :text, :image].each{|topic|
|
37
|
-
# All these topics should be there
|
38
|
-
definitions.keys.should include(topic)
|
39
|
-
# All these topics should have more than one item
|
40
|
-
definitions[topic].keys.length.should > 0
|
41
|
-
}
|
42
|
-
#pp definitions
|
43
|
-
end
|
44
46
|
it "Can get the Media Info values for a file" do
|
45
47
|
@video_files.each{|video|
|
48
|
+
@mediainfo = MediaInfoLib::MediaInfo.new
|
49
|
+
puts "Reading #{video}"
|
46
50
|
@mediainfo.open("#{VIDEO_FIXTURES}/#{video}").should > 0
|
47
51
|
values = @mediainfo.introspect
|
48
52
|
#puts "Streams for #{video}: Video:#{@mediainfo.video_streams} Audio:#{@mediainfo.audio_streams} Image:#{@mediainfo.image_streams}"
|
49
53
|
if @mediainfo.video_streams > 0
|
50
54
|
[:general, :audio, :video, :text, :chapters, :menu, :text, :image].each{|topic| values.should include(topic)}
|
51
|
-
# TODO Spot check some topics.
|
52
55
|
values[:general].keys.length.should > 0
|
53
|
-
values[:
|
54
|
-
values[:
|
56
|
+
values[:video][0]["Format"].should_not be_nil
|
57
|
+
values[:video][0]["Format"].should_not include("TODO")
|
58
|
+
if @mediainfo.audio_streams > 0
|
59
|
+
values[:audio][0]["Format"].should_not be_nil
|
60
|
+
values[:audio][0]["Format"].should_not include("TODO")
|
61
|
+
end
|
62
|
+
values[:audio].length.should == @mediainfo.audio_streams
|
63
|
+
values[:video].length.should == @mediainfo.video_streams
|
55
64
|
#pp values
|
65
|
+
@mediainfo.close
|
56
66
|
end
|
57
67
|
}
|
58
68
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mediainfo-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 9
|
10
|
+
version: 0.1.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- David Martinez
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
36
36
|
Kf0A+tvk/7CpmA==
|
37
37
|
-----END CERTIFICATE-----
|
38
38
|
|
39
|
-
date: 2010-07-
|
39
|
+
date: 2010-07-19 00:00:00 -07:00
|
40
40
|
default_executable:
|
41
41
|
dependencies:
|
42
42
|
- !ruby/object:Gem::Dependency
|
metadata.gz.sig
CHANGED
Binary file
|