Audio/Soundconverter.pm

filter: Statementstmt 100% 9 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 12 / 12 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Api/Virustotal.pm ↑ Summary Audit/Dns.pm »
1 #
2 # $Id$
3 #
4 # audio::soundconverter Brik
5 #
6 package Metabrik::Audio::Soundconverter;
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use base qw(Metabrik::Shell::Command Metabrik::System::Package);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub brik_properties {
13 return {
14 revision => '$Revision$',
15 tags => [ qw(unstable) ],
16 author => 'GomoR <GomoR[at]metabrik.org>',
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 my $self = shift;
40 my ($file, $format) = @_;
41  
42 $format ||= $self->format;
43 $self->brik_help_run_undef_arg('convert', $file) or return;
44  
45 $format = lc($format);
46 if ($format ne 'ogg' && $format ne 'wav' && $format ne 'mp3' && $format ne 'flac') {
47 return $self->log->error("convert: invalid value for format [$format]");
48 }
49  
50 $self->log->info("convert: to format [$format]");
51  
52 my %h = (
53 ogg => 'audio/x-vorbis',
54 flac => 'audio/x-flac',
55 wav => 'audio/x-wav',
56 mp3 => 'audio/mpeg',
57 );
58 my $ext = $format;
59 my $mime = $h{$format};
60  
61 my $cmd = "soundconverter -b -m $mime -s .$ext $file";
62  
63 return $self->execute($cmd);
64 }
65  
66 1;
67  
68 __END__
« Api/Virustotal.pm ↑ Summary Audit/Dns.pm »