| 1 | package Net::DAAP::Server::Track; | ||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 2 | ▶ | use base qw( Class::Accessor::Fast ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 2 | ▶ | use MP3::Info; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 2 | ▶ | use Perl6::Slurp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 2 | ▶ | use File::Basename qw(basename); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 2 | __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 | 0 | ▶ | sub new_from_file { | ||||||||||||||||||
|
Subroutine
new_from_file: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||
| 32 | 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 | ▶ | my $info = MP3::Info::get_mp3info($file) or return; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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 | ▶ | my $tag = MP3::Info::get_mp3tag( $file ) || {}; | ||||||||||||||||||
|
Condition0%0/2
MP3::Info::get_mp3tag($file) || {}
MC/DC0%0/1
MP3::Info::get_mp3tag($file) || {}
MP3::Info::get_mp3tag($file)
Truth table0%0/2
A
A= MP3::Info::get_mp3tag($file)
| |||||||||||||||||||||
| 54 | 0 | ▶ | $self->dmap_itemname( $tag->{TITLE} || basename($file, ".mp3") ); | ||||||||||||||||||
|
Condition0%0/3
$tag->{'TITLE'} || basename($file, '.mp3')
MC/DC0%0/2
$tag->{'TITLE'} || basename($file, '.mp3')
$tag->{'TITLE'}
basename($file, '.mp3')
Truth table0%0/3
A || B
A= $tag->{'TITLE'}B= 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 | ▶ | $self->daap_songyear( $tag->{YEAR} || undef ); | ||||||||||||||||||
|
Condition0%0/2
$tag->{'YEAR'} || undef
MC/DC0%0/1
$tag->{'YEAR'} || undef
$tag->{'YEAR'}
Truth table0%0/2
A
A= $tag->{'YEAR'}
| |||||||||||||||||||||
| 59 | 0 | ▶ | my ($number, $count) = split m{/}, ($tag->{TRACKNUM} || ""); | ||||||||||||||||||
|
Condition0%0/2
$tag->{'TRACKNUM'} || ''
MC/DC0%0/1
$tag->{'TRACKNUM'} || ''
$tag->{'TRACKNUM'}
Truth table0%0/2
A
A= $tag->{'TRACKNUM'}
| |||||||||||||||||||||
| 60 | 0 | ▶ | $self->daap_songtrackcount( $count || 0); | ||||||||||||||||||
|
Condition0%0/2
$count || 0
MC/DC0%0/1
$count || 0
$count
Truth table0%0/2
A
A= $count
| |||||||||||||||||||||
| 61 | 0 | ▶ | $self->daap_songtracknumber( $number || 0 ); | ||||||||||||||||||
|
Condition0%0/2
$number || 0
MC/DC0%0/1
$number || 0
$number
Truth table0%0/2
A
A= $number
| |||||||||||||||||||||
| 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 | 0 | ▶ | sub data { | ||||||||||||||||||
|
Subroutine
data: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 98 | 0 | my $self = shift; | |||||||||||||||||||
| 99 | 0 | scalar slurp $self->file; | |||||||||||||||||||
| 100 | } | ||||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | 2 | 1; | |||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | |||||||||||||||||||||