#!/usr/bin/perl -w # In order to run this script you should: # - have xmms vqfplugin working # - have pyxmms-remote installed and available in your $PATH # - edit $ENTRADA to match the directory where the vqfs are # - edit $SAIDA to mach the directory you want the oggs # - configure xmms output driver as disk writer # - edit $XMMS_OUT to match the output directory of the # disk writer plugin in xmms # $ENTRADA = "/tmp/cd03"; $SAIDA = "/home/mentus/tmp/songs/ogg/saida"; $XMMS_OUT = "/home/mentus/tmp/songs/ogg/wav"; @arquivos = `find $ENTRADA -name "*.vqf"`; foreach $vqf (@arquivos) { chomp($vqf); converte_wav($vqf); foreach $convertida (<$XMMS_OUT/*.wav>) { $novonome = converte_nome($convertida); system("mv \"$convertida\" \"$novonome\""); system("oggenc \"$novonome\""); system("rm \"$novonome\""); $novonome =~ s/\.wav$/.ogg/; } $caminho = `dirname \"$vqf\"`; $caminho = converte_caminho($caminho); system("mkdir -p \"$SAIDA$caminho\""); system("mv \"$novonome\" \"$SAIDA$caminho\""); $onlysong = `basename \"$novonome\"`; chomp($onlysong); print "$SAIDA$caminho/$onlysong converted\n"; } sub converte_wav { $filename = $_[0]; system("xmms \"$filename\" &"); system("pyxmms-remote main_win_set_visible 0"); while (1) { system("sleep 5"); $status = `pyxmms-remote is_playing`; if ($status == 0) { system("pyxmms-remote quit"); last; } } } sub converte_nome { $song = $_[0]; $song =~ s/\[//g; $song =~ s/\]/_-/g; $song =~ s/\s/_/g; return($song) } sub converte_caminho { $cam = $_[0]; chomp($cam); $cam =~ s/\[//g; $cam =~ s/\]/_-/g; $cam =~ s/\s/_/g; $cam =~ s/&/and/g; return($cam); }