line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MP3::Album::Track; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7795
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
50
|
|
4
|
1
|
|
|
1
|
|
626
|
use MP3::Info qw(:all); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use Data::Dumper; |
6
|
|
|
|
|
|
|
use File::Copy; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
|
|
|
|
|
|
my $c = shift; |
10
|
|
|
|
|
|
|
my %a = @_; |
11
|
|
|
|
|
|
|
my $b = {}; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
unless ($a{filename}) { |
14
|
|
|
|
|
|
|
$@ = "missing parameter filename"; |
15
|
|
|
|
|
|
|
return undef; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $s = bless $b, $c; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
$s->{info} = MP3::Info->new("$a{filename}"); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
unless ($s->{info}) { |
23
|
|
|
|
|
|
|
$@ = "$a{filename} does not apear to be a valid mp3"; |
24
|
|
|
|
|
|
|
return undef; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
$s->{filename} = $a{filename}; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
return $s; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub filename { my $s = shift; return $s->{filename} } |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub bitrate { |
35
|
|
|
|
|
|
|
my $s = shift; |
36
|
|
|
|
|
|
|
return $s->{info}->{BITRATE}; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub frequency { |
40
|
|
|
|
|
|
|
my $s = shift; |
41
|
|
|
|
|
|
|
return $s->{info}->{FREQUENCY}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub set_tag { |
45
|
|
|
|
|
|
|
my $s = shift; |
46
|
|
|
|
|
|
|
my %a = @_; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$a{title} |= ''; |
49
|
|
|
|
|
|
|
$a{artist} |= ''; |
50
|
|
|
|
|
|
|
$a{album} |= ''; |
51
|
|
|
|
|
|
|
$a{year} |= ''; |
52
|
|
|
|
|
|
|
$a{comment}|= ''; |
53
|
|
|
|
|
|
|
$a{genre} |= ''; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $rs; |
56
|
|
|
|
|
|
|
eval { |
57
|
|
|
|
|
|
|
$rs = set_mp3tag($s->{filename}, $a{title}, $a{artist}, $a{album}, $a{year}, $a{comment}, $a{genre}, $a{track_number}); |
58
|
|
|
|
|
|
|
}; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$s->{info} = MP3::Info->new($s->{filename}); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
return $rs; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub rename { |
66
|
|
|
|
|
|
|
my $s = shift; |
67
|
|
|
|
|
|
|
my %a = @_; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
$a{keep_copy} |= 0; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
unless ($a{filename}) { |
72
|
|
|
|
|
|
|
$@ = "missing param filename"; |
73
|
|
|
|
|
|
|
return undef; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my $r; |
77
|
|
|
|
|
|
|
if ( $a{keep_copy} ) { |
78
|
|
|
|
|
|
|
$r = copy($s->{filename}, $a{filename}); |
79
|
|
|
|
|
|
|
} else { |
80
|
|
|
|
|
|
|
$r = move($s->{filename}, $a{filename}); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
if (!$r) { $@ = "$!"; return undef} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
$s->{filename} = $a{filename}; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
return 1; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |