In single server implementations for small Call Centers recordings might end up being stored in the same server.
I had modified the first step audio processing script AST_CRON_audio_1_move_VDonly.pl in the 2.0.5 stable series to separate recordings into diretories per day. I did some additional changes in the script so that it will treat file names as case sensitive. The original script does not differenciate between the extensions wav and WAV extension, whereas in Asterisk wav stands for slinear encapsulated in Windows WAV format and WAV stands for GSM encapsulated in Windows WAV format.
I was planning to send it to Matt first, but I had been postponing it, because I did not have the time to document the changes I made in the script.
I posting you a diff against the original script below...
- Code: Select all
--- AST_CRON_audio_1_move_VDonly.pl 2009-07-16 00:43:10.048906252 +0300
+++ AST_CRON_audio_1_move_VDonly_DirTree.pl 2009-07-16 00:43:44.516907222 +0300
@@ -1,6 +1,6 @@
#!/usr/bin/perl
#
-# AST_CRON_audio_1_move_VDonly.pl
+# AST_CRON_audio_1_move_VDonly_DirTree.pl
#
# This is a STEP-1 program in the audio archival process
#
@@ -32,6 +32,9 @@
# 80731-2253 - Changed size comparisons for more efficiency
#
+use File::Path;
+
+
### begin parsing run-time options ###
if (length($ARGV[0])>1)
{
@@ -171,19 +174,16 @@
$FILEsize2[$i] = (-s "$dir1/$FILES[$i]");
if ($DBX) {print "$FILES[$i] $FILEsize2[$i]\n\n";}
- if ( ($FILES[$i] !~ /out\.wav|out\.gsm|lost\+found/i) && ($FILEsize1[$i] eq $FILEsize2[$i]) && (length($FILES[$i]) > 4))
+ if ( ($FILES[$i] =~ /^(.*)-in\.(wav|gsm|WAV)$/) && ($FILEsize1[$i] eq $FILEsize2[$i]) && (length($FILES[$i]) > 4))
{
+ $root = $1;
+ $ext = $2;
$INfile = $FILES[$i];
- $OUTfile = $FILES[$i];
- $OUTfile =~ s/-in\.wav/-out.wav/gi;
- $OUTfile =~ s/-in\.gsm/-out.gsm/gi;
- $ALLfile = $FILES[$i];
- $ALLfile =~ s/-in\.wav/-all.wav/gi;
- $ALLfile =~ s/-in\.gsm/-all.gsm/gi;
- $SQLFILE = $FILES[$i];
- $SQLFILE =~ s/-in\.wav|-in\.gsm//gi;
+ $OUTfile = "$root-out.$ext";
+ $ALLfile = "$root-all.$ext";
+ $SQLFILE = $root;
- $stmtA = "select recording_id from recording_log where filename='$SQLFILE' order by recording_id desc LIMIT 1;";
+ $stmtA = "select recording_id,DATE_FORMAT(start_time,'%Y/%m/%d') from recording_log where filename='$SQLFILE' order by recording_id desc LIMIT 1;";
if($DBX){print STDERR "\n|$stmtA|\n";}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@@ -192,22 +192,29 @@
{
@aryA = $sthA->fetchrow_array;
$recording_id = "$aryA[0]";
+ $recording_dir = "$aryA[1]";
}
$sthA->finish();
if ($DB) {print "|$recording_id|$INfile| |$ALLfile|\n";}
+ $dst_dir = "$dir2/$recording_dir";
+
+ if( ! -d $dst_dir ) {
+ mkpath( $dst_dir, 0, 0755 ) or die "$0: Creation of directory $dstDir failed.\n";
+ }
+
if (!$T)
{
- `mv -f "$dir1/$INfile" "$dir2/$ALLfile"`;
+ `mv -f "$dir1/$INfile" "$dst_dir/$ALLfile"`;
`rm -f "$dir1/$OUTfile"`;
}
else
{
- `cp -f "$dir1/$INfile" "$dir2/$ALLfile"`;
+ `cp -f "$dir1/$INfile" "$dst_dir/$ALLfile"`;
}
- $stmtA = "UPDATE recording_log set location='http://$server_ip/RECORDINGS/$ALLfile' where recording_id='$recording_id';";
+ $stmtA = "UPDATE recording_log set location='http://$server_ip/RECORDINGS/$recording_dir/$ALLfile' where recording_id='$recording_id';";
if($DBX){print STDERR "\n|$stmtA|\n";}
$affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query:|$stmtA|\n";