id3lib-ruby 0.3.1-mswin32 → 0.4.0-mswin32
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/CHANGES +6 -0
- data/Rakefile +16 -8
- data/ext/mswin32/id3lib_api.so +0 -0
- data/lib/id3lib.rb +31 -24
- data/test/test_writing.rb +11 -4
- data/usage.rb +40 -0
- metadata +6 -3
data/CHANGES
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
= id3lib-ruby changes
|
2
2
|
|
3
|
+
=== 0.4.0 (r41)
|
4
|
+
|
5
|
+
* Fixed Unicode problems (bug 4768).
|
6
|
+
* Renamed ID3Lib::API methods to be more like the id3lib method names.
|
7
|
+
For example, the GetType() method is now named get_type instead of type.
|
8
|
+
|
3
9
|
=== 0.3.1 (r32)
|
4
10
|
|
5
11
|
* Added check and messages for -lstdc++ and -lz to extconf.rb.
|
data/Rakefile
CHANGED
@@ -10,15 +10,22 @@ require 'rake/testtask'
|
|
10
10
|
require 'rake/rdoctask'
|
11
11
|
|
12
12
|
|
13
|
-
PKG_VERSION = '0.
|
13
|
+
PKG_VERSION = '0.4.0'
|
14
14
|
|
15
|
-
|
15
|
+
FILES_COMMON = FileList[
|
16
16
|
'lib/**/*.rb',
|
17
17
|
'test/test_*.rb',
|
18
18
|
'test/data/*.mp3',
|
19
19
|
'test/data/cover.jpg',
|
20
20
|
'Rakefile',
|
21
|
-
'
|
21
|
+
'*.rb'
|
22
|
+
]
|
23
|
+
|
24
|
+
FILES_EXT = FileList[
|
25
|
+
'ext/*.rb',
|
26
|
+
'ext/*.cxx',
|
27
|
+
'ext/*.i',
|
28
|
+
'ext/Rakefile'
|
22
29
|
]
|
23
30
|
|
24
31
|
|
@@ -42,7 +49,7 @@ Rake::TestTask.new do |t|
|
|
42
49
|
end
|
43
50
|
|
44
51
|
|
45
|
-
RDOC_OPTS = ['--line-numbers', '--main', 'README']
|
52
|
+
RDOC_OPTS = ['--inline-source', '--line-numbers', '--main', 'README']
|
46
53
|
|
47
54
|
desc "Generate RDOC documentation."
|
48
55
|
Rake::RDocTask.new :rdoc do |rdoc|
|
@@ -63,7 +70,7 @@ if defined? Gem
|
|
63
70
|
'id3lib-ruby provides a Ruby interface to the id3lib C++ library for ' +
|
64
71
|
'easily editing ID3 tags (v1 and v2) like with pyid3lib.'
|
65
72
|
s.requirements << 'id3lib C++ library'
|
66
|
-
s.files =
|
73
|
+
s.files = FILES_COMMON + FILES_EXT
|
67
74
|
s.extensions = ['ext/extconf.rb']
|
68
75
|
s.test_files = FileList['test/test_*.rb']
|
69
76
|
s.has_rdoc = true
|
@@ -81,7 +88,7 @@ if defined? Gem
|
|
81
88
|
end
|
82
89
|
|
83
90
|
spec_mswin32 = spec.clone
|
84
|
-
spec_mswin32.files =
|
91
|
+
spec_mswin32.files = FILES_COMMON + FileList['ext/mswin32/id3lib_api.so']
|
85
92
|
spec_mswin32.extensions = []
|
86
93
|
spec_mswin32.require_paths = ['lib', 'ext/mswin32']
|
87
94
|
spec_mswin32.platform = Gem::Platform::WIN32
|
@@ -99,14 +106,15 @@ end # defined? Gem
|
|
99
106
|
task :web => [:web_doc] do
|
100
107
|
puts "# Now execute the following:"
|
101
108
|
puts "scp web/* robinstocker@rubyforge.org:/var/www/gforge-projects/id3lib-ruby/"
|
102
|
-
puts "scp -r web/doc robinstocker@rubyforge.org:/var/www/gforge-projects/id3lib-ruby/
|
109
|
+
puts "scp -r web/doc robinstocker@rubyforge.org:/var/www/gforge-projects/id3lib-ruby/"
|
103
110
|
end
|
104
111
|
|
105
112
|
desc "Generate RDOC documentation on web."
|
106
113
|
Rake::RDocTask.new :web_doc do |rdoc|
|
107
114
|
rdoc.rdoc_dir = 'web/doc'
|
108
115
|
rdoc.title = 'id3lib-ruby'
|
109
|
-
rdoc.options
|
116
|
+
rdoc.options = RDOC_OPTS.clone
|
117
|
+
rdoc.options << '--main' << 'ID3Lib::Tag'
|
110
118
|
rdoc.rdoc_files.include('README', 'TODO', 'CHANGES')
|
111
119
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
112
120
|
end
|
data/ext/mswin32/id3lib_api.so
CHANGED
Binary file
|
data/lib/id3lib.rb
CHANGED
@@ -327,25 +327,26 @@ module ID3Lib
|
|
327
327
|
|
328
328
|
def self.read(libframe)
|
329
329
|
frame = {}
|
330
|
-
info = Info.frame_num(libframe.
|
330
|
+
info = Info.frame_num(libframe.get_id)
|
331
331
|
frame[:id] = info[ID]
|
332
|
-
|
333
|
-
textenc = field(libframe, :textenc).integer
|
334
|
-
frame[:textenc] = textenc
|
335
|
-
end
|
332
|
+
|
336
333
|
info[FIELDS].each do |field_id|
|
337
|
-
next if field_id == :textenc
|
338
334
|
libfield = field(libframe, field_id)
|
339
|
-
frame[field_id] =
|
340
|
-
libfield.
|
341
|
-
|
342
|
-
|
343
|
-
when :
|
344
|
-
|
345
|
-
when :text
|
335
|
+
frame[field_id] =
|
336
|
+
case Info::FieldType[libfield.get_type]
|
337
|
+
when :integer
|
338
|
+
libfield.get_integer
|
339
|
+
when :binary
|
340
|
+
libfield.get_binary
|
341
|
+
when :text
|
342
|
+
if libfield.get_encoding > 0
|
343
|
+
libfield.get_unicode
|
344
|
+
else
|
345
|
+
libfield.get_ascii
|
346
|
+
end
|
346
347
|
end
|
347
|
-
end
|
348
348
|
end
|
349
|
+
|
349
350
|
frame
|
350
351
|
end
|
351
352
|
|
@@ -353,29 +354,35 @@ module ID3Lib
|
|
353
354
|
if textenc = frame[:textenc]
|
354
355
|
field(libframe, :textenc).set_integer(textenc)
|
355
356
|
end
|
357
|
+
|
356
358
|
frame.each do |field_id, value|
|
357
359
|
next if field_id == :textenc
|
358
360
|
unless Info.frame(frame[:id])[FIELDS].include?(field_id)
|
359
361
|
# Ignore invalid fields
|
360
362
|
next
|
361
363
|
end
|
364
|
+
|
362
365
|
libfield = field(libframe, field_id)
|
363
|
-
|
364
|
-
|
365
|
-
libfield.
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
366
|
+
case Info::FieldType[libfield.get_type]
|
367
|
+
when :integer
|
368
|
+
libfield.set_integer(value)
|
369
|
+
when :binary
|
370
|
+
libfield.set_binary(value)
|
371
|
+
when :text
|
372
|
+
if textenc and textenc > 0 and
|
373
|
+
[:text, :description, :filename].include?(field_id)
|
374
|
+
# Special treatment for Unicode
|
375
|
+
libfield.set_encoding(textenc)
|
376
|
+
libfield.set_unicode(value)
|
377
|
+
else
|
378
|
+
libfield.set_ascii(value)
|
372
379
|
end
|
373
380
|
end
|
374
381
|
end
|
375
382
|
end
|
376
383
|
|
377
384
|
def self.field(libframe, id)
|
378
|
-
libframe.
|
385
|
+
libframe.get_field(Info.field(id)[NUM])
|
379
386
|
end
|
380
387
|
|
381
388
|
end
|
data/test/test_writing.rb
CHANGED
@@ -172,12 +172,19 @@ class TestWriting < Test::Unit::TestCase
|
|
172
172
|
|
173
173
|
def test_unicode
|
174
174
|
nihao = "\x4f\x60\x59\x7d"
|
175
|
-
|
176
|
-
|
175
|
+
frame = {
|
176
|
+
:id => :COMM,
|
177
|
+
:text => nihao,
|
178
|
+
:description => nihao,
|
179
|
+
:language => "zho",
|
180
|
+
:textenc => 1
|
181
|
+
}
|
182
|
+
@tag.comment = nil
|
183
|
+
@tag << frame
|
177
184
|
@tag.update!(ID3Lib::V2)
|
178
|
-
assert_equal
|
185
|
+
assert_equal frame, @tag.frame(:COMM)
|
179
186
|
reload!(ID3Lib::V2)
|
180
|
-
assert_equal
|
187
|
+
assert_equal frame, @tag.frame(:COMM)
|
181
188
|
end
|
182
189
|
|
183
190
|
def test_unicode_invalid_data
|
data/usage.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
require 'rubygems'
|
3
|
+
require 'id3lib'
|
4
|
+
|
5
|
+
# Load a tag from a file
|
6
|
+
tag = ID3Lib::Tag.new('talk.mp3')
|
7
|
+
|
8
|
+
# Get and set text frames with convenience methods
|
9
|
+
tag.title #=> "Talk"
|
10
|
+
tag.album = 'X&Y'
|
11
|
+
tag.track = '5/13'
|
12
|
+
|
13
|
+
# Tag is a subclass of Array and each frame is a Hash
|
14
|
+
tag[0]
|
15
|
+
#=> { :id => :TPE1, :textenc => 0, :text => "Coldplay" }
|
16
|
+
|
17
|
+
# Get the number of frames
|
18
|
+
tag.length #=> 7
|
19
|
+
|
20
|
+
# Remove all comment frames
|
21
|
+
tag.delete_if{ |frame| frame[:id] == :COMM }
|
22
|
+
|
23
|
+
# Get info about APIC frame to see which fields are allowed
|
24
|
+
ID3Lib::Info.frame(:APIC)
|
25
|
+
#=> [ 2, :APIC, "Attached picture",
|
26
|
+
#=> [:textenc, :mimetype, :picturetype, :description, :data] ]
|
27
|
+
|
28
|
+
# Add an attached picture frame
|
29
|
+
cover = {
|
30
|
+
:id => :APIC,
|
31
|
+
:mimetype => 'image/jpeg',
|
32
|
+
:picturetype => 3,
|
33
|
+
:description => 'A pretty picture',
|
34
|
+
:textenc => 0,
|
35
|
+
:data => File.read('cover.jpg')
|
36
|
+
}
|
37
|
+
tag << cover
|
38
|
+
|
39
|
+
# Last but not least, apply changes
|
40
|
+
tag.update!
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.
|
2
|
+
rubygems_version: 0.8.99
|
3
3
|
specification_version: 1
|
4
4
|
name: id3lib-ruby
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2006-06-
|
6
|
+
version: 0.4.0
|
7
|
+
date: 2006-06-27 00:00:00 +02:00
|
8
8
|
summary: id3lib-ruby provides a Ruby interface to the id3lib C++ library for easily editing ID3 tags (v1 and v2) like with pyid3lib.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -26,6 +26,7 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
26
26
|
platform: mswin32
|
27
27
|
signing_key:
|
28
28
|
cert_chain:
|
29
|
+
post_install_message:
|
29
30
|
authors:
|
30
31
|
- Robin Stocker
|
31
32
|
files:
|
@@ -38,6 +39,7 @@ files:
|
|
38
39
|
- test/data/unicode.mp3
|
39
40
|
- test/data/cover.jpg
|
40
41
|
- Rakefile
|
42
|
+
- usage.rb
|
41
43
|
- setup.rb
|
42
44
|
- ext/mswin32/id3lib_api.so
|
43
45
|
- README
|
@@ -47,6 +49,7 @@ test_files:
|
|
47
49
|
- test/test_writing.rb
|
48
50
|
- test/test_reading.rb
|
49
51
|
rdoc_options:
|
52
|
+
- --inline-source
|
50
53
|
- --line-numbers
|
51
54
|
- --main
|
52
55
|
- README
|