|
0 |
Description: Use Audio::Scan instead of MP3::Info.
|
|
1 |
Forwarded: yes
|
|
2 |
Author: Peter Pentchev <roam@ringlet.net>
|
|
3 |
Last-Updated: 2021-12-31
|
|
4 |
|
|
5 |
--- a/t/02-mp3-info.t
|
|
6 |
+++ b/t/02-mp3-info.t
|
|
7 |
@@ -19,7 +19,7 @@
|
|
8 |
use Test::More;
|
|
9 |
|
|
10 |
my $have_mp3_info = 1;
|
|
11 |
-eval "use MP3::Info;";
|
|
12 |
+eval "use Audio::Scan;";
|
|
13 |
if ($@) {
|
|
14 |
$have_mp3_info = 0;
|
|
15 |
}
|
|
16 |
@@ -36,6 +36,15 @@
|
|
17 |
)
|
|
18 |
$}x;
|
|
19 |
|
|
20 |
+my %XLAT = (
|
|
21 |
+ COMM => 'Comment',
|
|
22 |
+ TALB => 'Album',
|
|
23 |
+ TCON => 'Genre',
|
|
24 |
+ TDRC => 'Year',
|
|
25 |
+ TIT2 => 'Title',
|
|
26 |
+ TPE1 => 'Artist',
|
|
27 |
+);
|
|
28 |
+
|
|
29 |
sub extract_file_tag_stripped($)
|
|
30 |
{
|
|
31 |
my ($lines) = @_;
|
|
32 |
@@ -77,7 +86,7 @@
|
|
33 |
BAIL_OUT "Not an executable file: $PROG" unless -f $PROG && -x $PROG;
|
|
34 |
|
|
35 |
SKIP: {
|
|
36 |
- skip 'no MP3::Info module', 2 unless $have_mp3_info;
|
|
37 |
+ skip 'no Audio::Scan module', 2 unless $have_mp3_info;
|
|
38 |
|
|
39 |
my $orig = path($ENV{TEST_ID3_MEOW} //
|
|
40 |
'/usr/share/doc/libvideo-info-perl/examples/meow.mp3.gz');
|
|
41 |
@@ -98,11 +107,11 @@
|
|
42 |
}
|
|
43 |
BAIL_OUT "Could not create $fdata" unless $fdata->is_file;
|
|
44 |
|
|
45 |
- my $exp = MP3::Info->new("$fdata");
|
|
46 |
- is $exp->FILE, "$fdata", "MP3::Info parsed $fdata";
|
|
47 |
+ my $exp = Audio::Scan->scan_tags("$fdata");
|
|
48 |
+ ok exists $exp->{tags}, "Audio::Scan parsed $fdata";
|
|
49 |
|
|
50 |
subtest 'List (RFC-822) the tag' => sub {
|
|
51 |
- plan tests => 5;
|
|
52 |
+ plan tests => 6;
|
|
53 |
|
|
54 |
my $cmd = [$PROG, '-l', '-R', '--', $fdata];
|
|
55 |
my $tcmd = Test::Command->new(cmd => $cmd);
|
|
56 |
@@ -113,21 +122,32 @@
|
|
57 |
|
|
58 |
my $tag = extract_file_tag_stripped \@lines;
|
|
59 |
ok scalar keys %{$tag} >= 5, '-l -R output at least five tags';
|
|
60 |
+ if (exists $tag->{Genre}) {
|
|
61 |
+ my $value = (split / [(]/, $tag->{Genre})[0];
|
|
62 |
+ $value = '' if $value eq 'Unknown';
|
|
63 |
+ $tag->{Genre} = $value;
|
|
64 |
+ }
|
|
65 |
|
|
66 |
subtest 'compare the keys' => sub {
|
|
67 |
- plan tests => scalar keys %{$tag};
|
|
68 |
+ plan tests => scalar keys %{$exp->{tags}};
|
|
69 |
|
|
70 |
- for my $key (sort keys %{$tag}) {
|
|
71 |
- my $value = $tag->{$key};
|
|
72 |
- my $upper = uc $key;
|
|
73 |
- if ($key eq 'Filename') {
|
|
74 |
- $upper = 'FILE';
|
|
75 |
- } elsif ($key eq 'Genre') {
|
|
76 |
- $value = (split / [(]/, $value)[0];
|
|
77 |
- $value = '' if $value eq 'Unknown';
|
|
78 |
+ for my $key (sort keys %{$exp->{tags}}) {
|
|
79 |
+ my $expected = $exp->{tags}->{$key};
|
|
80 |
+ if ($key eq 'COMM') {
|
|
81 |
+ # Let's hope this works...
|
|
82 |
+ $expected = $expected->[$#{$expected}];
|
|
83 |
+ }
|
|
84 |
+ my $xlat = $XLAT{$key};
|
|
85 |
+ if (!defined $xlat) {
|
|
86 |
+ die "Unhandled '$key': '$expected'";
|
|
87 |
}
|
|
88 |
- is $value, $exp->{$upper}, "compare $key";
|
|
89 |
+ is $tag->{$xlat}, $expected, "compare $key ($xlat)";
|
|
90 |
+ delete $tag->{$xlat};
|
|
91 |
}
|
|
92 |
};
|
|
93 |
+ my $leftover = join ' ',
|
|
94 |
+ grep $_ ne 'Filename' && $tag->{$_} ne '',
|
|
95 |
+ keys %{$tag};
|
|
96 |
+ is $leftover, '', 'only empty keys left in the id3 output';
|
|
97 |
};
|
|
98 |
}
|