From b2fca0d7f5d0c09817bed4d3b1eae2107763944e Mon Sep 17 00:00:00 2001 From: lvw Date: Fri, 28 May 2004 15:30:48 +0000 Subject: Merged and added import scripts git-svn-id: https://vdr-muggle.svn.sourceforge.net/svnroot/vdr-muggle/trunk@99 e10066b5-e1e2-0310-b819-94efdf66514b --- muggle-plugin/scripts/gdparams.pm | 336 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 336 insertions(+) create mode 100755 muggle-plugin/scripts/gdparams.pm (limited to 'muggle-plugin/scripts/gdparams.pm') diff --git a/muggle-plugin/scripts/gdparams.pm b/muggle-plugin/scripts/gdparams.pm new file mode 100755 index 0000000..35aa319 --- /dev/null +++ b/muggle-plugin/scripts/gdparams.pm @@ -0,0 +1,336 @@ +################################################## +# +# GiantDisc mp3 Jukebox +# +# © 2000, Rolf Brugger +# +################################################## + +package gdparams; + +#use lib '/usr/local/bin'; +use strict; +use Getopt::Long; + +my @mp3dirs; + +############################################################ +### Global variables (accessible from anywhere) + +# IMPORTANT ERROR! all modules refer to gdparms::varname instead +# of gdparams::varname +# ... however, it works ... I just don't know why :-/ + + +#my ($dbhost, $shutdowncmd, $extmp3player, $defrecbitrate, +# $systemonline); + + +### Global constants +my $minfreehdspace = 1000; # minimal space required for a directory, + # that it can be used to record and + # compress a cd (in MB) + + +############################################################ +### + +sub get_configfile_params{ + ### Parameters: Call-by-reference + + my ($dbhost, + $commmode, + $serialdevice, $serialspeed, + $tcpiphost, $tcpipport, + $playerhost, $playertype, $snddevice, + $playerapp, $mp3playerparams, $oggplayerparams, $ptlogger, + $mp3encoder, $logtarget, $shutdowncmd, + $extmp3player, $defrecbitrate, $systemonline + ) = @_; + + + ### Read configuration file im home directory + open (CONF, "< ".gdbase()."/.gdconfig") + or die "Error: could not open configuration file .gdconfig\n"; + + my $line; + while(){ + $line = $_; + chop $line; + $line =~ tr/\r/ /; + # \w word-char + # \w non-word-char + # \s whitespace-char + # \S non-whitespace-char + + if($line =~ m/^dbhost.*=\s*(\S+)/i ){ + $$dbhost = $1; + } + + if($line =~ m/^commmode.*=\s*([0-9]+)/i ){ + $$commmode = $1; + } + + if($line =~ m/^serialdevice.*=\s*([\w\/]+)/i ){ + $$serialdevice = $1; + } + + if($line =~ m/^serialspeed.*=\s*([0-9]+)/i ){ + $$serialspeed = $1; + } + + if($line =~ m/^tcpiphost.*=\s*(\S+)/i ){ + $$tcpiphost = $1; + } + + if($line =~ m/^tcpipport.*=\s*([0-9]+)/i ){ + $$tcpipport = $1; + } + + if($line =~ m/^playerhost.*=\s*(\S+)/i ){ + $$playerhost = $1; + } + + if($line =~ m/^playertype.*=\s*([0-9]+)/i ){ + $$playertype = $1; + } + + if($line =~ m/^playerapp.*=\s*(\S+)/i ){ + $$playerapp = $1; + } + + if($line =~ m/^playerparams.*=\s*(.*)$/i ){ # match anything to end of line + print "\nWARNING: as of v1.20 the option 'playerparams' has been replaced by\n"; + print " 'mp3playerparams' and 'oggplayerparams'. Update .gdconfig accordingly\n\n"; + #$$playerparams = $1; + } + if($line =~ m/^mp3playerparams.*=\s*(.*)$/i ){ # match anything to end of line + $$mp3playerparams = $1; + } + if($line =~ m/^oggplayerparams.*=\s*(.*)$/i ){ # match anything to end of line + $$oggplayerparams = $1; + } + + if($line =~ m/^shutdowncmd.*=\s*(.*)$/i ){ # match anything to end of line + $$shutdowncmd = $1; + } + + if($line =~ m/^extmp3player.*=\s*(.*)$/i ){ # match anything to end of line + $$extmp3player = $1; + } + + if($line =~ m/^sounddevice.*=\s*(\S+)/i ){ + $$snddevice = $1; + } + + if($line =~ m/^mp3encoder.*=\s*(\w+)/i ){ + $$mp3encoder = $1; + } + + if($line =~ m/^logtarget.*=\s*(\w+)/i ){ + if ($1 eq "stdout" || $1 eq "logfile" || $1 eq "devnull"){ + $$logtarget = $1; + } + } + + if($line =~ m/^ptlogger.*=\s*(\S+)/i ){ + $$ptlogger = $1; + } + + if($line =~ m/^defrecbitrate.*=\s*(.+)/i ){ # match anything to end of line + $$defrecbitrate = $1; + } + + if($line =~ m/^systemonline.*=\s*([0-9])/i ){ + $$systemonline = $1; + } + + } + + close (CONF); +} + + +############################################################ +### + +sub get_otherclients_params{ + ### Parameters: Call-by-reference + + my ($keymap # type: reference to an empty hash + )= @_; + + + ### Read configuration file im home directory + open (CONF, "< ".gdbase()."/.gdconfig") + or die "Error: could not open configuration file .gdconfig\n"; + + my $line; + while(){ + $line = $_; + chop $line; + $line =~ tr/\r/ /; + # \w word-char + # \w non-word-char + # \s whitespace-char + # \S non-whitespace-char + + if($line =~ m/^keymap.*=\s*(\S+)\s*-\s*(\S+)\s*$/i ){ + print ("keymap: key: $1, val: $2\n"); + $$keymap{$1} = $2; + } + + + } + + close (CONF); +} + + +############################################################ +### translate logtarget string to integer +sub logtarget_to_int{ + my ($logtargetstr) = @_; + if ($logtargetstr eq "devnull") {return 0;} + if ($logtargetstr eq "logfile") {return 1;} + if ($logtargetstr eq "stdout" ) {return 2;} + return 2; # default +} + + +############################################################ +### + +sub get_commandline_params{ + + my ($dbhost, + $commmode, + $serialdevice, $serialspeed, + $tcpiphost, $tcpipport, + $playerhost, $playertype, $snddevice, + $playerapp, + $mp3playerparams, $oggplayerparams, + $ptlogger, + $mp3encoder, $logtarget) = @_; + # ARGV passed implicitly + + + my $help; + $Getopt::Long::autoabbrev=1; + GetOptions( + "help" => \$help, + "dbhost:s" => $dbhost, # $dbhost is already a reference + "commmode:i" => $commmode, + "serialdevice:s" => $serialdevice, + "serialspeed:i" => $serialspeed, + "tcpiphost:s" => $tcpiphost, + "tcpipport:i" => $tcpipport, + "playertype:i" => $playertype, + "playerhost:s" => $playerhost, + "sounddevice:s" => $snddevice, + "mp3playerparams=s" => $mp3playerparams, + "oggplayerparams=s" => $oggplayerparams, + "ptlogger:s" => $ptlogger, + "mp3encoder:s" => $mp3encoder, + "logtarget:s" => $logtarget + ); + + if ($help){ + print <