ruby-audioinfo 0.1.5 → 0.1.7
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 +5 -0
- data/Rakefile +44 -21
- data/lib/audioinfo.rb +52 -20
- data/lib/audioinfo/mpcinfo.rb +3 -1
- metadata +89 -45
- data/Manifest.txt +0 -10
- data/lib/shell_escape.rb +0 -6
data/History.txt
CHANGED
data/Rakefile
CHANGED
@@ -1,25 +1,48 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
2
|
+
require "rake/rdoctask"
|
3
|
+
|
4
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'lib', 'audioinfo')
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'jeweler'
|
8
|
+
|
9
|
+
#Jeweler::GemcutterTasks.new
|
10
|
+
|
11
|
+
Jeweler::Tasks.new do |gemspec|
|
12
|
+
gemspec.name = 'ruby-audioinfo'
|
13
|
+
gemspec.version = AudioInfo::VERSION
|
14
|
+
gemspec.authors = ['Guillaume Pierronnet', 'Marcello Barnaba']
|
15
|
+
gemspec.email = 'moumar@rubyforge.org'
|
16
|
+
gemspec.date = '2010-03-20'
|
17
|
+
|
18
|
+
gemspec.homepage = 'http://ruby-audioinfo.rubyforge.org'
|
19
|
+
gemspec.summary = 'Unified audio info access library'
|
20
|
+
gemspec.description = 'ruby-audioinfo glues together various audio libraries and presents a single API to the developer.'
|
21
|
+
'Currently, supported formats are: mp3, ogg, mpc, ape, wma, flac, aac, mp4, m4a.'
|
22
|
+
|
23
|
+
gemspec.files = %w( README.txt Rakefile History.txt) + Dir['{lib,test}/**/*']
|
24
|
+
gemspec.extra_rdoc_files = %w( README.txt )
|
25
|
+
gemspec.has_rdoc = true
|
26
|
+
gemspec.require_path = 'lib'
|
27
|
+
|
28
|
+
gemspec.add_dependency 'ruby-mp3info', '>= 0.6.3'
|
29
|
+
gemspec.add_dependency 'ruby-ogginfo', '>= 0.3.1'
|
30
|
+
gemspec.add_dependency 'mp4info', '>= 1.7.3'
|
31
|
+
gemspec.add_dependency 'wmainfo-rb', '>= 0.5'
|
32
|
+
gemspec.add_dependency 'flacinfo-rb', '>= 0.4'
|
33
|
+
gemspec.add_dependency 'apetag', '= 1.1.2'
|
34
|
+
end
|
35
|
+
Jeweler::GemcutterTasks.new
|
36
|
+
|
37
|
+
Jeweler::RubyforgeTasks.new
|
38
|
+
|
39
|
+
rescue LoadError
|
40
|
+
puts 'Jeweler not available. Install it with: gem install jeweler'
|
20
41
|
end
|
21
42
|
|
22
|
-
|
23
|
-
|
24
|
-
|
43
|
+
Rake::RDocTask.new do |rd|
|
44
|
+
rd.main = "README.txt"
|
45
|
+
rd.rdoc_dir = "rdoc"
|
46
|
+
rd.rdoc_files.include("README.txt", "History.txt", "lib/**/*.rb")
|
47
|
+
rd.title = "ruby-audioinfo #{AudioInfo::VERSION}"
|
25
48
|
end
|
data/lib/audioinfo.rb
CHANGED
@@ -1,18 +1,16 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
1
|
require "iconv"
|
4
2
|
require "stringio"
|
5
3
|
|
6
|
-
$: << File.dirname(__FILE__)+"/audioinfo"
|
7
|
-
|
8
4
|
require "mp3info"
|
9
5
|
require "ogginfo"
|
10
|
-
require "mpcinfo"
|
11
|
-
require "apetag"
|
12
6
|
require "wmainfo"
|
13
7
|
require "mp4info"
|
14
8
|
require "flacinfo"
|
15
|
-
require "
|
9
|
+
require "apetag"
|
10
|
+
|
11
|
+
$: << File.expand_path(File.dirname(__FILE__))
|
12
|
+
|
13
|
+
require "audioinfo/mpcinfo"
|
16
14
|
|
17
15
|
class AudioInfoError < Exception ; end
|
18
16
|
|
@@ -30,7 +28,7 @@ class AudioInfo
|
|
30
28
|
|
31
29
|
SUPPORTED_EXTENSIONS = %w{mp3 ogg mpc wma mp4 aac m4a flac}
|
32
30
|
|
33
|
-
VERSION = "0.1.
|
31
|
+
VERSION = "0.1.7"
|
34
32
|
|
35
33
|
attr_reader :path, :extension, :musicbrainz_infos, :tracknum, :bitrate, :vbr
|
36
34
|
attr_reader :artist, :album, :title, :length, :date
|
@@ -138,7 +136,7 @@ class AudioInfo
|
|
138
136
|
@length = @info.SECS
|
139
137
|
mapping = MUSICBRAINZ_FIELDS.invert
|
140
138
|
|
141
|
-
|
139
|
+
faad_info(filename).match(/^MusicBrainz (.+)$/) do
|
142
140
|
name, value = $1.split(/: /, 2)
|
143
141
|
key = mapping[name]
|
144
142
|
@musicbrainz_infos[key] = value
|
@@ -251,6 +249,14 @@ class AudioInfo
|
|
251
249
|
end
|
252
250
|
end
|
253
251
|
|
252
|
+
when ApeTag
|
253
|
+
ape = ApeTag.new(@path)
|
254
|
+
ape.update do |fields|
|
255
|
+
fields["Artist"] = @artist
|
256
|
+
fields["Album"] = @album
|
257
|
+
fields["Title"] = @title
|
258
|
+
fields["Track"] = @tracknum.to_s
|
259
|
+
end
|
254
260
|
else
|
255
261
|
raise(AudioInfoError, "implement me")
|
256
262
|
end
|
@@ -287,31 +293,32 @@ class AudioInfo
|
|
287
293
|
s.gsub("\000", "")
|
288
294
|
end
|
289
295
|
|
290
|
-
def default_fill_musicbrainz_fields
|
296
|
+
def default_fill_musicbrainz_fields(tags = @info.tag)
|
291
297
|
MUSICBRAINZ_FIELDS.keys.each do |field|
|
292
|
-
val =
|
298
|
+
val = tags["musicbrainz_#{field}"]
|
293
299
|
@musicbrainz_infos[field] = val if val
|
294
300
|
end
|
295
301
|
end
|
296
302
|
|
297
|
-
def default_tag_fill(
|
303
|
+
def default_tag_fill(tags = @info.tag)
|
298
304
|
%w{artist album title}.each do |v|
|
299
|
-
instance_variable_set( "@#{v}".to_sym, sanitize(
|
305
|
+
instance_variable_set( "@#{v}".to_sym, sanitize(tags[v].to_s) )
|
300
306
|
end
|
301
307
|
end
|
302
308
|
|
303
309
|
def fill_ape_tag(filename)
|
304
310
|
begin
|
305
311
|
@info = ApeTag.new(filename)
|
306
|
-
tags = convert_tags_encoding(@info.
|
312
|
+
#tags = convert_tags_encoding(@info.fields, "UTF-8")
|
313
|
+
tags = @info.fields.inject({}) do |hash, (k, v)|
|
314
|
+
hash[k.downcase] = v ? v.first : nil
|
315
|
+
hash
|
316
|
+
end
|
317
|
+
default_fill_musicbrainz_fields(tags)
|
307
318
|
default_tag_fill(tags)
|
308
|
-
default_fill_musicbrainz_fields
|
309
|
-
@date = @info.tag["year"]
|
310
|
-
@tracknum = 0
|
311
319
|
|
312
|
-
|
313
|
-
|
314
|
-
end
|
320
|
+
@date = tags["year"]
|
321
|
+
@tracknum = tags['track'].to_i
|
315
322
|
rescue ApeTagError
|
316
323
|
end
|
317
324
|
end
|
@@ -328,4 +335,29 @@ class AudioInfo
|
|
328
335
|
end
|
329
336
|
tags
|
330
337
|
end
|
338
|
+
|
339
|
+
def faad_info(file)
|
340
|
+
stdout, stdout_w = IO.pipe
|
341
|
+
stderr, stderr_w = IO.pipe
|
342
|
+
|
343
|
+
fork do
|
344
|
+
stdout.close
|
345
|
+
stderr.close
|
346
|
+
STDOUT.reopen(stdout_w)
|
347
|
+
STDERR.reopen(stderr_w)
|
348
|
+
exec 'faad', '-i', file
|
349
|
+
end
|
350
|
+
|
351
|
+
stdout_w.close
|
352
|
+
stderr_w.close
|
353
|
+
pid, status = Process.wait2
|
354
|
+
|
355
|
+
out = stdout.read.chomp
|
356
|
+
stdout.close
|
357
|
+
err = stderr.read.chomp
|
358
|
+
stderr.close
|
359
|
+
|
360
|
+
# Return the stderr because faad prints info on that fd...
|
361
|
+
status.exitstatus.zero? ? err : ''
|
362
|
+
end
|
331
363
|
end
|
data/lib/audioinfo/mpcinfo.rb
CHANGED
@@ -28,6 +28,8 @@ class MpcInfo
|
|
28
28
|
|
29
29
|
FREQUENCIES = [ 44100, 48000, 37800, 32000 ]
|
30
30
|
|
31
|
+
SV4_6_HEADER = Regexp.new('^[\x00\x01\x10\x11\x40\x41\x50\x51\x80\x81\x90\x91\xC0\xC1\xD0\xD1][\x20-37][\x00\x20\x40\x60\x80\xA0\xC0\xE0]/', nil, 'n')
|
32
|
+
|
31
33
|
attr_reader :infos
|
32
34
|
attr_reader :id3v2_tag
|
33
35
|
|
@@ -144,7 +146,7 @@ class MpcInfo
|
|
144
146
|
#$ThisFileInfo['audio']['encoder'] = @infos['encoder_version'];
|
145
147
|
#$ThisFileInfo['audio']['encoder_options'] = @infos['profile'];
|
146
148
|
=end
|
147
|
-
elsif mpc_header =~
|
149
|
+
elsif mpc_header =~ SV4_6_HEADER
|
148
150
|
# this is SV4 - SV6, handle seperately
|
149
151
|
header_size = 8
|
150
152
|
elsif mpc_header == "ID3"
|
metadata
CHANGED
@@ -1,124 +1,168 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-audioinfo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 21
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 7
|
10
|
+
version: 0.1.7
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Guillaume Pierronnet
|
14
|
+
- Marcello Barnaba
|
8
15
|
autorequire:
|
9
16
|
bindir: bin
|
10
17
|
cert_chain: []
|
11
18
|
|
12
|
-
date:
|
19
|
+
date: 2010-06-18 00:00:00 +02:00
|
13
20
|
default_executable:
|
14
21
|
dependencies:
|
15
22
|
- !ruby/object:Gem::Dependency
|
16
23
|
name: ruby-mp3info
|
17
|
-
|
18
|
-
|
19
|
-
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
20
27
|
requirements:
|
21
28
|
- - ">="
|
22
29
|
- !ruby/object:Gem::Version
|
30
|
+
hash: 1
|
31
|
+
segments:
|
32
|
+
- 0
|
33
|
+
- 6
|
34
|
+
- 3
|
23
35
|
version: 0.6.3
|
24
|
-
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id001
|
25
38
|
- !ruby/object:Gem::Dependency
|
26
39
|
name: ruby-ogginfo
|
27
|
-
|
28
|
-
|
29
|
-
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
30
43
|
requirements:
|
31
44
|
- - ">="
|
32
45
|
- !ruby/object:Gem::Version
|
46
|
+
hash: 17
|
47
|
+
segments:
|
48
|
+
- 0
|
49
|
+
- 3
|
50
|
+
- 1
|
33
51
|
version: 0.3.1
|
34
|
-
version:
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: MP4Info
|
37
52
|
type: :runtime
|
38
|
-
|
39
|
-
|
53
|
+
version_requirements: *id002
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: mp4info
|
56
|
+
prerelease: false
|
57
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
40
59
|
requirements:
|
41
60
|
- - ">="
|
42
61
|
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
|
62
|
+
hash: 13
|
63
|
+
segments:
|
64
|
+
- 1
|
65
|
+
- 7
|
66
|
+
- 3
|
67
|
+
version: 1.7.3
|
68
|
+
type: :runtime
|
69
|
+
version_requirements: *id003
|
45
70
|
- !ruby/object:Gem::Dependency
|
46
71
|
name: wmainfo-rb
|
47
|
-
|
48
|
-
|
49
|
-
|
72
|
+
prerelease: false
|
73
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
50
75
|
requirements:
|
51
76
|
- - ">="
|
52
77
|
- !ruby/object:Gem::Version
|
78
|
+
hash: 1
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
- 5
|
53
82
|
version: "0.5"
|
54
|
-
|
83
|
+
type: :runtime
|
84
|
+
version_requirements: *id004
|
55
85
|
- !ruby/object:Gem::Dependency
|
56
86
|
name: flacinfo-rb
|
57
|
-
|
58
|
-
|
59
|
-
|
87
|
+
prerelease: false
|
88
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
60
90
|
requirements:
|
61
91
|
- - ">="
|
62
92
|
- !ruby/object:Gem::Version
|
63
|
-
|
64
|
-
|
93
|
+
hash: 3
|
94
|
+
segments:
|
95
|
+
- 0
|
96
|
+
- 4
|
97
|
+
version: "0.4"
|
98
|
+
type: :runtime
|
99
|
+
version_requirements: *id005
|
65
100
|
- !ruby/object:Gem::Dependency
|
66
|
-
name:
|
67
|
-
|
68
|
-
|
69
|
-
|
101
|
+
name: apetag
|
102
|
+
prerelease: false
|
103
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
104
|
+
none: false
|
70
105
|
requirements:
|
71
|
-
- - "
|
106
|
+
- - "="
|
72
107
|
- !ruby/object:Gem::Version
|
73
|
-
|
74
|
-
|
75
|
-
|
108
|
+
hash: 23
|
109
|
+
segments:
|
110
|
+
- 1
|
111
|
+
- 1
|
112
|
+
- 2
|
113
|
+
version: 1.1.2
|
114
|
+
type: :runtime
|
115
|
+
version_requirements: *id006
|
116
|
+
description: ruby-audioinfo glues together various audio libraries and presents a single API to the developer.
|
76
117
|
email: moumar@rubyforge.org
|
77
118
|
executables: []
|
78
119
|
|
79
120
|
extensions: []
|
80
121
|
|
81
122
|
extra_rdoc_files:
|
82
|
-
- History.txt
|
83
|
-
- Manifest.txt
|
84
123
|
- README.txt
|
85
124
|
files:
|
86
125
|
- History.txt
|
87
|
-
- Manifest.txt
|
88
126
|
- README.txt
|
89
127
|
- Rakefile
|
90
128
|
- lib/audioinfo.rb
|
91
129
|
- lib/audioinfo/album.rb
|
92
130
|
- lib/audioinfo/apetag.rb
|
93
131
|
- lib/audioinfo/mpcinfo.rb
|
94
|
-
- lib/shell_escape.rb
|
95
132
|
- test/mpcinfo.rb
|
96
133
|
has_rdoc: true
|
97
134
|
homepage: http://ruby-audioinfo.rubyforge.org
|
135
|
+
licenses: []
|
136
|
+
|
98
137
|
post_install_message:
|
99
138
|
rdoc_options:
|
100
|
-
- --
|
101
|
-
- README.txt
|
139
|
+
- --charset=UTF-8
|
102
140
|
require_paths:
|
103
141
|
- lib
|
104
142
|
required_ruby_version: !ruby/object:Gem::Requirement
|
143
|
+
none: false
|
105
144
|
requirements:
|
106
145
|
- - ">="
|
107
146
|
- !ruby/object:Gem::Version
|
147
|
+
hash: 3
|
148
|
+
segments:
|
149
|
+
- 0
|
108
150
|
version: "0"
|
109
|
-
version:
|
110
151
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
|
+
none: false
|
111
153
|
requirements:
|
112
154
|
- - ">="
|
113
155
|
- !ruby/object:Gem::Version
|
156
|
+
hash: 3
|
157
|
+
segments:
|
158
|
+
- 0
|
114
159
|
version: "0"
|
115
|
-
version:
|
116
160
|
requirements: []
|
117
161
|
|
118
|
-
rubyforge_project:
|
119
|
-
rubygems_version: 1.3.
|
162
|
+
rubyforge_project:
|
163
|
+
rubygems_version: 1.3.7
|
120
164
|
signing_key:
|
121
|
-
specification_version:
|
122
|
-
summary:
|
165
|
+
specification_version: 3
|
166
|
+
summary: Unified audio info access library
|
123
167
|
test_files: []
|
124
168
|
|
data/Manifest.txt
DELETED