ruby-audioinfo 0.1.4 → 0.1.5

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/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ === 0.1.5 / 2009-03-29
2
+
3
+ * flac parsing more robust
4
+ * musicbrainz_infos support for flac
5
+ * quick fixes in mpcinfo for id3v2 tag parsing
6
+
1
7
  === 0.1.4 / 2008-07-04
2
8
 
3
9
  * charset correctly set when commiting MP3 tags too
@@ -150,7 +150,16 @@ class MpcInfo
150
150
  elsif mpc_header == "ID3"
151
151
  @id3v2_tag = ID3v2.new
152
152
  @id3v2_tag.from_io(@file)
153
- parse_infos
153
+ @file.seek(@id3v2_tag.io_position)
154
+ # very dirty hack to allow parsing of mpc infos after id3v2 tag
155
+ while @file.read(1) != "M"; end
156
+ if @file.read(2) == "P+"
157
+ @file.seek(-3, IO::SEEK_CUR)
158
+ # we need to reparse the tag, since we have the beggining of the mpc file
159
+ parse_infos
160
+ else
161
+ raise(MpcInfoError, "cannot find MPC header after id3 tag")
162
+ end
154
163
  else
155
164
  raise(MpcInfoError, "cannot find MPC header")
156
165
  end
data/lib/audioinfo.rb CHANGED
@@ -30,7 +30,7 @@ class AudioInfo
30
30
 
31
31
  SUPPORTED_EXTENSIONS = %w{mp3 ogg mpc wma mp4 aac m4a flac}
32
32
 
33
- VERSION = "0.1.4"
33
+ VERSION = "0.1.5"
34
34
 
35
35
  attr_reader :path, :extension, :musicbrainz_infos, :tracknum, :bitrate, :vbr
36
36
  attr_reader :artist, :album, :title, :length, :date
@@ -52,9 +52,9 @@ class AudioInfo
52
52
  end
53
53
 
54
54
  # open the file with path +fn+ and convert all tags from/to specified +encoding+
55
- def initialize(fn, encoding = 'utf-8')
56
- raise(AudioInfoError, "path is nil") if fn.nil?
57
- @path = fn
55
+ def initialize(filename, encoding = 'utf-8')
56
+ raise(AudioInfoError, "path is nil") if filename.nil?
57
+ @path = filename
58
58
  ext = File.extname(@path)
59
59
  raise(AudioInfoError, "cannot find extension") if ext.empty?
60
60
  @extension = ext[1..-1].downcase
@@ -64,15 +64,16 @@ class AudioInfo
64
64
  begin
65
65
  case @extension
66
66
  when 'mp3'
67
- @info = Mp3Info.new(fn, :encoding => @encoding)
67
+ @info = Mp3Info.new(filename, :encoding => @encoding)
68
68
  default_tag_fill
69
- #"TXXX"=>
70
- #["MusicBrainz TRM Id\000",
71
- #"MusicBrainz Artist Id\000aba64937-3334-4c65-90a1-4e6b9d4d7ada",
72
- #"MusicBrainz Album Id\000e1a223c1-cbc2-427f-a192-5d22fefd7c4c",
73
- #"MusicBrainz Album Type\000album",
74
- #"MusicBrainz Album Status\000official",
75
- #"MusicBrainz Album Artist Id\000"]
69
+ #"TXXX"=>
70
+ #["MusicBrainz TRM Id\000",
71
+ #"MusicBrainz Artist Id\000aba64937-3334-4c65-90a1-4e6b9d4d7ada",
72
+ #"MusicBrainz Album Id\000e1a223c1-cbc2-427f-a192-5d22fefd7c4c",
73
+ #"MusicBrainz Album Type\000album",
74
+ #"MusicBrainz Album Status\000official",
75
+ #"MusicBrainz Album Artist Id\000"]
76
+
76
77
  if (arr = @info.tag2["TXXX"]).is_a?(Array)
77
78
  fields = MUSICBRAINZ_FIELDS.invert
78
79
  arr.each do |val|
@@ -91,7 +92,7 @@ class AudioInfo
91
92
  @info.close
92
93
 
93
94
  when 'ogg'
94
- @info = OggInfo.new(fn, @encoding)
95
+ @info = OggInfo.new(filename, @encoding)
95
96
  default_fill_musicbrainz_fields
96
97
  default_tag_fill
97
98
  @bitrate = @info.bitrate/1000
@@ -102,17 +103,17 @@ class AudioInfo
102
103
  @info.close
103
104
 
104
105
  when 'mpc'
105
- fill_ape_tag(fn)
106
-
107
- mpc_info = MpcInfo.new(fn)
106
+ fill_ape_tag(filename)
107
+
108
+ mpc_info = MpcInfo.new(filename)
108
109
  @bitrate = mpc_info.infos['bitrate']/1000
109
110
  @length = mpc_info.infos['length']
110
111
 
111
112
  when 'ape'
112
- fill_ape_tag(fn)
113
+ fill_ape_tag(filename)
113
114
 
114
115
  when 'wma'
115
- @info = WmaInfo.new(fn, :encoding => @encoding)
116
+ @info = WmaInfo.new(filename, :encoding => @encoding)
116
117
  @artist = @info.tags["Author"]
117
118
  @album = @info.tags["AlbumTitle"]
118
119
  @title = @info.tags["Title"]
@@ -127,7 +128,7 @@ class AudioInfo
127
128
  end
128
129
 
129
130
  when 'aac', 'mp4', 'm4a'
130
- @info = MP4Info.open(fn)
131
+ @info = MP4Info.open(filename)
131
132
  @artist = @info.ART
132
133
  @album = @info.ALB
133
134
  @title = @info.NAM
@@ -137,22 +138,27 @@ class AudioInfo
137
138
  @length = @info.SECS
138
139
  mapping = MUSICBRAINZ_FIELDS.invert
139
140
 
140
- `faad -i #{fn.shell_escape} 2>&1 `.grep(/^MusicBrainz (.+)$/) do
141
+ `faad -i #{filename.shell_escape} 2>&1 `.grep(/^MusicBrainz (.+)$/) do
141
142
  name, value = $1.split(/: /, 2)
142
143
  key = mapping[name]
143
144
  @musicbrainz_infos[key] = value
144
145
  end
145
146
 
146
147
  when 'flac'
147
- @info = FlacInfo.new(fn)
148
+ @info = FlacInfo.new(filename)
148
149
  tags = convert_tags_encoding(@info.tags, "UTF-8")
149
- @artist = tags["ARTIST"]
150
- @album = tags["ALBUM"]
151
- @title = tags["TITLE"]
152
- @tracknum = tags["TRACKNUMBER"].to_i
153
- @date = tags["DATE"]
150
+ @artist = tags["ARTIST"] || tags["artist"]
151
+ @album = tags["ALBUM"] || tags["album"]
152
+ @title = tags["TITLE"] || tags["title"]
153
+ @tracknum = (tags["TRACKNUMBER"]||tags["tracknumber"]).to_i
154
+ @date = tags["DATE"]||tags["date"]
154
155
  @length = @info.streaminfo["total_samples"] / @info.streaminfo["samplerate"].to_f
155
- @bitrate = File.size(fn).to_f*8/@length/1024
156
+ @bitrate = File.size(filename).to_f*8/@length/1024
157
+ tags.each do |tagname, tagvalue|
158
+ next unless tagname =~ /^musicbrainz_(.+)$/
159
+ @musicbrainz_infos[$1] = tags[tagname]
160
+ end
161
+ @musicbrainz_infos["trmid"] = tags["musicip_puid"]
156
162
  #default_fill_musicbrainz_fields
157
163
 
158
164
  else
@@ -241,7 +247,7 @@ class AudioInfo
241
247
  "album" => @album,
242
248
  "title" => @title,
243
249
  "tracknumber" => @tracknum}.each do |k,v|
244
- ogg.tag[k] = v
250
+ ogg.tag[k] = v.to_s
245
251
  end
246
252
  end
247
253
 
@@ -294,9 +300,9 @@ class AudioInfo
294
300
  end
295
301
  end
296
302
 
297
- def fill_ape_tag(fn)
303
+ def fill_ape_tag(filename)
298
304
  begin
299
- @info = ApeTag.new(fn)
305
+ @info = ApeTag.new(filename)
300
306
  tags = convert_tags_encoding(@info.tag, "UTF-8")
301
307
  default_tag_fill(tags)
302
308
  default_fill_musicbrainz_fields
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-audioinfo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guillaume Pierronnet
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-07-04 00:00:00 +02:00
12
+ date: 2009-03-28 23:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -64,13 +64,13 @@ dependencies:
64
64
  version:
65
65
  - !ruby/object:Gem::Dependency
66
66
  name: hoe
67
- type: :runtime
67
+ type: :development
68
68
  version_requirement:
69
69
  version_requirements: !ruby/object:Gem::Requirement
70
70
  requirements:
71
71
  - - ">="
72
72
  - !ruby/object:Gem::Version
73
- version: 1.6.0
73
+ version: 1.9.0
74
74
  version:
75
75
  description: "ruby-audioinfo glue together various audio ruby libraries and presents a unified API to the developper. Currently, supported formats are: mp3, ogg, mpc, ape, wma, flac, aac, mp4, m4a."
76
76
  email: moumar@rubyforge.org
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  requirements: []
117
117
 
118
118
  rubyforge_project: ruby-audioinfo
119
- rubygems_version: 1.2.0
119
+ rubygems_version: 1.3.1
120
120
  signing_key:
121
121
  specification_version: 2
122
122
  summary: "ruby-audioinfo glue together various audio ruby libraries and presents a single API to the developper. Currently, supported formats are: mp3, ogg, mpc, ape, wma, flac, aac, mp4, m4a."