Forgot your password?
typodupeerror
User Journal

Journal ghotiboy's Journal: RadioVo Source - Perl Module (oggrec.pm)

# Read the config file given as argv[0]
# All you give as an argument is the first
# part of the name of the config file

package oggrec;

sub new {
    my $this = {};
    bless $this;
    return $this;
}

sub oggrec {
    my $BASEDIR = "/MUSIC";
    my $MUSIC = "$BASEDIR/music";
    my $CONFIG = "$BASEDIR/config";
    my $STATUS = "$BASEDIR/status/status";
    my $oggrec_conf = "$CONFIG/oggrec.conf";

    my @config_files;
    push(@config_files, $oggrec_conf);

#    (my $time, my $conf) = &figure_args(@_);

    (my $conf) = @_;
    if($conf) {
        $rec_conf = "$CONFIG/$conf.conf";
        push(@config_files, $rec_conf);
    }

    foreach $conf_file (@config_files) {
        print "opening $conf_file\n";
        open(FILE, "$conf_file")    or die "Can't open $file: $!";
        my @config = <FILE>;
        close(FILE);

        foreach my $line (@config) {
            chomp($line);

            eval($line);
        }
    }

    open(STATUS_FILE, ">$STATUS");
    print STATUS_FILE "$outfile";
    close(STATUS_FILE);

    # print "cd $MUSIC && $rawrec $rawrec_args | $oggenc $oggenc_args\n\n";
    print "Recording...\n";

    my $output = `cd $MUSIC && $rawrec $rawrec_args 2>/dev/null | $oggenc $oggenc_args 2>&1`;
    # my $output = `cd $MUSIC && $rawrec $rawrec_args | $oggenc $oggenc_args `;
    print $output;

}

sub figure_args {
    local(@args) = @_;

    $size = @args;

    print "size=$size\n";

    if($size ne 1) {
        die "Wrong number of arguments\nPlease enter a time or configuration\n";
    }

    if($args[0] =~ /:/) {
        @time = split(/:/, $args[0]);
        $i=0;
        $total_time = 0;

        while($element = pop(@time)) {
            $total_time += $element*(60**$i);
            print "$total_time\n";
            $i += 1;
        }
        return($total_time, "");
    }else{
        return(0, $args[0]);
    }
}

return 1;

"Atomic batteries to power, turbines to speed." -- Robin, The Boy Wonder

Working...