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
|
|
505
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use base qw(Metabrik::Shell::Command Metabrik::System::Package); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
796
|
|
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__ |