Tacoen's shared code-snipsets
sub CreateLST { my ($tpl_file,$output)=@_; my $spl; my $tpl = uc(tacoenf::load_as_string($tpl_file)); $tpl =~ s/\%pause(.*)\%/&pause($1,$sn)/gie; $tpl =~ s/\%(.*)\%/"-1\t".$file{uc($1)}/gie; $tpl = &removeblank($tpl); my $ntpl = @ntpl = split(/\n/,$tpl); my $str = $ntpl."\n".$tpl."\n"; tacoenf::save_file($output,$str,0); if ($debug) { print $tpl_file." -> ".$output."\n"; print "-"x60; print "\n"; print $str; print "-"x60; print "\n\n"; } } sub CreateSEQ { my ($tpl_file,$output)=@_; my $sn=0; my $str; my @ntpl = tacoenf::load_as_array($tpl_file); foreach $tpl(@ntpl) { $tpl =~ s/\%time\%/"file$sn=.time\nlength$n=-1\n"/gie; $tpl =~ s/\%pause(.*)\%/&seqpause($1,$sn)/gie; $tpl =~ s/\%(.*)\%/"file$sn=".$file{uc($1)}."\nlength$n=-1\n"/gie; $str .=$tpl; $sn++; } $str = &removeblank(&removeblank($str)); $strn = "\n[playlist]\n\n".$str."\nNumberofentries=".$sn."\nnextindex=0\n"; tacoenf::save_file($output,$strn,0); if ($debug) { print $tpl_file." -> ".$output."\n"; print "-"x60; print "\n"; print $strn; print "-"x60; print "\n\n"; } } sub removeblank { my $str = shift; $str =~ s/-1\t\n/\n/gi; $str =~ s/\n\n/\n/gi; $str =~ s/^[\s]//gi; $str =~ s/[\s]$//gi; return $str; } sub seqpause { my ($p,$n) = @_; my $pa = $p*1000; return "file$n=$p.pause\nlength=$pa\n"; } sub pause { my $p = shift; my $pa = $p*1000; return "$pa\t$p.pause"; }