wmainfo-rb 0.5 → 0.6

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.
Files changed (3) hide show
  1. data/README +7 -4
  2. data/lib/wmainfo.rb +9 -13
  3. metadata +84 -32
data/README CHANGED
@@ -10,14 +10,19 @@ License: Ruby
10
10
  require 'wmainfo'
11
11
  foo = WmaInfo.new("someSong.wma")
12
12
  ... or ...
13
- foo = WmaInfo.new("someVideo.wmv", debug=1)
13
+ foo = WmaInfo.new("someVideo.wmv", :encoding=>"UTF-16LE")
14
+ (default encoding is ASCII)
15
+ ... or ...
16
+ foo = WmaInfo.new("someVideo.wmv", :debug=>1)
14
17
 
15
18
  == Public attributes ==
16
19
 
17
20
  @drm :: 'true' if DRM present else 'false'
18
21
  @tags :: dict of strings (id3 like data)
19
22
  @info :: dict of variable types (non-id3 like data)
23
+ @ext_info :: dict of variable types (non-id3 like data) from ASF_Extended_Content_Description_Object
20
24
  @headerObject :: dict of arrays (name, GUID, size and offset of ASF objects)
25
+ @stream :: dict of variable types (stream properties data)
21
26
 
22
27
  == Public methods ==
23
28
 
@@ -27,9 +32,7 @@ hastag?('str') :: returns True if @tags['str'] exists
27
32
  print_tags :: pretty-print @tags dict
28
33
  hasinfo?('str') :: returns True if @info['str'] exists
29
34
  print_info :: pretty-print @info dict
30
- parse_stream :: parse Asf_Stream_Property_Object
31
- ... which will create another public attribute:
32
- @stream :: dict of variable types (stream properties data)
35
+ print_stream :: pretty-print @stream dict
33
36
 
34
37
  For more/different documentation see http://badcomputer.org/unix/code/wmainfo/
35
38
 
data/lib/wmainfo.rb CHANGED
@@ -29,13 +29,14 @@ end
29
29
  class WmaInfo
30
30
  # WmaInfo.tags and WmaInfo.info are hashes of NAME=VALUE pairs
31
31
  # WmaInfo.header_object is a hash of arrays
32
- attr_reader :tags, :header_object, :info, :stream
32
+ attr_reader :tags, :header_object, :info, :ext_info, :stream
33
33
  def initialize(file, opts = {})
34
34
  @drm = nil
35
35
  @tags = {}
36
36
  @header_object = {}
37
37
  @info = {}
38
38
  @ext_info = {}
39
+ @stream = {}
39
40
  @file = file
40
41
  @debug = opts[:debug]
41
42
  @ic = Iconv.new(opts[:encoding] || "ASCII", "UTF-16LE")
@@ -76,16 +77,9 @@ class WmaInfo
76
77
  @info.each_pair { |key,val| puts "#{key}: #{val}" }
77
78
  end
78
79
 
79
- # I don't think most people will want/need this info
80
- # so it is not parsed automatically
81
- def parse_stream
82
- begin
83
- @stream = {}
84
- offset = @header_object['ASF_Stream_Properties_Object'][2]
85
- parse_asf_stream_properties_object(offset)
86
- rescue
87
- raise WmaInfoError, "Cannot grok ASF_Stream_Properties_Object", caller
88
- end
80
+ # prettyprint WmaInfo.stream hash
81
+ def print_stream
82
+ @stream.each_pair { |key,val| puts "#{key}: #{val}" }
89
83
  end
90
84
 
91
85
  # returns: "filename.wma :: Size: N bytes :: Bitrate: N kbps :: Duration: N seconds"
@@ -172,6 +166,9 @@ class WmaInfo
172
166
  elsif next_object_name == 'ASF_Extended_Content_Description_Object'
173
167
  parse_asf_extended_content_description_object
174
168
  next
169
+ elsif next_object_name == 'ASF_Stream_Properties_Object'
170
+ parse_asf_stream_properties_object
171
+ next
175
172
  elsif next_object_name == 'ASF_Content_Encryption_Object' || next_object_name == 'ASF_Extended_Content_Encryption_Object'
176
173
  parse_asf_content_encryption_object
177
174
  end
@@ -276,8 +273,7 @@ class WmaInfo
276
273
  end
277
274
  end
278
275
 
279
- def parse_asf_stream_properties_object(offset)
280
- @offset = offset - 6 # gained an extra 6 bytes somewhere?!
276
+ def parse_asf_stream_properties_object
281
277
 
282
278
  streamType = read_and_increment_offset(16)
283
279
  @stream['stream_type_guid'] = byte_string_to_guid(streamType)
metadata CHANGED
@@ -1,47 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.4
3
- specification_version: 1
4
2
  name: wmainfo-rb
5
3
  version: !ruby/object:Gem::Version
6
- version: "0.5"
7
- date: 2008-03-18 00:00:00 -06:00
8
- summary: Pure Ruby lib for accessing info/tags from wma/wmv files
9
- require_paths:
10
- - lib
11
- email: bulliver@badcomputer.org
12
- homepage: http://badcomputer.org/unix/code/wmainfo/
13
- rubyforge_project:
14
- description:
15
- autorequire: wmainfo
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: "0.6"
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - Darren Kirby
31
- files:
32
- - README
33
- - lib/wmainfo.rb
34
- test_files: []
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
35
11
 
36
- rdoc_options: []
12
+ date: 2009-06-07 00:00:00 -06:00
13
+ default_executable:
14
+ dependencies: []
37
15
 
38
- extra_rdoc_files:
39
- - README
16
+ description: |
17
+ :: wmainfo-rb ::
18
+ Author: Darren Kirby
19
+ mailto:bulliver@badcomputer.org
20
+ License: Ruby
21
+
22
+ = Quick API docs =
23
+
24
+ == Initializing ==
25
+
26
+ require 'wmainfo'
27
+ foo = WmaInfo.new("someSong.wma")
28
+ ... or ...
29
+ foo = WmaInfo.new("someVideo.wmv", :encoding=>"UTF-16LE")
30
+ (default encoding is ASCII)
31
+ ... or ...
32
+ foo = WmaInfo.new("someVideo.wmv", :debug=>1)
33
+
34
+ == Public attributes ==
35
+
36
+ @drm :: 'true' if DRM present else 'false'
37
+ @tags :: dict of strings (id3 like data)
38
+ @info :: dict of variable types (non-id3 like data)
39
+ @ext_info :: dict of variable types (non-id3 like data) from ASF_Extended_Content_Description_Object
40
+ @headerObject :: dict of arrays (name, GUID, size and offset of ASF objects)
41
+ @stream :: dict of variable types (stream properties data)
42
+
43
+ == Public methods ==
44
+
45
+ print_objects :: pretty-print header objects
46
+ hasdrm? :: returns True if file has DRM
47
+ hastag?('str') :: returns True if @tags['str'] exists
48
+ print_tags :: pretty-print @tags dict
49
+ hasinfo?('str') :: returns True if @info['str'] exists
50
+ print_info :: pretty-print @info dict
51
+ print_stream :: pretty-print @stream dict
52
+
53
+ For more/different documentation see http://badcomputer.org/unix/code/wmainfo/
54
+
55
+ == Thanks/Contributors ==
56
+
57
+ Ilmari Heikkinen sent in a fix for uninitialized '@ext_info'.
58
+ Guillaume Pierronnet sent in a patch which improves character encoding handling.
59
+
60
+ email: bulliver@badcomputer.org
40
61
  executables: []
41
62
 
42
63
  extensions: []
43
64
 
65
+ extra_rdoc_files:
66
+ - README
67
+ files:
68
+ - README
69
+ - lib/wmainfo.rb
70
+ has_rdoc: true
71
+ homepage: http://badcomputer.org/unix/code/wmainfo/
72
+ licenses: []
73
+
74
+ post_install_message:
75
+ rdoc_options: []
76
+
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: "0"
84
+ version:
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: "0"
90
+ version:
44
91
  requirements: []
45
92
 
46
- dependencies: []
93
+ rubyforge_project: wmainfo-rb
94
+ rubygems_version: 1.3.3
95
+ signing_key:
96
+ specification_version: 3
97
+ summary: Pure Ruby lib for accessing info/tags from wma/wmv files
98
+ test_files: []
47
99