#!/usr/bin/perl -w use File::Basename ; # version 2010-12-06 # parse # [mp4|m4v|mkv] [DD|noDD|HD-HD|HD-smallHD] [VHQ|HQ|MQ] [first|all] # aka # m4v DD HQ first # m4v DD HQ all # m4v noDD HQ all # m4v noDD HQ all # m4v HD-HD VHQ all # gets 4Parameter plus "path of recording" # prevent xxv bug to write info.vdr in vdr 1.7.13 my $config = &parse_config("/etc/vdr/plugins/vdrtranscode.conf") ; my $Indir = "$config->{Indir}" ; # check given Directory foreach ( $Indir ) { if ( -l $_ ) { $_ = readlink ( $_ ) } ; unless ( -e $_ || -d $_ ) { &quit ;} $_ .= "/" ; $_ =~s/\/\//\//g ; } if ( -f "$ARGV[1]/info.vdr" ) { unlink "$ARGV[1]/info.vdr"} ; rename_vdr_file ( @ARGV ) ; open REFRESH , ">/${Indir}.update" ; close REFRESH ; sub rename_vdr_file { #print "$_[0] \n" ; my $container = shift ; my $dd = shift ; my $quali = shift ; my $atrack = shift ; my $filename = shift ; $filename =~ s/\d{4}-\d{2}-\d{2}.*\.rec// ; my $dir = dirname($filename) ; my $file = basename($filename) ; # special for removing any leading [***] comments on filename if ( $container =~ /REMOVE/ ) { my ${file_remove_cut} ; ( ${file_remove_cut} = ${file} ) =~ s/\[del-.*\]|\[cut-.*\]|\[work-.*\]|\[oops-.*\]// ; rename ( "${dir}/${file}" , "${dir}/${file_remove_cut}" ) ; print "cut marking removed...\n" ; } else { unless ( "${dir}/${file}" =~ /\[cut-.*\]/ ) { rename ( "${dir}/${file}" , "${dir}/[cut-$container|$dd|$quali|$atrack]${file}" ) ; print "marked as cut ...\n" ; } } } ################################################################# # thanks to http://www.patshaping.de/hilfen_ta/codeschnipsel/perl-configparser.htm sub parse_config($) { my $file = shift; local *CF; open(CF,'<'.$file) or die "Open $file: $!"; read(CF, my $data, -s $file); close(CF); my @lines = split(/\015\012|\012|\015/,$data); my $config = {}; my $count = 0; foreach my $line(@lines) { $count++; next if($line =~ /^\s*#/); next if($line !~ /^\s*\S+\s*=.*$/); my ($key,$value) = split(/=/,$line,2); # Remove whitespaces at the beginning and at the end $key =~ s/^\s+//g; $key =~ s/\s+$//g; $value =~ s/^\s+//g; $value =~ s/\s+$//g; # die "Configuration option '$key' defined twice in line $count of configuration file '$file'" if($config->{$key}); $config->{$key} = $value; } return $config; } #################################################################