flac2mp3 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +10 -0
- data/lib/flac2mp3.rb +40 -7
- data/lib/flac2mp3/version.rb +1 -1
- data/spec/flac2mp3_spec.rb +55 -6
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
== 0.2.5 2008-05-12
|
2
|
+
|
3
|
+
* 1 bug fix:
|
4
|
+
* Composer now actually carried over from FLAC to MP# tags, not just thought to be.
|
5
|
+
|
6
|
+
* 3 enhancements:
|
7
|
+
* Compilation flag carried over.
|
8
|
+
* Track total carried over in addition to track number.
|
9
|
+
* Disc total and disc number carried over.
|
10
|
+
|
1
11
|
== 0.2.4 2008-04-28
|
2
12
|
|
3
13
|
* 1 bug fix:
|
data/lib/flac2mp3.rb
CHANGED
@@ -26,11 +26,15 @@ module Flac2mp3
|
|
26
26
|
:artist => :artist,
|
27
27
|
:bpm => :TBPM,
|
28
28
|
:description => :comments,
|
29
|
-
:composer => :
|
29
|
+
:composer => :TCOM,
|
30
30
|
:date => :year,
|
31
31
|
:genre => :genre_s,
|
32
32
|
:title => :title,
|
33
|
-
:tracknumber => :
|
33
|
+
:tracknumber => :TRCK,
|
34
|
+
:tracktotal => :TRCK,
|
35
|
+
:discnumber => :TPOS,
|
36
|
+
:disctotal => :TPOS,
|
37
|
+
:compilation => :TCMP
|
34
38
|
}
|
35
39
|
end
|
36
40
|
|
@@ -48,19 +52,48 @@ module Flac2mp3
|
|
48
52
|
def mp3data(filename, tags)
|
49
53
|
raise TypeError, "Tags must be a hash" unless tags.is_a?(Hash)
|
50
54
|
Mp3Info.open(filename) do |mp3|
|
51
|
-
tags.each do |
|
52
|
-
|
53
|
-
tag
|
54
|
-
tag = mp3.tag2 if key == :bpm
|
55
|
-
tag.send("#{mp3tag}=", value)
|
55
|
+
convert_tags(tags).each do |mp3tag, data|
|
56
|
+
tag = mp3.send(data[:target])
|
57
|
+
tag.send("#{mp3tag}=", data[:value])
|
56
58
|
end
|
57
59
|
end
|
58
60
|
end
|
59
61
|
|
62
|
+
|
60
63
|
private
|
61
64
|
|
62
65
|
def string_fields
|
63
66
|
[:title, :description]
|
64
67
|
end
|
68
|
+
|
69
|
+
def tag2_fields
|
70
|
+
[:bpm, :composer, :compilation, :tracktotal, :tracknumber, :disctotal, :discnumber]
|
71
|
+
end
|
72
|
+
|
73
|
+
def tag_formats
|
74
|
+
{
|
75
|
+
:TRCK => ':tracknumber/:tracktotal',
|
76
|
+
:TPOS => ':discnumber/:disctotal'
|
77
|
+
}
|
78
|
+
end
|
79
|
+
|
80
|
+
def convert_tags(tags)
|
81
|
+
mp3_tags = {}
|
82
|
+
|
83
|
+
tags.each do |key, value|
|
84
|
+
next unless mp3tag = tag_mapping[key]
|
85
|
+
|
86
|
+
if format = tag_formats[mp3tag]
|
87
|
+
value = format.gsub(/:(\w+)/) do
|
88
|
+
field = $1
|
89
|
+
tags[field.to_sym]
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
target = tag2_fields.include?(key) ? :tag2 : :tag
|
94
|
+
mp3_tags[mp3tag] = { :target => target, :value => value }
|
95
|
+
end
|
96
|
+
mp3_tags
|
97
|
+
end
|
65
98
|
end
|
66
99
|
end
|
data/lib/flac2mp3/version.rb
CHANGED
data/spec/flac2mp3_spec.rb
CHANGED
@@ -142,8 +142,8 @@ describe Flac2mp3, 'providing a mapping of tags' do
|
|
142
142
|
Flac2mp3.tag_mapping[:description].should == :comments
|
143
143
|
end
|
144
144
|
|
145
|
-
it "should map 'composer' to '
|
146
|
-
Flac2mp3.tag_mapping[:composer].should == :
|
145
|
+
it "should map 'composer' to 'TCOM'" do
|
146
|
+
Flac2mp3.tag_mapping[:composer].should == :TCOM
|
147
147
|
end
|
148
148
|
|
149
149
|
it "should map 'date' to 'year'" do
|
@@ -158,8 +158,24 @@ describe Flac2mp3, 'providing a mapping of tags' do
|
|
158
158
|
Flac2mp3.tag_mapping[:title].should == :title
|
159
159
|
end
|
160
160
|
|
161
|
-
it "should map 'tracknumber' to '
|
162
|
-
Flac2mp3.tag_mapping[:tracknumber].should == :
|
161
|
+
it "should map 'tracknumber' to 'TRCK'" do
|
162
|
+
Flac2mp3.tag_mapping[:tracknumber].should == :TRCK
|
163
|
+
end
|
164
|
+
|
165
|
+
it "should map 'tracktotal' to 'TRCK'" do
|
166
|
+
Flac2mp3.tag_mapping[:tracktotal].should == :TRCK
|
167
|
+
end
|
168
|
+
|
169
|
+
it "should map 'discnumber' to 'TPOS'" do
|
170
|
+
Flac2mp3.tag_mapping[:discnumber].should == :TPOS
|
171
|
+
end
|
172
|
+
|
173
|
+
it "should map 'disctotal' to 'TPOS'" do
|
174
|
+
Flac2mp3.tag_mapping[:disctotal].should == :TPOS
|
175
|
+
end
|
176
|
+
|
177
|
+
it "should map 'compilation' to 'TCMP'" do
|
178
|
+
Flac2mp3.tag_mapping[:compilation].should == :TCMP
|
163
179
|
end
|
164
180
|
end
|
165
181
|
|
@@ -258,7 +274,7 @@ describe Flac2mp3, 'when getting FLAC tag data' do
|
|
258
274
|
data[:description].should == '1938'
|
259
275
|
end
|
260
276
|
|
261
|
-
it 'should leave numeric
|
277
|
+
it 'should leave numeric descriptions as strings even if the description key is not a simple downcased symbol' do
|
262
278
|
@tags['DESCRIPTION'] = '1938'
|
263
279
|
|
264
280
|
data = Flac2mp3.flacdata(@filename)
|
@@ -324,7 +340,6 @@ describe Flac2mp3, 'when setting MP3 tag data' do
|
|
324
340
|
|
325
341
|
@mp3tags.expects(:comments=).never
|
326
342
|
@mp3tags.expects(:year=).never
|
327
|
-
@mp3tags.expects(:tracknum=).never
|
328
343
|
|
329
344
|
Flac2mp3.mp3data(@filename, @tags)
|
330
345
|
end
|
@@ -346,4 +361,38 @@ describe Flac2mp3, 'when setting MP3 tag data' do
|
|
346
361
|
|
347
362
|
Flac2mp3.mp3data(@filename, @tags)
|
348
363
|
end
|
364
|
+
|
365
|
+
it 'should use tag2 for composer' do
|
366
|
+
@tags[:composer] = 'Il Maestro'
|
367
|
+
|
368
|
+
@mp3tags2.expects(:TCOM=).with(@tags[:composer])
|
369
|
+
|
370
|
+
Flac2mp3.mp3data(@filename, @tags)
|
371
|
+
end
|
372
|
+
|
373
|
+
it 'should use tag2 for compilation' do
|
374
|
+
@tags[:compilation] = '1'
|
375
|
+
|
376
|
+
@mp3tags2.expects(:TCMP=).with(@tags[:compilation])
|
377
|
+
|
378
|
+
Flac2mp3.mp3data(@filename, @tags)
|
379
|
+
end
|
380
|
+
|
381
|
+
it 'should set tag2 track to be a combination of tracknumber and tracktotal' do
|
382
|
+
@tags[:tracknumber] = 4
|
383
|
+
@tags[:tracktotal] = 15
|
384
|
+
|
385
|
+
@mp3tags2.expects(:TRCK=).with('4/15')
|
386
|
+
|
387
|
+
Flac2mp3.mp3data(@filename, @tags)
|
388
|
+
end
|
389
|
+
|
390
|
+
it "should set tag2 'pos' to be a combination of discnumber and disctotal" do
|
391
|
+
@tags[:discnumber] = 1
|
392
|
+
@tags[:disctotal] = 2
|
393
|
+
|
394
|
+
@mp3tags2.expects(:TPOS=).with('1/2')
|
395
|
+
|
396
|
+
Flac2mp3.mp3data(@filename, @tags)
|
397
|
+
end
|
349
398
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flac2mp3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yossef Mendelssohn
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-05-12 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|