config: add audio-upload-hooks
Hooks can be used to automate the process of updating database columns when new audio files are uploaded. A hook command reads the path of an audio file and output a list of database columns to be updated with their respective values. Currently, the only supported database tables are calcms_events and calcms_audio_recordings. Some examples are included
This commit is contained in:
29
tools/audio-upload-hooks/set-loudness-duration.pl
Executable file
29
tools/audio-upload-hooks/set-loudness-duration.pl
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/perl
|
||||
use warnings;
|
||||
use strict;
|
||||
use Symbol 'gensym';
|
||||
use IPC::Open3 qw(open3);
|
||||
$| = 1;
|
||||
|
||||
# measure duration and rms
|
||||
# requires sox and libsox-fmt-all
|
||||
|
||||
die unless $ARGV[0];
|
||||
my $pid
|
||||
= open3(undef, undef, my $err = gensym(), "sox", $ARGV[0], "-n", "stats");
|
||||
|
||||
while (defined(my $line = <$err>)) {
|
||||
my @fields = split /\s+/, $line;
|
||||
if ($line =~ /^RMS lev dB/) {
|
||||
print "calcms_audio_recordings.rmsLeft = "
|
||||
. int($fields[3] + 0.5) . "\n";
|
||||
print "calcms_audio_recordings.rmsRight = "
|
||||
. int($fields[4] + 0.5) . "\n";
|
||||
} elsif ($line =~ /^Length\ss/) {
|
||||
print "calcms_audio_recordings.audioDuration = "
|
||||
. int($fields[2] + 0.5)
|
||||
. "\n";
|
||||
}
|
||||
}
|
||||
waitpid($pid, 0);
|
||||
die if $?;
|
||||
3
tools/audio-upload-hooks/set-podcast-url.sh
Executable file
3
tools/audio-upload-hooks/set-podcast-url.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
echo "calcms_events.podcast_url = http://podcasts.org/files/$1"
|
||||
|
||||
2
tools/audio-upload-hooks/set-size.sh
Executable file
2
tools/audio-upload-hooks/set-size.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
echo "calcms_audio_recordings.size = $(du -b $1 | cut -f1)"
|
||||
Reference in New Issue
Block a user