id3lib-ruby 0.6.0-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +67 -0
- data/INSTALL +75 -0
- data/README +84 -0
- data/Rakefile +181 -0
- data/TODO +10 -0
- data/ext/id3lib_api/Rakefile +21 -0
- data/ext/id3lib_api/extconf.rb +27 -0
- data/ext/id3lib_api/id3lib_api.i +182 -0
- data/ext/id3lib_api/id3lib_api_wrap.cxx +3648 -0
- data/lib/id3lib.rb +418 -0
- data/lib/id3lib/accessors.rb +103 -0
- data/lib/id3lib/info.rb +393 -0
- data/lib/id3lib_api.so +0 -0
- data/setup.rb +1585 -0
- data/test/data/cover.jpg +0 -0
- data/test/data/sample.mp3 +0 -0
- data/test/data/unicode.mp3 +0 -0
- data/test/test_reading.rb +82 -0
- data/test/test_unicode.rb +85 -0
- data/test/test_writing.rb +221 -0
- data/usage.rb +40 -0
- metadata +175 -0
data/CHANGES
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
= id3lib-ruby changes
|
2
|
+
|
3
|
+
=== 0.6.0 (2010-05-16)
|
4
|
+
|
5
|
+
* Added convenience method user_frame_text to Tag for finding a
|
6
|
+
TXXX frame given a description (e.g. "MusicBrainz Album Id")
|
7
|
+
(RubyForge feature request 24381)
|
8
|
+
* Fixed compilation problem on Ruby 1.9 (GitHub issue 1)
|
9
|
+
* Don't check for ID3Tag_New in extconf.rb (RubyForge bug 27589)
|
10
|
+
* Updated to SWIG 1.3.40
|
11
|
+
* Use rake-compiler for cross-compiling the extension
|
12
|
+
|
13
|
+
=== 0.5.0 (2006-12-16)
|
14
|
+
|
15
|
+
* Warn when encountering nil field instead of raising exception (bug 6446).
|
16
|
+
* Corrected allowed fields - they are now generated from id3lib's source.
|
17
|
+
* Renamed :id field to :identifier because of confusion with frame ID.
|
18
|
+
* Added INSTALL document for installation instructions.
|
19
|
+
* Fixed memory leak in extension, where iterator was never released.
|
20
|
+
According to tests, there is no memory leak anymore.
|
21
|
+
* Added two patches for id3lib in mswin32 gem:
|
22
|
+
* unicode16: fixes Unicode writing bug
|
23
|
+
* convert_i-leak: fixes memory leak in Unicode conversion function
|
24
|
+
* Updated to SWIG 1.3.31.
|
25
|
+
|
26
|
+
=== 0.4.1 (r53)
|
27
|
+
|
28
|
+
* Added :description to the allowed fields of :TXXX frames (patch 5484).
|
29
|
+
* Added more tests and a warning in README for writing of UTF-16 frames.
|
30
|
+
|
31
|
+
=== 0.4.0 (r41)
|
32
|
+
|
33
|
+
* Fixed Unicode problems (bug 4768).
|
34
|
+
* Renamed ID3Lib::API methods to be more like the id3lib method names.
|
35
|
+
E.g. the GetType() method is now named get_type instead of type.
|
36
|
+
|
37
|
+
=== 0.3.1 (r32)
|
38
|
+
|
39
|
+
* Added check and messages for -lstdc++ and -lz to extconf.rb.
|
40
|
+
* Updated to SWIG 1.3.29.
|
41
|
+
|
42
|
+
=== 0.3.0 (r29)
|
43
|
+
|
44
|
+
* Added generation of mswin32 binary gem. This means that
|
45
|
+
installing on Windows is a piece of cake. No dependencies, no
|
46
|
+
compiling, just a gem installation.
|
47
|
+
* Changed Info.frame to use hash access instead of find -> faster.
|
48
|
+
|
49
|
+
=== 0.2.1 (r23)
|
50
|
+
|
51
|
+
* Fixed extconf.rb to print a message and abort if id3lib can't be
|
52
|
+
found.
|
53
|
+
|
54
|
+
=== 0.2.0 (r21)
|
55
|
+
|
56
|
+
* Overhauled direct access methods
|
57
|
+
* Remove frames by setting them to nil, e.g. tag.title = nil
|
58
|
+
* Removed methods for rarely used frames.
|
59
|
+
* All methods use strings now, no special cases like track anymore.
|
60
|
+
* Explicit call of to_s in set_frame_text.
|
61
|
+
* More unit tests
|
62
|
+
* Added method invalid_frames which is useful to detect invalid frame
|
63
|
+
data before calling update!.
|
64
|
+
|
65
|
+
=== 0.1.0 (r19)
|
66
|
+
|
67
|
+
* First release :)
|
data/INSTALL
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
= id3lib-ruby installation instructions
|
2
|
+
|
3
|
+
== Binary package (Windows)
|
4
|
+
|
5
|
+
There are precompiled binary gems available for Windows, so the installation
|
6
|
+
is as simple as typing the following and selecting the newest mswin32 gem:
|
7
|
+
|
8
|
+
gem install id3lib-ruby
|
9
|
+
|
10
|
+
== Source package
|
11
|
+
|
12
|
+
For other systems, there is a RubyGems package or a compressed archive.
|
13
|
+
|
14
|
+
=== Prerequisites
|
15
|
+
|
16
|
+
Before installing id3lib-ruby, you need to install the underlying id3lib
|
17
|
+
library and, depending on your system, set CONFIGURE_ARGS.
|
18
|
+
|
19
|
+
==== Ubuntu and Debian Linux
|
20
|
+
|
21
|
+
Install libid3-dev and be sure to have ruby-dev installed, otherwise you
|
22
|
+
won't be able to build Ruby extensions.
|
23
|
+
|
24
|
+
sudo aptitude install libid3-dev ruby-dev g++
|
25
|
+
|
26
|
+
==== Fedora Linux
|
27
|
+
|
28
|
+
sudo yum install id3lib-devel ruby-devel gcc-c++
|
29
|
+
|
30
|
+
==== Gentoo Linux
|
31
|
+
|
32
|
+
sudo emerge -n id3lib
|
33
|
+
|
34
|
+
==== Mac OS X
|
35
|
+
|
36
|
+
If you use the Ruby distribution provided by Mac OS X, you need to have Apple's
|
37
|
+
Xcode installed in order to be able to build extensions.
|
38
|
+
|
39
|
+
Now, either install id3lib through MacPorts or Fink, or by downloading and
|
40
|
+
compiling manually.
|
41
|
+
|
42
|
+
===== MacPorts
|
43
|
+
|
44
|
+
sudo port install id3lib
|
45
|
+
|
46
|
+
===== Fink
|
47
|
+
|
48
|
+
sudo apt-get install id3lib4-dev
|
49
|
+
|
50
|
+
=== Installing id3lib-ruby
|
51
|
+
|
52
|
+
Now you're ready to install id3lib-ruby. If you use RubyGems, run the
|
53
|
+
following and select the newest version marked "ruby":
|
54
|
+
|
55
|
+
sudo gem install id3lib-ruby
|
56
|
+
|
57
|
+
Or if you install from the archive, unpack it and do:
|
58
|
+
|
59
|
+
sudo ruby setup.rb
|
60
|
+
|
61
|
+
==== Mac OS X
|
62
|
+
|
63
|
+
On Mac OS X 10.5 and later, Ruby tries to compile the extension for multiple
|
64
|
+
architectures (universal build) and fails. You have to specify the right
|
65
|
+
architecture manually. For 64 bit Intel processors, do:
|
66
|
+
|
67
|
+
sudo env ARCHFLAGS="-arch x86_64" gem install id3lib-ruby
|
68
|
+
|
69
|
+
For 32 bit Intel processors:
|
70
|
+
|
71
|
+
sudo env ARCHFLAGS="-arch i386" gem install id3lib-ruby
|
72
|
+
|
73
|
+
And for PPC processors:
|
74
|
+
|
75
|
+
sudo env ARCHFLAGS="-arch ppc" gem install id3lib-ruby
|
data/README
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
= id3lib-ruby
|
2
|
+
|
3
|
+
id3lib-ruby provides a Ruby interface to the id3lib C++ library for easily
|
4
|
+
editing ID3 tags (v1 and v2) of MP3 audio files.
|
5
|
+
|
6
|
+
The class documentation starts at ID3Lib::Tag.
|
7
|
+
|
8
|
+
|
9
|
+
== Features
|
10
|
+
|
11
|
+
* Read and write ID3v1 and ID3v2 tags
|
12
|
+
* Simple interface for adding, changing and removing frames
|
13
|
+
* Quick access to common text frames like title and performer
|
14
|
+
* Custom data frames like attached picture (APIC)
|
15
|
+
* Pretty complete coverage of id3lib's features
|
16
|
+
* UTF-16 support (warning: id3lib writes broken UTF-16 frames)
|
17
|
+
* Windows binary gem available
|
18
|
+
|
19
|
+
The CHANGES file contains a list of changes between versions.
|
20
|
+
|
21
|
+
|
22
|
+
== Installation
|
23
|
+
|
24
|
+
See INSTALL.
|
25
|
+
|
26
|
+
|
27
|
+
== Online Information
|
28
|
+
|
29
|
+
The home of id3lib-ruby is http://id3lib-ruby.rubyforge.org
|
30
|
+
|
31
|
+
|
32
|
+
== Usage
|
33
|
+
|
34
|
+
require 'rubygems'
|
35
|
+
require 'id3lib'
|
36
|
+
|
37
|
+
# Load a tag from a file
|
38
|
+
tag = ID3Lib::Tag.new('talk.mp3')
|
39
|
+
|
40
|
+
# Get and set text frames with convenience methods
|
41
|
+
tag.title #=> "Talk"
|
42
|
+
tag.album = 'X&Y'
|
43
|
+
tag.track = '5/13'
|
44
|
+
|
45
|
+
# Tag is a subclass of Array and each frame is a Hash
|
46
|
+
tag[0]
|
47
|
+
#=> { :id => :TPE1, :textenc => 0, :text => "Coldplay" }
|
48
|
+
|
49
|
+
# Get the number of frames
|
50
|
+
tag.length #=> 7
|
51
|
+
|
52
|
+
# Remove all comment frames
|
53
|
+
tag.delete_if{ |frame| frame[:id] == :COMM }
|
54
|
+
|
55
|
+
# Get info about APIC frame to see which fields are allowed
|
56
|
+
ID3Lib::Info.frame(:APIC)
|
57
|
+
#=> [ 2, :APIC, "Attached picture",
|
58
|
+
#=> [:textenc, :mimetype, :picturetype, :description, :data] ]
|
59
|
+
|
60
|
+
# Add an attached picture frame
|
61
|
+
cover = {
|
62
|
+
:id => :APIC,
|
63
|
+
:mimetype => 'image/jpeg',
|
64
|
+
:picturetype => 3,
|
65
|
+
:description => 'A pretty picture',
|
66
|
+
:textenc => 0,
|
67
|
+
:data => File.read('cover.jpg')
|
68
|
+
}
|
69
|
+
tag << cover
|
70
|
+
|
71
|
+
# Last but not least, apply changes
|
72
|
+
tag.update!
|
73
|
+
|
74
|
+
|
75
|
+
== Licence
|
76
|
+
|
77
|
+
This library has Ruby's licence:
|
78
|
+
|
79
|
+
http://www.ruby-lang.org/en/LICENSE.txt
|
80
|
+
|
81
|
+
|
82
|
+
== Author
|
83
|
+
|
84
|
+
Robin Stocker <robinstocker at rubyforge.org>
|
data/Rakefile
ADDED
@@ -0,0 +1,181 @@
|
|
1
|
+
|
2
|
+
begin
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rake/gempackagetask'
|
5
|
+
rescue Exception
|
6
|
+
nil
|
7
|
+
end
|
8
|
+
|
9
|
+
begin
|
10
|
+
require 'rake/extensiontask'
|
11
|
+
rescue LoadError
|
12
|
+
# Compiling of extension will have to be done manually.
|
13
|
+
end
|
14
|
+
|
15
|
+
require 'rake/testtask'
|
16
|
+
require 'rake/rdoctask'
|
17
|
+
require 'open-uri'
|
18
|
+
|
19
|
+
|
20
|
+
FILES_COMMON = FileList[
|
21
|
+
'lib/**/*.rb',
|
22
|
+
'test/test_*.rb',
|
23
|
+
'test/data/*.mp3',
|
24
|
+
'test/data/cover.jpg',
|
25
|
+
'Rakefile',
|
26
|
+
'*.rb'
|
27
|
+
]
|
28
|
+
|
29
|
+
FILES_DOC = FileList[
|
30
|
+
'README', 'INSTALL', 'TODO', 'CHANGES'
|
31
|
+
]
|
32
|
+
|
33
|
+
FILES_EXT = FileList[
|
34
|
+
'ext/id3lib_api/*.{rb,cxx,i}',
|
35
|
+
'ext/id3lib_api/Rakefile'
|
36
|
+
]
|
37
|
+
|
38
|
+
|
39
|
+
Rake::TestTask.new do |t|
|
40
|
+
t.libs = ['lib', 'ext/id3lib_api']
|
41
|
+
t.test_files = FileList['test/test_*.rb']
|
42
|
+
t.verbose = true
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
RDOC_OPTS = ['--inline-source', '--line-numbers', '--main', 'README']
|
47
|
+
|
48
|
+
desc "Generate RDOC documentation."
|
49
|
+
Rake::RDocTask.new :rdoc do |rdoc|
|
50
|
+
rdoc.rdoc_dir = 'doc'
|
51
|
+
rdoc.title = 'id3lib-ruby'
|
52
|
+
rdoc.options = RDOC_OPTS
|
53
|
+
rdoc.rdoc_files.include(FILES_DOC)
|
54
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
55
|
+
end
|
56
|
+
task :doc => [:rdoc]
|
57
|
+
|
58
|
+
|
59
|
+
if defined? Gem
|
60
|
+
|
61
|
+
spec = Gem::Specification.new do |s|
|
62
|
+
s.name = 'id3lib-ruby'
|
63
|
+
s.version = File.read('lib/id3lib.rb')[/VERSION = '(.*)'/, 1]
|
64
|
+
s.summary =
|
65
|
+
'id3lib-ruby provides a Ruby interface to the id3lib C++ library for ' +
|
66
|
+
'easily editing ID3 tags (v1 and v2) of MP3 audio files.'
|
67
|
+
s.description = File.read('README')
|
68
|
+
s.requirements << 'id3lib C++ library'
|
69
|
+
s.files = FILES_COMMON + FILES_EXT
|
70
|
+
s.test_files = FileList['test/test_*.rb']
|
71
|
+
s.extensions << 'ext/id3lib_api/extconf.rb'
|
72
|
+
s.has_rdoc = true
|
73
|
+
s.extra_rdoc_files = FILES_DOC
|
74
|
+
s.rdoc_options = RDOC_OPTS
|
75
|
+
s.author = 'Robin Stocker'
|
76
|
+
s.email = 'robinstocker@rubyforge.org'
|
77
|
+
s.homepage = 'http://id3lib-ruby.rubyforge.org'
|
78
|
+
s.rubyforge_project = "id3lib-ruby"
|
79
|
+
end
|
80
|
+
|
81
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
82
|
+
pkg.need_tar_gz = true
|
83
|
+
pkg.need_zip = true
|
84
|
+
end
|
85
|
+
|
86
|
+
if defined? Rake::ExtensionTask
|
87
|
+
|
88
|
+
host = 'i586-mingw32msvc'
|
89
|
+
plat = 'x86-mswin32-60'
|
90
|
+
tmp = "#{Dir.pwd}/tmp/#{plat}"
|
91
|
+
cflags = "'-Os -DID3LIB_LINKOPTION=1'"
|
92
|
+
config_options = ["--with-opt-dir=#{tmp}", "--with-cflags=#{cflags}"]
|
93
|
+
id3lib_version = '3.8.3'
|
94
|
+
id3lib = "id3lib-#{id3lib_version}"
|
95
|
+
id3lib_url = "http://downloads.sourceforge.net/project/" +
|
96
|
+
"id3lib/id3lib/#{id3lib_version}/#{id3lib}.tar.gz"
|
97
|
+
patches = FileList["#{Dir.pwd}/ext/mswin32/patches/*patch"]
|
98
|
+
|
99
|
+
Rake::ExtensionTask.new('id3lib_api', spec) do |ext|
|
100
|
+
ext.cross_compile = true
|
101
|
+
ext.cross_platform = plat
|
102
|
+
ext.cross_config_options.concat(config_options)
|
103
|
+
if RUBY_PLATFORM =~ /mingw/
|
104
|
+
ext.config_options.concat(config_options)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
task :cross => [:id3lib] do
|
109
|
+
# Mkmf just uses "g++" as C++ compiler, despite what's in rbconfig.rb.
|
110
|
+
# So, we need to hack around it by setting CXX to the cross compiler.
|
111
|
+
ENV["CXX"] = "#{host}-g++"
|
112
|
+
end
|
113
|
+
|
114
|
+
# Linking to the DLLs provided by id3lib.sf.net doesn't seem to work on
|
115
|
+
# Windows, so we download and compile it automatically (the same as when
|
116
|
+
# cross compiling).
|
117
|
+
if RUBY_PLATFORM =~ /mingw/
|
118
|
+
Rake::Task[:compile].prerequisites.unshift(:id3lib)
|
119
|
+
end
|
120
|
+
|
121
|
+
task :id3lib => ["#{tmp}/lib/libid3.a"]
|
122
|
+
|
123
|
+
file "#{tmp}/lib/libid3.a" => ["#{tmp}/#{id3lib}/config.log"] do
|
124
|
+
chdir "#{tmp}/#{id3lib}" do
|
125
|
+
env = "CFLAGS=#{cflags} CXXFLAGS=#{cflags}"
|
126
|
+
sh "sh configure --host=#{host} --prefix=#{tmp} #{env}"
|
127
|
+
sh "make"
|
128
|
+
sh "make install"
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
file "#{tmp}/#{id3lib}/config.log" => ["#{tmp}/#{id3lib}.tar.gz"] do
|
133
|
+
chdir tmp do
|
134
|
+
sh "tar xzf #{id3lib}.tar.gz"
|
135
|
+
patches.each do |patch|
|
136
|
+
sh "patch -p0 < #{patch}"
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
file "#{tmp}/#{id3lib}.tar.gz" => [tmp] do |t|
|
142
|
+
puts "Downloading #{id3lib_url}"
|
143
|
+
data = open(id3lib_url).read()
|
144
|
+
break if data == nil
|
145
|
+
chdir tmp do
|
146
|
+
open(File.basename(t.name), 'wb') do |f|
|
147
|
+
f.write(data)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
directory tmp
|
153
|
+
|
154
|
+
end # defined? Rake::ExtensionTask
|
155
|
+
|
156
|
+
end # defined? Gem
|
157
|
+
|
158
|
+
|
159
|
+
task :web => [:web_doc] do
|
160
|
+
puts "# Now execute the following:"
|
161
|
+
puts "scp web/index.html web/logo.png web/red.css robinstocker@rubyforge.org:/var/www/gforge-projects/id3lib-ruby/"
|
162
|
+
puts "scp -r web/doc robinstocker@rubyforge.org:/var/www/gforge-projects/id3lib-ruby/"
|
163
|
+
end
|
164
|
+
|
165
|
+
desc "Generate RDOC documentation for web."
|
166
|
+
Rake::RDocTask.new :web_doc do |rdoc|
|
167
|
+
rdoc.rdoc_dir = 'web/doc'
|
168
|
+
rdoc.title = 'id3lib-ruby'
|
169
|
+
rdoc.options = RDOC_OPTS.clone
|
170
|
+
rdoc.options << '--main' << 'ID3Lib::Tag'
|
171
|
+
rdoc.rdoc_files.include(FILES_DOC)
|
172
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
173
|
+
end
|
174
|
+
|
175
|
+
desc "Generate syntax-highlighted HTML of usage.rb."
|
176
|
+
task :usage_html do
|
177
|
+
require 'syntax/convertors/html'
|
178
|
+
convertor = Syntax::Convertors::HTML.for_syntax('ruby')
|
179
|
+
html = convertor.convert(File.read('usage.rb'))
|
180
|
+
puts html
|
181
|
+
end
|
data/TODO
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
= id3lib-ruby to-do list
|
2
|
+
|
3
|
+
The underlying C++ library id3lib is no longer maintained and outdated (no
|
4
|
+
support for ID3v2.4). Therefore id3lib-ruby is no longer actively developed.
|
5
|
+
Here's the old to-do list anyway:
|
6
|
+
|
7
|
+
* Evaluate an object-oriented way to handle frames, instead of with hashes.
|
8
|
+
* Make the update! method intelligent, because the call of strip each time
|
9
|
+
is very slow and stupid.
|
10
|
+
* Add UTF-8 support if id3lib can handle it.
|
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
require 'rake/clean'
|
3
|
+
|
4
|
+
|
5
|
+
CLEAN.include '*.o', 'Makefile', 'mkmf.log'
|
6
|
+
CLOBBER.include 'id3lib_api.so', 'id3lib_api.bundle'
|
7
|
+
|
8
|
+
task :default => ['id3lib_api.bundle']
|
9
|
+
task :swig => ['id3lib_api_wrap.cxx']
|
10
|
+
|
11
|
+
file 'id3lib_api.bundle' => ['id3lib_api_wrap.cxx', 'Makefile'] do
|
12
|
+
sh "make"
|
13
|
+
end
|
14
|
+
|
15
|
+
file 'id3lib_api_wrap.cxx' => ['id3lib_api.i'] do
|
16
|
+
sh "swig -c++ -ruby -initname id3lib_api id3lib_api.i"
|
17
|
+
end
|
18
|
+
|
19
|
+
file 'Makefile' do
|
20
|
+
ruby "extconf.rb"
|
21
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Default opt dirs to help mkmf find id3lib
|
2
|
+
configure_args = "--with-opt-dir=/usr/local:/opt/local:/sw "
|
3
|
+
ENV['CONFIGURE_ARGS'] = configure_args + ENV.fetch('CONFIGURE_ARGS', "")
|
4
|
+
|
5
|
+
require 'mkmf'
|
6
|
+
|
7
|
+
def error msg
|
8
|
+
message msg + "\n"
|
9
|
+
abort
|
10
|
+
end
|
11
|
+
|
12
|
+
unless have_library('stdc++')
|
13
|
+
error "You must have libstdc++ installed."
|
14
|
+
end
|
15
|
+
|
16
|
+
unless have_library('z')
|
17
|
+
error "You must have zlib installed."
|
18
|
+
end
|
19
|
+
|
20
|
+
# This is only necessary for linking on Windows (don't ask me why).
|
21
|
+
have_library('iconv')
|
22
|
+
|
23
|
+
unless have_header('id3.h') and have_library('id3')
|
24
|
+
error "You must have id3lib installed in order to use id3lib-ruby."
|
25
|
+
end
|
26
|
+
|
27
|
+
create_makefile('id3lib_api')
|