lib/URI/Title/MP3.pm

filter: Statementstmt 34.0% 15 / 44 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 10 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 71.4% 5 / 7 Podpod 0.0% 0 / 2 totaltotal 24.1% 20 / 83 SCAR 43.8
CC
12
Cov
22%
title
110.0
_get_tag
12.0
BEGIN
1.0
CRAP 80.2
« lib/URI/Title.pm ↑ Summary lib/URI/Title/PDF.pm »
1 package URI::Title::MP3;
2 3 $URI::Title::MP3::VERSION = '1.902';
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use MP3::Info;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use File::Temp qw(tempfile);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 sub types {(
10 2 ▶ 'audio/mp3',
Subroutine types: called CC=1 SCAR=0.0
Pod undocumented
11 )}
12  
13 sub _get_tag {
14 0 ▶ my $data = shift;
Subroutine _get_tag: not called CC=3 SCAR=24.8
15 0 my (undef, $temp) = tempfile();
16 0 ▶ open FILE, ">$temp" or die $!;
Branch: 1 branch
BranchTrueFalseTotal
open FILE, ">$temp" or die $! 0 0 0
17 0 print FILE $data;
18 0 close FILE;
19 0 my $tag = get_mp3tag($temp);
20 0 ▶ if ($tag) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag) 0 0 0
21 0 my $info = get_mp3info($temp);
22 0 $tag->{info} = $info;
23 }
24 0 unlink($temp);
25 0 return $tag;
26 }
27  
28 sub title {
29 0 ▶ my ($class, $url, $data, $type) = @_;
Subroutine title: not called CC=10 SCAR=47.0
Pod undocumented
30 0 my $tag;
31 0 ▶ if (-f $url) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $url) { } 0 0 0
32 0 $tag = get_mp3tag($url);
33 0 ▶ if ($tag) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag) 0 0 0
34 0 my $info = get_mp3info($url);
35 0 $tag->{info} = $info;
36 }
37  
38 } else {
39 0 $tag = _get_tag( $data . URI::Title::_get_end($url) );
40 }
41 0 ▶ return unless $tag;
Branch: 1 branch
BranchTrueFalseTotal
unless $tag 0 0 0
42 0 ▶ return unless ($tag->{ARTIST} or $tag->{TITLE});
Branch: 1 branch
BranchTrueFalseTotal
unless $tag->{"ARTIST"} or $tag->{"TITLE"} 0 0 0
Condition0%0/3
$tag->{"ARTIST"} or $tag->{"TITLE"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$tag->{"ARTIST"} or $tag->{"TITLE"}
$tag->{"ARTIST"} $tag->{"TITLE"}
Truth table0%0/3
A or B
A= $tag->{"ARTIST"}B= $tag->{"TITLE"}
ABresult
1X1
011
000
43
44 0 ▶ $tag->{ARTIST} ||= "Unknown Artist";
Condition0%0/2
$tag->{"ARTIST"} ||= "Unknown Artist"
l!l
00
MC/DC0%0/1
$tag->{"ARTIST"} ||= "Unknown Artist"
$tag->{"ARTIST"}
Truth table0%0/2
A
A= $tag->{"ARTIST"}
Aresult
11
00
45 0 ▶ $tag->{TITLE} ||= "Unknown Title";
Condition0%0/2
$tag->{"TITLE"} ||= "Unknown Title"
l!l
00
MC/DC0%0/1
$tag->{"TITLE"} ||= "Unknown Title"
$tag->{"TITLE"}
Truth table0%0/2
A
A= $tag->{"TITLE"}
Aresult
11
00
46 0 my $title = "$tag->{ARTIST} - $tag->{TITLE}";
47  
48 0 ▶ if (my $total = $tag->{info}{SECS} and -f $url) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $total = $tag->{"info"}{"SECS"} and -f $url) 0 0 0
Condition0%0/3
my $total = $tag->{"info"}{"SECS"} and -f $url
!ll&&!rl&&r
000
MC/DC0%0/2
my $total = $tag->{"info"}{"SECS"} and -f $url
my $total = $tag->{"info"}{"SECS"} -f $url
Truth table0%0/3
A and B
A= my $total = $tag->{"info"}{"SECS"}B= -f $url
ABresult
0X0
100
111
49 0 my $m = $total / 60;
50 0 my $s = $total % 60;
51 0 $title .= sprintf(" (%d:%02d)", $m, $s);
52 }
53  
54 0 return $title;
55 }
56  
57 3 1;
58  
59 __END__
« lib/URI/Title.pm ↑ Summary lib/URI/Title/PDF.pm »