| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::DAAP::Server::Track; |
|
2
|
2
|
|
|
2
|
|
13
|
use strict; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
54
|
|
|
3
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
45
|
|
|
4
|
2
|
|
|
2
|
|
9
|
use base qw( Class::Accessor::Fast ); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
1799
|
|
|
5
|
2
|
|
|
2
|
|
8510
|
use MP3::Info; |
|
|
2
|
|
|
|
|
73826
|
|
|
|
2
|
|
|
|
|
190
|
|
|
6
|
2
|
|
|
2
|
|
1545
|
use Perl6::Slurp; |
|
|
2
|
|
|
|
|
3275
|
|
|
|
2
|
|
|
|
|
12
|
|
|
7
|
2
|
|
|
2
|
|
73
|
use File::Basename qw(basename); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
1144
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw( |
|
10
|
|
|
|
|
|
|
file |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
dmap_itemid dmap_itemname dmap_itemkind dmap_persistentid |
|
13
|
|
|
|
|
|
|
daap_songalbum daap_songartist daap_songbitrate |
|
14
|
|
|
|
|
|
|
daap_songbeatsperminute daap_songcomment daap_songcompilation |
|
15
|
|
|
|
|
|
|
daap_songcomposer daap_songdateadded daap_songdatemodified |
|
16
|
|
|
|
|
|
|
daap_songdisccount daap_songdiscnumber daap_songdisabled |
|
17
|
|
|
|
|
|
|
daap_songeqpreset daap_songformat daap_songgenre |
|
18
|
|
|
|
|
|
|
daap_songdescription daap_songrelativevolume daap_songsamplerate |
|
19
|
|
|
|
|
|
|
daap_songsize daap_songstarttime daap_songstoptime daap_songtime |
|
20
|
|
|
|
|
|
|
daap_songtrackcount daap_songtracknumber daap_songuserrating |
|
21
|
|
|
|
|
|
|
daap_songyear daap_songdatakind daap_songdataurl |
|
22
|
|
|
|
|
|
|
com_apple_itunes_norm_volume |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
daap_songgrouping daap_songcodectype daap_songcodecsubtype |
|
25
|
|
|
|
|
|
|
com_apple_itunes_itms_songid com_apple_itunes_itms_artistid |
|
26
|
|
|
|
|
|
|
com_apple_itunes_itms_playlistid com_apple_itunes_itms_composerid |
|
27
|
|
|
|
|
|
|
com_apple_itunes_itms_genreid |
|
28
|
|
|
|
|
|
|
dmap_containeritemid |
|
29
|
|
|
|
|
|
|
)); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub new_from_file { |
|
32
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
|
33
|
0
|
|
|
|
|
|
my $file = shift; |
|
34
|
0
|
|
|
|
|
|
my $self = $class->new({ file => $file }); |
|
35
|
0
|
|
|
|
|
|
print "Adding $file\n"; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my @stat = stat $file; |
|
39
|
0
|
|
|
|
|
|
$self->dmap_itemid( $stat[1] ); # the inode should be good enough |
|
40
|
0
|
|
|
|
|
|
$self->dmap_containeritemid( 0+$self ); |
|
41
|
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
$self->dmap_itemkind( 2 ); # music |
|
43
|
0
|
|
|
|
|
|
$self->dmap_persistentid( $stat[1] ); # blah, this should be some 64 bit thing |
|
44
|
0
|
|
|
|
|
|
$self->daap_songbeatsperminute( 0 ); |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# All mp3 files have 'info'. If it doesn't, give up, we can't read it. |
|
47
|
0
|
0
|
|
|
|
|
my $info = MP3::Info::get_mp3info($file) or return; |
|
48
|
0
|
|
|
|
|
|
$self->daap_songbitrate( $info->{BITRATE} ); |
|
49
|
0
|
|
|
|
|
|
$self->daap_songsamplerate( $info->{FREQUENCY} * 1000 ); |
|
50
|
0
|
|
|
|
|
|
$self->daap_songtime( $info->{SECS} * 1000 ); |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# read the tag if we can, fall back to very simple data otherwise. |
|
53
|
0
|
|
0
|
|
|
|
my $tag = MP3::Info::get_mp3tag( $file ) || {}; |
|
54
|
0
|
|
0
|
|
|
|
$self->dmap_itemname( $tag->{TITLE} || basename($file, ".mp3") ); |
|
55
|
0
|
|
|
|
|
|
$self->daap_songalbum( $tag->{ALBUM} ); |
|
56
|
0
|
|
|
|
|
|
$self->daap_songartist( $tag->{ARTIST} ); |
|
57
|
0
|
|
|
|
|
|
$self->daap_songcomment( $tag->{COMMENT} ); |
|
58
|
0
|
|
0
|
|
|
|
$self->daap_songyear( $tag->{YEAR} || undef ); |
|
59
|
0
|
|
0
|
|
|
|
my ($number, $count) = split m{/}, ($tag->{TRACKNUM} || ""); |
|
60
|
0
|
|
0
|
|
|
|
$self->daap_songtrackcount( $count || 0); |
|
61
|
0
|
|
0
|
|
|
|
$self->daap_songtracknumber( $number || 0 ); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# from blech: |
|
64
|
|
|
|
|
|
|
# if ($rtag->{TCP} || $rtag->{TCMP}) { |
|
65
|
|
|
|
|
|
|
# $artist = 'various artists'; |
|
66
|
|
|
|
|
|
|
# } |
|
67
|
|
|
|
|
|
|
# |
|
68
|
0
|
|
|
|
|
|
$self->daap_songcompilation( 0 ); |
|
69
|
|
|
|
|
|
|
# $self->daap_songcomposer( ); |
|
70
|
0
|
|
|
|
|
|
$self->daap_songdateadded( $stat[10] ); |
|
71
|
0
|
|
|
|
|
|
$self->daap_songdatemodified( $stat[9] ); |
|
72
|
0
|
|
|
|
|
|
$self->daap_songdisccount( 0 ); |
|
73
|
0
|
|
|
|
|
|
$self->daap_songdiscnumber( 0 ); |
|
74
|
0
|
|
|
|
|
|
$self->daap_songdisabled( 0 ); |
|
75
|
0
|
|
|
|
|
|
$self->daap_songeqpreset( '' ); |
|
76
|
0
|
|
|
|
|
|
$file =~ m{\.(.*?)$}; |
|
77
|
0
|
|
|
|
|
|
$self->daap_songformat( $1 ); |
|
78
|
0
|
|
|
|
|
|
$self->daap_songgenre( '' ); |
|
79
|
0
|
|
|
|
|
|
$self->daap_songgrouping( '' ); |
|
80
|
|
|
|
|
|
|
# $self->daap_songdescription( ); |
|
81
|
|
|
|
|
|
|
# $self->daap_songrelativevolume( ); |
|
82
|
0
|
|
|
|
|
|
$self->daap_songsize( -s $file ); |
|
83
|
0
|
|
|
|
|
|
$self->daap_songstarttime( 0 ); |
|
84
|
0
|
|
|
|
|
|
$self->daap_songstoptime( 0 ); |
|
85
|
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
$self->daap_songuserrating( 0 ); |
|
87
|
0
|
|
|
|
|
|
$self->daap_songdatakind( 0 ); |
|
88
|
|
|
|
|
|
|
# $self->daap_songdataurl( ); |
|
89
|
0
|
|
|
|
|
|
$self->com_apple_itunes_norm_volume( 17502 ); |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# $self->daap_songcodectype( 1836082535 ); # mp3? |
|
92
|
|
|
|
|
|
|
# $self->daap_songcodecsubtype( 3 ); # or is this mp3? |
|
93
|
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
return $self; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub data { |
|
98
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
99
|
0
|
|
|
|
|
|
scalar slurp $self->file; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|