diff options
author | Matteo Brancaleoni <mbrancaleoni@espia.it> | 2003-02-14 06:00:11 +0000 |
---|---|---|
committer | Matteo Brancaleoni <mbrancaleoni@espia.it> | 2003-02-14 06:00:11 +0000 |
commit | 06fde4bfafaff33006359fb9e0ea965b0236e7af (patch) | |
tree | 4d5b29650be4cacf2c29710581941f0e84cfd431 /agi/numeralize | |
parent | 52a7b81e248f05d6c1e87d2d9260f04632e3b3d7 (diff) |
Fri Feb 14 07:00:01 CET 2003
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@614 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'agi/numeralize')
-rwxr-xr-x | agi/numeralize | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/agi/numeralize b/agi/numeralize new file mode 100755 index 000000000..5ca51913d --- /dev/null +++ b/agi/numeralize @@ -0,0 +1,44 @@ +#!/usr/bin/perl +# +# Build a database linking filenames to their numerical representations +# using a keypad for the DialAnMp3 application +# + +$mp3dir="/usr/media/mpeg3"; + +dbmopen(%DIGITS, "/var/lib/asterisk/mp3list", 0644) || die("Unable to open mp3list");; +sub process_dir { + my ($dir) = @_; + my $file; + my $digits; + my @entries; + opendir(DIR, $dir); + @entries = readdir(DIR); + closedir(DIR); + foreach $_ (@entries) { + if (!/^\./) { + $file = "$dir/$_"; + if (-d "$file") { + process_dir("$file"); + } else { + $digits = $_; + $digits =~ s/[^ \w]+//g; + $digits =~ s/\_/ /g; + $digits =~ tr/[a-z]/[A-Z]/; + $digits =~ tr/[A-C]/2/; + $digits =~ tr/[D-F]/3/; + $digits =~ tr/[G-I]/4/; + $digits =~ tr/[J-L]/5/; + $digits =~ tr/[M-O]/6/; + $digits =~ tr/[P-S]/7/; + $digits =~ tr/[T-V]/8/; + $digits =~ tr/[W-Z]/9/; + $digits =~ s/\s+/ /; + print "File: $file, digits: $digits\n"; + $DIGITS{$file} = $digits; + } + } + } +} + +process_dir($mp3dir); |