easytag 0.4.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/Gemfile +7 -2
- data/README.md +33 -27
- data/Rakefile +7 -7
- data/easytag.gemspec +2 -4
- data/lib/easytag.rb +12 -2
- data/lib/easytag/attributes/base.rb +32 -128
- data/lib/easytag/attributes/flac.rb +25 -0
- data/lib/easytag/attributes/mp3.rb +91 -554
- data/lib/easytag/attributes/mp4.rb +22 -492
- data/lib/easytag/attributes/ogg.rb +27 -0
- data/lib/easytag/attributes/vorbis.rb +18 -0
- data/lib/easytag/taggers/base.rb +19 -0
- data/lib/easytag/taggers/factory.rb +59 -0
- data/lib/easytag/taggers/flac.rb +23 -0
- data/lib/easytag/taggers/mp3.rb +77 -0
- data/lib/easytag/taggers/mp4.rb +73 -0
- data/lib/easytag/taggers/ogg.rb +25 -0
- data/lib/easytag/taggers/vorbis.rb +66 -0
- data/lib/easytag/util.rb +9 -31
- data/lib/easytag/version.rb +3 -4
- data/scripts/build_attributes_table.rb +34 -0
- data/{test → spec/data}/consistency.01.m4a +0 -0
- data/{test → spec/data}/consistency.01.mp3 +0 -0
- data/spec/data/consistency.flac +0 -0
- data/{test/consistency.02.m4a → spec/data/consistency.m4a} +0 -0
- data/{test/consistency.02.mp3 → spec/data/consistency.mp3} +0 -0
- data/spec/data/consistency.multiple_images.flac +0 -0
- data/{test/no_tags.m4a → spec/data/consistency.multiple_images.m4a} +0 -0
- data/spec/data/consistency.multiple_images.mp3 +0 -0
- data/spec/data/consistency.multiple_images.ogg +0 -0
- data/spec/data/consistency.ogg +0 -0
- data/{test → spec/data}/musicbrainz.m4a +0 -0
- data/spec/data/no_tags.flac +0 -0
- data/spec/data/no_tags.m4a +0 -0
- data/{test → spec/data}/no_tags.mp3 +0 -0
- data/spec/data/no_tags.ogg +0 -0
- data/{test → spec/data}/only_id3v1.mp3 +0 -0
- data/{test → spec/data}/only_id3v2.mp3 +0 -0
- data/spec/flac_tagger_spec.rb +24 -0
- data/spec/mp3_tagger_spec.rb +64 -0
- data/spec/mp4_tagger_spec.rb +22 -0
- data/spec/ogg_tagger_spec.rb +21 -0
- data/spec/shared_examples.rb +115 -0
- data/spec/spec_helper.rb +34 -0
- data/spec/tagger_factory_spec.rb +27 -0
- data/spec/util_spec.rb +47 -0
- metadata +47 -48
- data/lib/easytag/attributes.rb +0 -0
- data/lib/easytag/base.rb +0 -28
- data/lib/easytag/file.rb +0 -44
- data/lib/easytag/interfaces.rb +0 -18
- data/lib/easytag/interfaces/base.rb +0 -24
- data/lib/easytag/interfaces/mp3.rb +0 -48
- data/lib/easytag/interfaces/mp4.rb +0 -14
- data/test/test_consistency.rb +0 -233
- data/test/test_mp3.rb +0 -98
- data/test/test_mp4.rb +0 -49
- data/test/test_util.rb +0 -72
metadata
CHANGED
@@ -1,57 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easytag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Lucas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: ruby
|
14
|
+
name: taglib-ruby
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.6.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.6.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: ruby-
|
28
|
+
name: ruby-imagespec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.3.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
40
|
+
version: 0.3.1
|
55
41
|
description: |2
|
56
42
|
EasyTag is an abstract interface to the TagLib audio tagging library.
|
57
43
|
It is designed to provide a simple and consistent API regardless
|
@@ -69,32 +55,48 @@ files:
|
|
69
55
|
- Rakefile
|
70
56
|
- easytag.gemspec
|
71
57
|
- lib/easytag.rb
|
72
|
-
- lib/easytag/attributes.rb
|
73
58
|
- lib/easytag/attributes/base.rb
|
59
|
+
- lib/easytag/attributes/flac.rb
|
74
60
|
- lib/easytag/attributes/mp3.rb
|
75
61
|
- lib/easytag/attributes/mp4.rb
|
76
|
-
- lib/easytag/
|
77
|
-
- lib/easytag/
|
62
|
+
- lib/easytag/attributes/ogg.rb
|
63
|
+
- lib/easytag/attributes/vorbis.rb
|
78
64
|
- lib/easytag/image.rb
|
79
|
-
- lib/easytag/
|
80
|
-
- lib/easytag/
|
81
|
-
- lib/easytag/
|
82
|
-
- lib/easytag/
|
65
|
+
- lib/easytag/taggers/base.rb
|
66
|
+
- lib/easytag/taggers/factory.rb
|
67
|
+
- lib/easytag/taggers/flac.rb
|
68
|
+
- lib/easytag/taggers/mp3.rb
|
69
|
+
- lib/easytag/taggers/mp4.rb
|
70
|
+
- lib/easytag/taggers/ogg.rb
|
71
|
+
- lib/easytag/taggers/vorbis.rb
|
83
72
|
- lib/easytag/util.rb
|
84
73
|
- lib/easytag/version.rb
|
85
|
-
-
|
86
|
-
-
|
87
|
-
-
|
88
|
-
-
|
89
|
-
-
|
90
|
-
-
|
91
|
-
-
|
92
|
-
-
|
93
|
-
-
|
94
|
-
-
|
95
|
-
-
|
96
|
-
-
|
97
|
-
-
|
74
|
+
- scripts/build_attributes_table.rb
|
75
|
+
- spec/data/consistency.01.m4a
|
76
|
+
- spec/data/consistency.01.mp3
|
77
|
+
- spec/data/consistency.flac
|
78
|
+
- spec/data/consistency.m4a
|
79
|
+
- spec/data/consistency.mp3
|
80
|
+
- spec/data/consistency.multiple_images.flac
|
81
|
+
- spec/data/consistency.multiple_images.m4a
|
82
|
+
- spec/data/consistency.multiple_images.mp3
|
83
|
+
- spec/data/consistency.multiple_images.ogg
|
84
|
+
- spec/data/consistency.ogg
|
85
|
+
- spec/data/musicbrainz.m4a
|
86
|
+
- spec/data/no_tags.flac
|
87
|
+
- spec/data/no_tags.m4a
|
88
|
+
- spec/data/no_tags.mp3
|
89
|
+
- spec/data/no_tags.ogg
|
90
|
+
- spec/data/only_id3v1.mp3
|
91
|
+
- spec/data/only_id3v2.mp3
|
92
|
+
- spec/flac_tagger_spec.rb
|
93
|
+
- spec/mp3_tagger_spec.rb
|
94
|
+
- spec/mp4_tagger_spec.rb
|
95
|
+
- spec/ogg_tagger_spec.rb
|
96
|
+
- spec/shared_examples.rb
|
97
|
+
- spec/spec_helper.rb
|
98
|
+
- spec/tagger_factory_spec.rb
|
99
|
+
- spec/util_spec.rb
|
98
100
|
homepage: https://github.com/cjlucas/ruby-easytag
|
99
101
|
licenses:
|
100
102
|
- MIT
|
@@ -115,12 +117,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
117
|
version: '0'
|
116
118
|
requirements: []
|
117
119
|
rubyforge_project:
|
118
|
-
rubygems_version: 2.
|
120
|
+
rubygems_version: 2.1.11
|
119
121
|
signing_key:
|
120
122
|
specification_version: 4
|
121
123
|
summary: A simple audio metadata tagging interface
|
122
|
-
test_files:
|
123
|
-
|
124
|
-
- test/test_mp3.rb
|
125
|
-
- test/test_mp4.rb
|
126
|
-
- test/test_util.rb
|
124
|
+
test_files: []
|
125
|
+
has_rdoc:
|
data/lib/easytag/attributes.rb
DELETED
File without changes
|
data/lib/easytag/base.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'taglib'
|
2
|
-
|
3
|
-
require 'easytag/interfaces'
|
4
|
-
|
5
|
-
module EasyTag
|
6
|
-
class Base
|
7
|
-
attr_reader :interface
|
8
|
-
|
9
|
-
def self.build_proxy_methods(iface)
|
10
|
-
# generate dynamic getters
|
11
|
-
(iface.instance_methods - Object.instance_methods).each do |m|
|
12
|
-
define_method(m) { proxy_getter(m) }
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def proxy_getter(m)
|
17
|
-
unless @interface.respond_to?(m)
|
18
|
-
warn "#{@interface.class} doesn't support method #{m}"
|
19
|
-
end
|
20
|
-
|
21
|
-
@interface.send(m)
|
22
|
-
end
|
23
|
-
|
24
|
-
# dynamic instance method generation
|
25
|
-
EasyTag::Interfaces.all.each { |iface| self.build_proxy_methods(iface) }
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
data/lib/easytag/file.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'easytag/base'
|
2
|
-
|
3
|
-
module EasyTag
|
4
|
-
class EasyTagFileUnsupportedError < Exception; end
|
5
|
-
|
6
|
-
class File < Base
|
7
|
-
attr_reader :file
|
8
|
-
|
9
|
-
def initialize(file)
|
10
|
-
@file = file
|
11
|
-
|
12
|
-
if audio_interface_class.nil?
|
13
|
-
raise EasyTagFileUnsupportedError,
|
14
|
-
"Couldn't determine which interface to use"
|
15
|
-
end
|
16
|
-
|
17
|
-
@interface = audio_interface_class.new(file)
|
18
|
-
end
|
19
|
-
|
20
|
-
# block interface
|
21
|
-
def self.open(file)
|
22
|
-
interface = self.new(file)
|
23
|
-
begin
|
24
|
-
yield interface if block_given?
|
25
|
-
ensure
|
26
|
-
interface.close if interface.respond_to?(:close)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
# sufficient for now
|
32
|
-
def audio_interface_class
|
33
|
-
ext = ::File.extname(@file).downcase[1..-1]
|
34
|
-
case ext
|
35
|
-
when 'mp3'
|
36
|
-
EasyTag::Interfaces::MP3
|
37
|
-
when 'mp4', 'm4a', 'aac'
|
38
|
-
EasyTag::Interfaces::MP4
|
39
|
-
else
|
40
|
-
nil
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
data/lib/easytag/interfaces.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'easytag/image'
|
2
|
-
require 'easytag/interfaces/base'
|
3
|
-
require 'easytag/interfaces/mp3'
|
4
|
-
require 'easytag/interfaces/mp4'
|
5
|
-
|
6
|
-
module EasyTag::Interfaces
|
7
|
-
# get all audio interfaces
|
8
|
-
def self.all
|
9
|
-
# get all classes in Interfaces
|
10
|
-
classes = self.constants.map do |sym|
|
11
|
-
const = self.const_get(sym)
|
12
|
-
const if const.class == Class && const.method_defined?(:info)
|
13
|
-
end
|
14
|
-
|
15
|
-
# filter out nil's
|
16
|
-
classes.compact
|
17
|
-
end
|
18
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module EasyTag
|
2
|
-
module Interfaces
|
3
|
-
class Base
|
4
|
-
attr_reader :info
|
5
|
-
|
6
|
-
def close
|
7
|
-
@info.close
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.build_attributes(attrib_class, attrib_args)
|
11
|
-
attrib_args.each do |attrib_args|
|
12
|
-
attrib = attrib_class.new(attrib_args)
|
13
|
-
define_method(attrib.name) do
|
14
|
-
instance_variable_get(attrib.ivar) ||
|
15
|
-
instance_variable_set(attrib.ivar, attrib.call(self))
|
16
|
-
end
|
17
|
-
|
18
|
-
attrib.aliases.each { |a| alias_method a, attrib.name}
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'mp3info'
|
2
|
-
|
3
|
-
require 'easytag/attributes/mp3'
|
4
|
-
|
5
|
-
module EasyTag::Interfaces
|
6
|
-
|
7
|
-
class MP3 < Base
|
8
|
-
ATTRIB_ARGS = EasyTag::Attributes::MP3_ATTRIB_ARGS
|
9
|
-
ATTRIB_CLASS = EasyTag::Attributes::MP3Attribute
|
10
|
-
|
11
|
-
def initialize(file)
|
12
|
-
@info = TagLib::MPEG::File.new(file)
|
13
|
-
|
14
|
-
add_tdat_to_taglib(file)
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def add_tdat_to_taglib(file)
|
20
|
-
# this is required because taglib hash issues with the TDAT+TYER
|
21
|
-
# frame (https://github.com/taglib/taglib/issues/127)
|
22
|
-
id3v2_hash = ID3v2.new
|
23
|
-
|
24
|
-
File.open(file) do |fp|
|
25
|
-
fp.read(3) # read past ID3 identifier
|
26
|
-
begin
|
27
|
-
id3v2_hash.from_io(fp)
|
28
|
-
rescue ID3v2Error => e
|
29
|
-
warn 'no id3v2 tags found'
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
# delete all TDAT frames (taglib-ruby segfaults when trying to read)
|
34
|
-
frames = @info.id3v2_tag.frame_list('TDAT')
|
35
|
-
frames.each { |frame| @info.id3v2_tag.remove_frame(frame) }
|
36
|
-
|
37
|
-
if id3v2_hash['TDAT']
|
38
|
-
frame = TagLib::ID3v2::TextIdentificationFrame
|
39
|
-
.new('TDAT', TagLib::String::UTF8)
|
40
|
-
|
41
|
-
frame.text = id3v2_hash['TDAT']
|
42
|
-
@info.id3v2_tag.add_frame(frame)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
self.build_attributes(ATTRIB_CLASS, ATTRIB_ARGS)
|
47
|
-
end
|
48
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'easytag/attributes/mp4'
|
2
|
-
|
3
|
-
module EasyTag::Interfaces
|
4
|
-
class MP4 < Base
|
5
|
-
ATTRIB_ARGS = EasyTag::Attributes::MP4_ATTRIB_ARGS
|
6
|
-
ATTRIB_CLASS = EasyTag::Attributes::MP4Attribute
|
7
|
-
|
8
|
-
def initialize(file)
|
9
|
-
@info = TagLib::MP4::File.new(file)
|
10
|
-
end
|
11
|
-
|
12
|
-
self.build_attributes(ATTRIB_CLASS, ATTRIB_ARGS)
|
13
|
-
end
|
14
|
-
end
|
data/test/test_consistency.rb
DELETED
@@ -1,233 +0,0 @@
|
|
1
|
-
require 'digest/sha1'
|
2
|
-
require 'test/unit'
|
3
|
-
|
4
|
-
require 'easytag'
|
5
|
-
|
6
|
-
TEST_DIR = File.dirname(File.absolute_path(__FILE__)) << File::SEPARATOR
|
7
|
-
|
8
|
-
class TestConsistencyMP301 < Test::Unit::TestCase
|
9
|
-
def setup
|
10
|
-
@mp3 = EasyTag::File.new("#{TEST_DIR}consistency.01.mp3")
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_tags
|
14
|
-
assert_equal('Track Title', @mp3.title)
|
15
|
-
assert_equal('Artist Name Here', @mp3.artist)
|
16
|
-
assert_equal('Album Artist Here', @mp3.album_artist)
|
17
|
-
assert_equal('Album Name Here', @mp3.album)
|
18
|
-
assert_equal('This is my comment.', @mp3.comment)
|
19
|
-
assert_equal('Polka', @mp3.genre)
|
20
|
-
assert_equal(1941, @mp3.year)
|
21
|
-
assert_equal([5, 0], @mp3.track_num)
|
22
|
-
assert_equal([3, 0], @mp3.disc_num)
|
23
|
-
assert_equal(false, @mp3.compilation?)
|
24
|
-
assert_equal(0, @mp3.bpm)
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_date
|
28
|
-
assert_equal(1941, @mp3.date.year)
|
29
|
-
assert_equal(12, @mp3.date.month)
|
30
|
-
assert_equal(7, @mp3.date.day)
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_album_art
|
34
|
-
assert_equal(2, @mp3.album_art.count)
|
35
|
-
|
36
|
-
sha1 = Digest::SHA1.hexdigest(@mp3.album_art[0].data)
|
37
|
-
assert_equal('this is the front cover', @mp3.album_art[0].desc)
|
38
|
-
assert_equal('Cover (front)', @mp3.album_art[0].type_s)
|
39
|
-
assert_equal('image/jpeg', @mp3.album_art[0].mime_type)
|
40
|
-
assert_equal(10, @mp3.album_art[0].width)
|
41
|
-
assert_equal(5, @mp3.album_art[0].height)
|
42
|
-
assert_equal('6555697ca1bf96117608bfb5a44c05cb622f88eb', sha1)
|
43
|
-
|
44
|
-
sha1 = Digest::SHA1.hexdigest(@mp3.album_art[1].data)
|
45
|
-
assert_equal('this is the artist', @mp3.album_art[1].desc)
|
46
|
-
assert_equal('Artist', @mp3.album_art[1].type_s)
|
47
|
-
assert_equal('image/png', @mp3.album_art[1].mime_type)
|
48
|
-
assert_equal(10, @mp3.album_art[1].width)
|
49
|
-
assert_equal(5, @mp3.album_art[1].height)
|
50
|
-
assert_equal('9db2996823fb44ed64dfc8f57dc9df3b970c6b22', sha1)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
class TestConsistency01 < Test::Unit::TestCase
|
55
|
-
def setup
|
56
|
-
@mp3 = EasyTag::File.new("#{TEST_DIR}consistency.01.mp3")
|
57
|
-
@mp4 = EasyTag::File.new("#{TEST_DIR}consistency.01.m4a")
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_tags
|
61
|
-
assert_equal(@mp3.title, @mp4.title)
|
62
|
-
assert_equal(@mp3.artist, @mp4.artist)
|
63
|
-
assert_equal(@mp3.album_artist, @mp4.album_artist)
|
64
|
-
assert_equal(@mp3.album, @mp4.album)
|
65
|
-
assert_equal(@mp3.comments, @mp4.comments)
|
66
|
-
assert_equal(@mp3.genre, @mp4.genre)
|
67
|
-
assert_equal(@mp3.year, @mp4.year)
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_date
|
71
|
-
# MP4 only supports year, so thats all we can test
|
72
|
-
assert_equal(@mp3.date.year, @mp4.date.year)
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_album_art
|
76
|
-
# we're limited to what we can compare here, since mp4 is so limited
|
77
|
-
img_mp3 = @mp3.album_art[0]
|
78
|
-
img_mp4 = @mp4.album_art[0]
|
79
|
-
assert_equal(img_mp3.mime_type, img_mp4.mime_type)
|
80
|
-
assert_equal(img_mp3.data, img_mp4.data)
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
84
|
-
|
85
|
-
class TestConsistencyMP302 < Test::Unit::TestCase
|
86
|
-
def setup
|
87
|
-
@mp3 = EasyTag::File.new("#{TEST_DIR}consistency.02.mp3")
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_tags
|
91
|
-
cases = [
|
92
|
-
['She Lives in My Lap', @mp3.title],
|
93
|
-
['', @mp3.title_sort_order],
|
94
|
-
['OutKast feat. Rosario Dawson', @mp3.artist],
|
95
|
-
['OutKast feat. Dawson, Rosario', @mp3.artist_sort_order],
|
96
|
-
['OutKast', @mp3.album_artist],
|
97
|
-
['', @mp3.album_artist_sort_order],
|
98
|
-
['Speakerboxxx / The Love Below', @mp3.album],
|
99
|
-
['', @mp3.album_sort_order],
|
100
|
-
[[], @mp3.comments],
|
101
|
-
['', @mp3.genre],
|
102
|
-
[2003, @mp3.year],
|
103
|
-
[[8, 21], @mp3.track_num],
|
104
|
-
[[2, 2], @mp3.disc_num],
|
105
|
-
['The Love Below', @mp3.disc_subtitle],
|
106
|
-
['CD', @mp3.media],
|
107
|
-
['Arista', @mp3.label],
|
108
|
-
[true, @mp3.compilation?],
|
109
|
-
[0, @mp3.bpm],
|
110
|
-
['B0000AGWFX', @mp3.asin],
|
111
|
-
]
|
112
|
-
|
113
|
-
cases.each do |c|
|
114
|
-
expected, actual = c
|
115
|
-
assert_equal(expected, actual)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
def test_date
|
120
|
-
assert_equal(2003, @mp3.date.year)
|
121
|
-
assert_equal(9, @mp3.date.month)
|
122
|
-
assert_equal(23, @mp3.date.day)
|
123
|
-
|
124
|
-
assert_equal(2003, @mp3.original_date.year)
|
125
|
-
assert_equal(9, @mp3.original_date.month)
|
126
|
-
assert_equal(23, @mp3.original_date.day)
|
127
|
-
end
|
128
|
-
|
129
|
-
def test_musicbrainz_data
|
130
|
-
cases = [
|
131
|
-
[['album'], @mp3.musicbrainz_album_type],
|
132
|
-
['73fdb566-a9b1-494c-9f32-51768ec9fd27',
|
133
|
-
@mp3.musicbrainz_album_artist_id],
|
134
|
-
[["73fdb566-a9b1-494c-9f32-51768ec9fd27",
|
135
|
-
"9facf8dc-df23-4561-85c5-ece75d692f21"], @mp3.musicbrainz_artist_id],
|
136
|
-
['468cd19e-d55c-46a2-a5a6-66292d2f0a90', @mp3.musicbrainz_album_id],
|
137
|
-
['fa64febd-61e0-346e-aaa2-04564ed4f0a3',
|
138
|
-
@mp3.musicbrainz_release_group_id],
|
139
|
-
['US', @mp3.musicbrainz_album_release_country],
|
140
|
-
['official', @mp3.musicbrainz_album_status],
|
141
|
-
]
|
142
|
-
|
143
|
-
cases.each do |c|
|
144
|
-
expected, actual = c
|
145
|
-
assert_equal(expected, actual)
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
def test_album_art
|
150
|
-
assert_equal(1, @mp3.album_art.count)
|
151
|
-
|
152
|
-
#sha1 = Digest::SHA1.hexdigest(@mp3.album_art[0].data)
|
153
|
-
#assert_equal('this is the front cover', @mp3.album_art[0].desc)
|
154
|
-
#assert_equal('Cover (front)', @mp3.album_art[0].type_s)
|
155
|
-
#assert_equal('image/jpeg', @mp3.album_art[0].mime_type)
|
156
|
-
#assert_equal(10, @mp3.album_art[0].width)
|
157
|
-
#assert_equal(5, @mp3.album_art[0].height)
|
158
|
-
#assert_equal('6555697ca1bf96117608bfb5a44c05cb622f88eb', sha1)
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
class TestConsistency02 < Test::Unit::TestCase
|
163
|
-
def setup
|
164
|
-
@mp3 = EasyTag::File.new("#{TEST_DIR}consistency.02.mp3")
|
165
|
-
@mp4 = EasyTag::File.new("#{TEST_DIR}consistency.02.m4a")
|
166
|
-
end
|
167
|
-
|
168
|
-
def test_tags
|
169
|
-
cases = [
|
170
|
-
:title,
|
171
|
-
:title_sort_order,
|
172
|
-
:artist,
|
173
|
-
:artist_sort_order,
|
174
|
-
#:album_artist_sort_order, # MP3 isn't working
|
175
|
-
:album,
|
176
|
-
:album_sort_order,
|
177
|
-
:comments,
|
178
|
-
:genre,
|
179
|
-
:year,
|
180
|
-
:track_num,
|
181
|
-
:disc_num,
|
182
|
-
:disc_subtitle,
|
183
|
-
:media,
|
184
|
-
:label,
|
185
|
-
:compilation?,
|
186
|
-
:bpm,
|
187
|
-
:asin,
|
188
|
-
:conductor,
|
189
|
-
:remixer,
|
190
|
-
:mood,
|
191
|
-
]
|
192
|
-
|
193
|
-
cases.each do |c|
|
194
|
-
#puts c
|
195
|
-
assert_equal(@mp3.send(c), @mp4.send(c))
|
196
|
-
end
|
197
|
-
|
198
|
-
end
|
199
|
-
|
200
|
-
def test_date
|
201
|
-
assert_equal(@mp3.date.year, @mp4.date.year)
|
202
|
-
assert_equal(@mp3.date.month, @mp4.date.month)
|
203
|
-
assert_equal(@mp3.date.day, @mp4.date.day)
|
204
|
-
end
|
205
|
-
|
206
|
-
def test_album_art
|
207
|
-
# we're limited to what we can compare here, since mp4 is so limited
|
208
|
-
img_mp3 = @mp3.album_art[0]
|
209
|
-
img_mp4 = @mp4.album_art[0]
|
210
|
-
assert_equal(img_mp3.mime_type, img_mp4.mime_type)
|
211
|
-
assert_equal(img_mp3.data, img_mp4.data)
|
212
|
-
end
|
213
|
-
|
214
|
-
def test_musicbrainz_data
|
215
|
-
cases = [
|
216
|
-
:musicbrainz_album_artist_id,
|
217
|
-
:musicbrainz_album_id,
|
218
|
-
:musicbrainz_album_release_country,
|
219
|
-
:musicbrainz_album_status,
|
220
|
-
:musicbrainz_album_type,
|
221
|
-
:musicbrainz_artist_id,
|
222
|
-
:musicbrainz_release_group_id,
|
223
|
-
:musicbrainz_track_id,
|
224
|
-
]
|
225
|
-
|
226
|
-
cases.each do |c|
|
227
|
-
#puts c
|
228
|
-
assert_equal(@mp3.send(c), @mp4.send(c))
|
229
|
-
end
|
230
|
-
end
|
231
|
-
|
232
|
-
end
|
233
|
-
|