-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTimes
executable file
·57 lines (52 loc) · 1.23 KB
/
Times
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/perl
use MP3::Info;
use MP3::Tag;
use Audio::FLAC::Header;
my $totalTime = 0;
while (<*.mp3>)
{
$tag = get_mp3tag($_);
$info = get_mp3info ($_);
($min, $sec) = split(/:/, $info->{TIME});
$totalTime += (($min * 60) + $sec);
if ($tag)
{
$trnum = sprintf("%02d", $tag->{TRACKNUM});
print "$trnum $tag->{TITLE}: $info->{TIME}\n";
}
}
while (<*.flac>)
{
my $flac = Audio::FLAC::Header->new($_);
my $tags = $flac->tags();
$info = $flac->info();
$min = $flac->{trackLengthMinutes};
$sec = sprintf("%02d", $flac->{trackLengthSeconds});
$totalTime += (($min * 60) + $flac->{trackLengthSeconds});
if ($tags)
{
$trnum = sprintf("%02d", $tags->{TRACKNUMBER});
print "$trnum $tags->{TITLE}: ${min}:${sec}\n";
}
}
if ($totalTime != 0)
{
$min = int($totalTime / 60);
$sec = sprintf("%02d", $totalTime - ($min * 60));
$hrs = int($totalTime / 3600);
$minstr = $min . ":" . $sec;
$tstr = "";
if ($hrs > 0)
{
$min -= ($hrs * 60);
$min = sprintf("%02d", $min);
$tstr = $hrs . ":";
}
$tstr .= $min . ":" . $sec;
print "\nTotal time: ${tstr}";
if ($hrs > 0)
{
print " (${minstr})";
}
print "\n";
}