id3lib-ruby 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,10 +1,15 @@
1
1
  = id3lib-ruby changes
2
2
 
3
+ === 0.4.1 (r53)
4
+
5
+ * Added :description to the allowed fields of :TXXX frames (patch 5484).
6
+ * Added more tests and a warning in README for writing of UTF-16 frames.
7
+
3
8
  === 0.4.0 (r41)
4
9
 
5
10
  * Fixed Unicode problems (bug 4768).
6
11
  * 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.
12
+ E.g. the GetType() method is now named get_type instead of type.
8
13
 
9
14
  === 0.3.1 (r32)
10
15
 
data/README CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  = id3lib-ruby
3
2
 
4
3
  id3lib-ruby provides a Ruby interface to the id3lib C++ library for easily
@@ -9,12 +8,12 @@ The class documentation starts at ID3Lib::Tag.
9
8
 
10
9
  == Features
11
10
 
12
- * Read and write ID3v1 or ID3v2 tags
11
+ * Read and write ID3v1 and ID3v2 tags
13
12
  * Simple interface for adding, changing and removing frames
14
13
  * Quick access to common text frames like title and performer
15
14
  * Custom data frames like attached picture (APIC)
16
15
  * Pretty complete coverage of id3lib's features
17
- * UTF-16 support
16
+ * UTF-16 support (warning: id3lib writes broken UTF-16 frames)
18
17
  * Windows binary gem available
19
18
 
20
19
  See TODO for planned features.
@@ -40,6 +39,7 @@ Manual installation:
40
39
 
41
40
  ruby setup.rb
42
41
 
42
+
43
43
  == Usage
44
44
 
45
45
  require 'rubygems'
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ require 'rake/testtask'
10
10
  require 'rake/rdoctask'
11
11
 
12
12
 
13
- PKG_VERSION = '0.4.0'
13
+ PKG_VERSION = '0.4.1'
14
14
 
15
15
  FILES_COMMON = FileList[
16
16
  'lib/**/*.rb',
@@ -109,7 +109,7 @@ task :web => [:web_doc] do
109
109
  puts "scp -r web/doc robinstocker@rubyforge.org:/var/www/gforge-projects/id3lib-ruby/"
110
110
  end
111
111
 
112
- desc "Generate RDOC documentation on web."
112
+ desc "Generate RDOC documentation for web."
113
113
  Rake::RDocTask.new :web_doc do |rdoc|
114
114
  rdoc.rdoc_dir = 'web/doc'
115
115
  rdoc.title = 'id3lib-ruby'
data/TODO CHANGED
@@ -1,4 +1,6 @@
1
1
  = id3lib-ruby to-do list
2
2
 
3
- * Evaluate a more object-oriented way to handle frames, instead of hashes.
3
+ * Evaluate an object-oriented way to handle frames, instead of with hashes.
4
+ * Make the update! method intelligent, because the call of strip each time
5
+ is very slow and stupid.
4
6
  * Add UTF-8 support if id3lib can handle it.
data/ext/id3lib_api.i CHANGED
@@ -112,16 +112,16 @@ public:
112
112
 
113
113
  VALUE get_unicode()
114
114
  {
115
- const char *string = (const char *)self->GetRawUnicodeText();
116
- if (string == NULL) return rb_str_new("", 0);
115
+ const char *str = (const char *)self->GetRawUnicodeText();
116
+ if (str == NULL) return rb_str_new("", 0);
117
117
  long size = self->Size();
118
- if (size >= 2 && string[size-2] == '\0' && string[size-1] == '\0') {
118
+ if (size >= 2 && str[size-2] == '\0' && str[size-1] == '\0') {
119
119
  // id3lib seems to be inconsistent: the Unicode strings
120
120
  // don't always end in 0x0000. If they do, we don't want these
121
121
  // trailing bytes.
122
122
  size -= 2;
123
123
  }
124
- return rb_str_new(string, size);
124
+ return rb_str_new(str, size);
125
125
  }
126
126
  }
127
127
 
@@ -1808,16 +1808,16 @@ SWIGINTERN VALUE ID3_Field_get_binary(ID3_Field *self){
1808
1808
  return rb_str_new((const char *)self->GetRawBinary(), self->Size());
1809
1809
  }
1810
1810
  SWIGINTERN VALUE ID3_Field_get_unicode(ID3_Field *self){
1811
- const char *string = (const char *)self->GetRawUnicodeText();
1812
- if (string == NULL) return rb_str_new("", 0);
1811
+ const char *str = (const char *)self->GetRawUnicodeText();
1812
+ if (str == NULL) return rb_str_new("", 0);
1813
1813
  long size = self->Size();
1814
- if (size >= 2 && string[size-2] == '\0' && string[size-1] == '\0') {
1814
+ if (size >= 2 && str[size-2] == '\0' && str[size-1] == '\0') {
1815
1815
  // id3lib seems to be inconsistent: the Unicode strings
1816
1816
  // don't always end in 0x0000. If they do, we don't want these
1817
1817
  // trailing bytes.
1818
1818
  size -= 2;
1819
1819
  }
1820
- return rb_str_new(string, size);
1820
+ return rb_str_new(str, size);
1821
1821
  }
1822
1822
  SWIGINTERN size_t ID3_Field_set_binary(ID3_Field *self,VALUE data){
1823
1823
  StringValue(data);
data/lib/id3lib/info.rb CHANGED
@@ -142,7 +142,7 @@ module ID3Lib
142
142
  [76, :TSRC, "ISRC (international standard recording code)", [:textenc, :text]],
143
143
  [77, :TSSE, "Software/Hardware and settings used for encoding", [:textenc, :text]],
144
144
  [78, :TSST, "Set subtitle", [:textenc, :text]],
145
- [79, :TXXX, "User defined text information", [:textenc, :text]],
145
+ [79, :TXXX, "User defined text information", [:textenc, :description, :text]],
146
146
  [80, :TYER, "Year", [:textenc, :text]],
147
147
  # Special frames again
148
148
  [81, :UFID, "Unique file identifier", [:owner, :data]],
data/test/test_reading.rb CHANGED
@@ -39,11 +39,6 @@ class TestReading < Test::Unit::TestCase
39
39
  assert_equal 'Dummy Comment 2', two[:text]
40
40
  end
41
41
 
42
- def test_unicode
43
- @tag = ID3Lib::Tag.new('test/data/unicode.mp3', ID3Lib::V2)
44
- assert_equal "\x4f\x60\x59\x7d", @tag.title
45
- end
46
-
47
42
  def test_has_tag
48
43
  assert @tag.has_tag?(ID3Lib::V1)
49
44
  assert @tag.has_tag?(ID3Lib::V2)
@@ -0,0 +1,75 @@
1
+
2
+ require 'test/unit'
3
+ require 'fileutils'
4
+ require 'id3lib'
5
+
6
+
7
+ class TestUnicode < Test::Unit::TestCase
8
+
9
+ Sample = 'test/data/sample.mp3'
10
+ Temp = 'test/data/tmp.sample.mp3'
11
+
12
+ def setup
13
+ FileUtils.cp Sample, Temp
14
+ @tag = ID3Lib::Tag.new(Temp)
15
+ end
16
+
17
+ def teardown
18
+ FileUtils.rm Temp
19
+ end
20
+
21
+ # Failing because of id3lib.
22
+ def dont_test_UTF16BE
23
+ do_unicode_test :text => "\x4f\x60\x59\x7d", :textenc => 2
24
+ end
25
+
26
+ def test_UTF16LE
27
+ do_unicode_test :text => "\x60\x4f\x7d\x59", :textenc => 1
28
+ end
29
+
30
+ # Failing because of id3lib.
31
+ def dont_test_UTF16BE_with_BOM
32
+ do_unicode_test :text => "\xfe\xff\x4f\x60\x59\x7d", :textenc => 1
33
+ end
34
+
35
+ def test_UTF16LE_with_BOM
36
+ do_unicode_test :text => "\xff\xfe\x60\x4f\x7d\x59", :textenc => 1
37
+ end
38
+
39
+ # Failing because of id3lib.
40
+ def dont_test_UTF16BE_above_127
41
+ do_unicode_test :text => "\xfe\xffC\346", :textenc => 1
42
+ end
43
+
44
+ def test_UTF16LE_above_127
45
+ do_unicode_test :text => "\xe6C", :textenc => 1
46
+ end
47
+
48
+ def test_UTF16LE_above_127_with_BOM
49
+ do_unicode_test :text => "\xff\xfe\xe6C", :textenc => 1
50
+ end
51
+
52
+ def test_reading
53
+ @tag = ID3Lib::Tag.new('test/data/unicode.mp3', ID3Lib::V2)
54
+ assert_equal "\x4f\x60\x59\x7d", @tag.title
55
+ end
56
+
57
+ def test_invalid_data
58
+ nonstr = 1
59
+ @tag.reject!{ |f| f[:id] == :TIT2 }
60
+ @tag << {:id => :TIT2, :text => nonstr, :textenc => 1}
61
+ assert_raise(TypeError) { @tag.update!(ID3Lib::V2) }
62
+ end
63
+
64
+ def do_unicode_test(opts)
65
+ frame = {:id => :TIT2}
66
+ frame.update(opts)
67
+ @tag.title = nil
68
+ @tag << frame
69
+ @tag.update!(ID3Lib::V2)
70
+ assert_equal frame, @tag.frame(:TIT2)
71
+ @tag = ID3Lib::Tag.new(Temp, ID3Lib::V2)
72
+ assert_equal frame, @tag.frame(:TIT2)
73
+ end
74
+
75
+ end
data/test/test_writing.rb CHANGED
@@ -32,7 +32,7 @@ class TestWriting < Test::Unit::TestCase
32
32
  reload!
33
33
  assert_equal 'New Title', @tag.title
34
34
  end
35
-
35
+
36
36
  def test_genre
37
37
  @tag.genre = 'Rock'
38
38
  assert_equal 'Rock', @tag.genre
@@ -41,7 +41,7 @@ class TestWriting < Test::Unit::TestCase
41
41
  reload!
42
42
  assert_equal 'Rock', @tag.genre
43
43
  end
44
-
44
+
45
45
  def test_id3v1_genre
46
46
  @tag.strip!(ID3Lib::V2)
47
47
  genre_id = '(' + ID3Lib::Info::Genres.index('Rock').to_s + ')'
@@ -75,7 +75,7 @@ class TestWriting < Test::Unit::TestCase
75
75
  reload!
76
76
  assert_equal '6', @tag.track
77
77
  end
78
-
78
+
79
79
  def test_year
80
80
  @tag.year = '2001'
81
81
  assert_equal '2001', @tag.year
@@ -105,7 +105,7 @@ class TestWriting < Test::Unit::TestCase
105
105
  reload!
106
106
  assert_equal 'New Comment', @tag.comment
107
107
  end
108
-
108
+
109
109
  def test_manual_frame
110
110
  @tag << {:id => :TLAN, :text => 'zho'}
111
111
  assert_equal 'zho', @tag.frame_text(:TLAN)
@@ -114,7 +114,7 @@ class TestWriting < Test::Unit::TestCase
114
114
  reload!
115
115
  assert_equal 'zho', @tag.frame_text(:TLAN)
116
116
  end
117
-
117
+
118
118
  def test_apic
119
119
  pic = {
120
120
  :id => :APIC,
@@ -130,17 +130,17 @@ class TestWriting < Test::Unit::TestCase
130
130
  reload!
131
131
  assert_equal pic, @tag.frame(:APIC)
132
132
  end
133
-
133
+
134
134
  def test_remove_frame
135
135
  @tag.remove_frame(:TIT2)
136
136
  assert_nil @tag.frame(:TIT2)
137
137
  end
138
-
138
+
139
139
  def test_remove_frame_with_direct_access
140
140
  @tag.title = nil
141
141
  assert_nil @tag.frame(:TIT2)
142
142
  end
143
-
143
+
144
144
  def test_wrong_frame
145
145
  l = @tag.length
146
146
  @tag << {:id => :WRONG, :text => "Test"}
@@ -149,14 +149,14 @@ class TestWriting < Test::Unit::TestCase
149
149
  reload!
150
150
  assert_equal l, @tag.length
151
151
  end
152
-
152
+
153
153
  def test_strip
154
154
  @tag.strip!
155
155
  assert @tag.empty?
156
156
  reload!
157
157
  assert @tag.empty?
158
158
  end
159
-
159
+
160
160
  def test_tagtype
161
161
  @tag.strip!(ID3Lib::V1)
162
162
  reload!(ID3Lib::V1)
@@ -169,30 +169,6 @@ class TestWriting < Test::Unit::TestCase
169
169
  reload!
170
170
  assert @tag.empty?
171
171
  end
172
-
173
- def test_unicode
174
- nihao = "\x4f\x60\x59\x7d"
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
184
- @tag.update!(ID3Lib::V2)
185
- assert_equal frame, @tag.frame(:COMM)
186
- reload!(ID3Lib::V2)
187
- assert_equal frame, @tag.frame(:COMM)
188
- end
189
-
190
- def test_unicode_invalid_data
191
- nonstr = 1
192
- @tag.reject!{ |f| f[:id] == :TIT2 }
193
- @tag << {:id => :TIT2, :text => nonstr, :textenc => 1}
194
- assert_raise(TypeError) { @tag.update!(ID3Lib::V2) }
195
- end
196
172
 
197
173
  def test_padding
198
174
  assert_equal 2176, File.size(Temp)
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.99
2
+ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: id3lib-ruby
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.4.0
7
- date: 2006-06-27 00:00:00 +02:00
6
+ version: 0.4.1
7
+ date: 2006-08-24 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
@@ -32,6 +32,7 @@ files:
32
32
  - lib/id3lib.rb
33
33
  - lib/id3lib/accessors.rb
34
34
  - lib/id3lib/info.rb
35
+ - test/test_unicode.rb
35
36
  - test/test_writing.rb
36
37
  - test/test_reading.rb
37
38
  - test/data/sample.mp3
@@ -49,6 +50,7 @@ files:
49
50
  - CHANGES
50
51
  - TODO
51
52
  test_files:
53
+ - test/test_unicode.rb
52
54
  - test/test_writing.rb
53
55
  - test/test_reading.rb
54
56
  rdoc_options: