File Coverage

blib/lib/Metabrik/Audio/Soundconverter.pm
Criterion Covered Total %
statement 9 23 39.1
branch 0 4 0.0
condition 0 12 0.0
subroutine 3 5 60.0
pod 1 2 50.0
total 13 46 28.2


line stmt bran cond sub pod time code
1             #
2             # $Id$
3             #
4             # audio::soundconverter Brik
5             #
6             package Metabrik::Audio::Soundconverter;
7 1     1   520 use strict;
  1         2  
  1         31  
8 1     1   5 use warnings;
  1         2  
  1         34  
9              
10 1     1   5 use base qw(Metabrik::Shell::Command Metabrik::System::Package);
  1         2  
  1         421  
11              
12             sub brik_properties {
13             return {
14 0     0 1   revision => '$Revision$',
15             tags => [ qw(unstable) ],
16             author => 'GomoR ',
17             license => 'http://opensource.org/licenses/BSD-3-Clause',
18             attributes => {
19             format => [ qw(flac|mp3|ogg|wav) ],
20             },
21             attributes_default => {
22             format => 'wav',
23             },
24             commands => {
25             convert => [ qw(file) ],
26             },
27             require_binaries => {
28             soundconverter => [ ],
29             },
30             need_packages => {
31             ubuntu => [ qw(soundconverter) ],
32             debian => [ qw(soundconverter) ],
33             kali => [ qw(soundconverter) ],
34             },
35             };
36             }
37              
38             sub convert {
39 0     0 0   my $self = shift;
40 0           my ($file, $format) = @_;
41              
42 0   0       $format ||= $self->format;
43 0 0         $self->brik_help_run_undef_arg('convert', $file) or return;
44              
45 0           $format = lc($format);
46 0 0 0       if ($format ne 'ogg' && $format ne 'wav' && $format ne 'mp3' && $format ne 'flac') {
      0        
      0        
47 0           return $self->log->error("convert: invalid value for format [$format]");
48             }
49              
50 0           $self->log->info("convert: to format [$format]");
51              
52 0           my %h = (
53             ogg => 'audio/x-vorbis',
54             flac => 'audio/x-flac',
55             wav => 'audio/x-wav',
56             mp3 => 'audio/mpeg',
57             );
58 0           my $ext = $format;
59 0           my $mime = $h{$format};
60              
61 0           my $cmd = "soundconverter -b -m $mime -s .$ext $file";
62              
63 0           return $self->execute($cmd);
64             }
65              
66             1;
67              
68             __END__