blib/script/m4amp3.pl untested

filter: Statementstmt 0.0% 0 / 56 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 30 MC/DCmcdc 0.0% 0 / 13 Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 118 CC 3 SCAR 11.5
CC
3
Cov
0%
init
6.0
_argvfiles
6.0
usage
2.0
CRAP 3.1
1 #!/usr/local/bin/perl
2 use strict;
3 use vars qw($VERSION);
4 use Getopt::Std::Strict 'dhv';
5 use LEOCHARRE::Dir ':all';
6 use LEOCHARRE::DEBUG;
7 use Cwd;
8 use Carp;
9 $VERSION = sprintf "%d.%02d", q$Revision: 1.2 $ =~ /(\d+)/g;
10 use File::Which 'which';
11  
12 which($_) or die("missing $_?") for qw(faad lame);
13  
14 init();
15  
16  
17  
18 my @files = _argvfiles('m4a') or die("No files selected.");
19  
20  
21 for my $abs (@files){
22
23 my $abs_to = $abs;
24 $abs_to=~s/\.m4a/\.mp3/i or die;
25  
26 #`faad -o - "$abs" | lame - "$abs_to"`;
27  
28 `mplayer -ao pcm "$abs" -aofile "$abs.wav"`;
29 $? and die(" $abs $?");
30  
31 `lame -h -b 192 "$abs.wav" "$abs_to"`;
32 $? and die(" $abs $?");
33  
34 print "$abs_to\n";
35  
36
37  
38  
39 }
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50 exit;
51  
52  
53  
54 sub usage {
55 qq{$0 - convert m4a to mp3
56  
57 We seek id3 tags artist, song, and album to copy over to the mp3 version.
58  
59 OPTIONS
60  
61 -d debug on
62 -h help
63 -v version and exit
64  
65  
66 AUTHOR
67  
68 Leo Charre leocharre at cpan dot org
69  
70 SEE ALSO
71  
72  
73  
74 }}
75  
76 sub init {
77 $::DEBUG = 1 if $opt_d;
78 $opt_h and print usage() and exit;
79 $opt_v and print $VERSION and exit;
80  
81 }
82  
83  
84  
85 sub _argvfiles {
86 my($ext)= shift;
87  
88 my @got;
89  
90 require Cwd;
91 for (@ARGV){
92 my $abs = Cwd::abs_path($_) or next;
93 -f $abs or warn("not on disk $abs");
94 if ($ext){
95 $abs=~/\Q$ext\E$/ or warn("not '$ext', $abs") and next;
96 }
97 push @got, $abs;
98 }
99 @got or return;
100 my $c = scalar @got;
101 debug("Got @got");
102 return @got;
103  
104 }