summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/audiorecorder.conf12
-rwxr-xr-xcontrib/postproc.pl144
-rwxr-xr-xcontrib/set_path35
3 files changed, 191 insertions, 0 deletions
diff --git a/contrib/audiorecorder.conf b/contrib/audiorecorder.conf
new file mode 100644
index 0000000..548fe26
--- /dev/null
+++ b/contrib/audiorecorder.conf
@@ -0,0 +1,12 @@
+S19.2E-1-1093-28406 /* DAS MODUL */
+S19.2E-1-1093-28475 /* Eins Live */
+S19.2E-1-1093-28476 /* WDR 2 */
+S19.2E-1-1093-28468 /* SWR 3 */
+S19.2E-1-1093-28423 /* YOU FM */
+S19.2E-1-1093-28450 /* Bremen Vier */
+S19.2E-1-1093-28402 /* Bayern 3 */
+S19.2E-1-1093-28437 /* NDR 2 */
+S19.2E-1-1093-28440 /* N-JOY */
+S19.2E-1-1093-28420 /* hr2 */
+S19.2E-1-1093-28421 /* hr3 */
+S19.2E-1-1093-28419 /* hr1 */
diff --git a/contrib/postproc.pl b/contrib/postproc.pl
new file mode 100755
index 0000000..eefbd32
--- /dev/null
+++ b/contrib/postproc.pl
@@ -0,0 +1,144 @@
+#!/usr/bin/perl
+use strict;
+
+use File::Basename;
+
+my $LOGGER = "/usr/bin/logger -t " . basename(__FILE__);
+my $mydir = dirname(__FILE__);
+
+# write into logfile for debugging purpose
+my $logfile;
+$logfile= $mydir . '/' . basename(__FILE__, '.pl') . '.log';
+
+# function to write into syslog
+sub Log
+{
+ system("$LOGGER '[audiorecorder]: @_'");
+ print LOGFILE "# @_\n" if (defined($logfile));
+}
+
+if (defined($logfile)) {
+ # open file for debug
+ open(LOGFILE, ">> " . $logfile)
+ or die "Fehler beim Öffnen von '$logfile': $!\n";
+ print LOGFILE "=========================== ". localtime() . "\n";
+ print LOGFILE 'ARGV[0] = ' . $ARGV[0] . "\n";
+ print LOGFILE 'ARGV[1] = ' . $ARGV[1] . "\n";
+ print LOGFILE 'ARGV[2] = ' . $ARGV[2] . "\n";
+ print LOGFILE 'ARGV[3] = ' . $ARGV[3] . "\n";
+ print LOGFILE 'ARGV[4] = ' . $ARGV[4] . "\n";
+ print LOGFILE 'ARGV[5] = ' . $ARGV[5] . "\n";
+ print LOGFILE 'ARGV[6] = ' . $ARGV[6] . "\n";
+ print LOGFILE 'ARGV[7] = ' . $ARGV[7] . "\n";
+ print LOGFILE 'ARGV[8] = ' . $ARGV[8] . "\n";
+ print LOGFILE 'ARGV[9] = ' . $ARGV[9] . "\n";
+}
+
+# test number of parameters
+if ($#ARGV ne 7) {
+ Log("Wrong number of parameters");
+ exit;
+}
+
+# use telling names for parameters
+my $src = $ARGV[0];
+my $src_bitrate = $ARGV[1];
+my $artist = $ARGV[2];
+my $title = $ARGV[3];
+my $channel = $ARGV[4];
+my $event = $ARGV[5];
+my $codec = $ARGV[6];
+my $dst_bitrate = $ARGV[7];
+
+# test parameters
+if ($artist eq "" || $title eq "") {
+ Log("Without data better remove this file");
+ exit;
+}
+
+# Create canonical filename
+my $dst;
+my $tmp = lc($artist . "_-_" . $title);
+# clear nearly all non-characters
+$tmp =~ s/[ \*\?!:"\']/_/g;
+# converts slashes to commas
+$tmp =~ s/\//,/g;
+# convert special characters to ASCII
+$tmp =~ s/[áàå]/a/g;
+$tmp =~ s/ä/ae/g;
+$tmp =~ s/ç/c/g;
+$tmp =~ s/[éÉè]/e/g;
+$tmp =~ s/[íï]/i/g;
+$tmp =~ s/ñ/n/g;
+$tmp =~ s/[óò]/o/g;
+$tmp =~ s/ö/oe/g;
+$tmp =~ s/ù/u/g;
+$tmp =~ s/ü/ue/g;
+# remove multiple underscores
+$tmp =~ s/___*/_/g;
+# remove underscore at file end
+$tmp =~ s/_$//g;
+
+# Name with extension
+$dst = $tmp . "." . $codec;
+
+# open blacklist
+my $inname = $mydir . '/blacklist.m3u';
+if (open(BLACKLIST, "< " . $inname)) {
+ while (<BLACKLIST>) {
+ chomp;
+ if ($_ eq $dst) {
+ Log("File $dst blacklisted");
+ exit;
+ }
+ }
+ close(BLACKLIST)
+}
+
+# calculate sizes
+my $src_size = (-s $src);
+print LOGFILE "size($src) = " . $src_size . "\n" if (defined($logfile));
+
+# No file smaller 8 secs
+if ($src_size < $src_bitrate) {
+ Log("File $src too small ($src_size)!");
+ exit;
+}
+
+# Full qualified name
+my $audiodir = dirname($src) . '/';
+my $fqn = $audiodir . $dst;
+
+# file already exists?
+if (-e $fqn) {
+ # Write duplicate file under curtain circumstances
+ my $size = (-s $fqn);
+ print LOGFILE "size($dst) = " . $size . "\n" if (defined($logfile));
+ # If file size is smaller than 17000 bytes this files are special
+ if ($size < 17000) {
+ Log("File already on CD");
+ exit;
+ }
+
+ my $dst_size = 0;
+ $dst_size = $src_size * $dst_bitrate / $src_bitrate if (!($src_bitrate == 0));
+ print LOGFILE "approx. size($dst) = " . $dst_size . "\n" if (defined($logfile));
+
+ if ($size > $dst_size) {
+ Log("Already larger version on disk ($size vs. $dst_size)");
+ exit;
+ }
+
+ # Files larger than existing ones are stored with
+ # a special numbered extension
+ my $i = 0;
+ while (-e $fqn) {
+ $i++;
+ $dst = $tmp . ".~" . $i . "~." . $codec;
+ $fqn = $audiodir . $dst;
+ }
+ }
+
+print LOGFILE '$dst = ' . $dst . "\n" if (defined($logfile));
+# return file name
+print $dst;
diff --git a/contrib/set_path b/contrib/set_path
new file mode 100755
index 0000000..6b8317b
--- /dev/null
+++ b/contrib/set_path
@@ -0,0 +1,35 @@
+#! /bin/bash
+
+# To active this script, call the audiorecorder-plugin with the
+# parameter -p plus the full path to this script, e.g.
+# "-p /audio/set_path" if this script is stored in the /audio
+# directory, it does not have to be in /usr/bin. Further you have
+# to configure the plugin to use "extern" for the file names.
+
+# The parameters to ths script are
+# $1. source file
+# (e.g. "/audio/S19.2E-1-1093-28450-2007-04-13.16.15.37.tmp.mp2")
+# $2. bitrate of the source file
+# $3. artist
+# $4. title
+# $5. channel
+# $6. event
+# $7. used codec (e.g. "mp3")
+# $8. set bitrate of the target
+
+# The output of the script has to be the file name of the target
+# file. If the file already exists or if there is no output of
+# this script, the audiorecorder plugin does not convert the recording
+# but deletes it.
+
+# In this sample file, the file name of the target file is made
+# of "<artist>_-_<title>.<codec>". Additionally all characters are
+# translated from upper to lower case as well as '/' translated to
+# ',' and '*', '?' resp. ' ' to '_'.
+
+# You can do anything in this script: handle special characters,
+# double underscores, etc. Test wether a song is already stored on CDs,
+# use a blacklist for miserable artists, store multiple versions of
+# recordings, ... Have a look at postproc.pl.
+
+echo -n "$3_-_$4.$7" | tr '[A-Z]/*? ' '[a-z],___'