Howto: Convert your mp3 tags (id3v2 to id3v1) so your Playstation 3 can play your MP3s!
- Run the converter on your media server: ps3_mp3_converter.pl -d {directory}
- Copy your mp3 collection wherever you told ps3_mp3_converter.pl to run in.
use strict;
use warnings;
use File::Basename;
use File::Find ();
use Getopt::Std;
use Linux::Inotify2;
use POE;
$|++;
#######################################
#######################################
our @found_dirs;
sub watch_add_dir {
my ($heap_ref, $session, $dir_name) = @_;
$heap_ref->{inotify}->watch($dir_name, IN_CREATE|IN_CLOSE_WRITE, $session->postback("watch_hdlr"));
print " Watching directory $dir_name\n";
}
sub watch_hdlr {
my ($heap_ref, $session, $event) = ( $_[HEAP], $_[SESSION], $_[ARG1][0] );
my $name = $event->fullname;
my $short_name = $event->name;
unless ($_[HEAP]{inotify}{files}{$name}) {
if ($event->IN_CREATE && -d $name) {
print "New directory: $name\n";
watch_add_dir($heap_ref, $session, $name);
} elsif ($event->IN_CLOSE_WRITE) {
my $ext = ( fileparse($name, ‘\..*’) )[2];
if (lc($ext) eq ‘.mp3′) {
print "-"x20 . "\n";
print "$name:\n";
my $cmd_output = `eyeD3 –to-v1.1 "$name"`;
$cmd_output = `eyeD3 –remove-v2 "$name"`;
}
$_[HEAP]{inotify}{files}{$name} = 1;
}
}
print "events for $name have been lost\n" if $event->IN_Q_OVERFLOW;
}
sub find_wanted {
my $object = $File::Find::name;
if (-d $object) {
push @found_dirs, $object;
}
}
#######################################
#######################################
#######################################
my %arg_options;
my $watch_dir;
getopts(‘d:’, \%arg_options);
if ($arg_options{d} && -d $arg_options{d}) {
$watch_dir = $arg_options{d};
File::Find::find({wanted => \&find_wanted}, $watch_dir);
POE::Session->create
( inline_states =>
{ _start => sub {
my $inotify_FH;
$_[KERNEL]->alias_set(‘notify’);
$_[HEAP]{inotify} = new Linux::Inotify2
or die "Unable to create new inotify object: $!";
foreach my $dir (@found_dirs) {
watch_add_dir($_[HEAP], $_[SESSION], $dir);
}
$_[HEAP]{inotify}{files} = {};
open $inotify_FH, "< &=" . $_[HEAP]{inotify}->fileno
or die "Can’t fdopen: $!\n";
$_[KERNEL]->select_read( $inotify_FH, "inotify_poll" );
},
inotify_poll => sub {
$_[HEAP]{inotify}->poll;
},
watch_hdlr => \&watch_hdlr,
},
);
POE::Kernel->run();
}
exit 0;



You will need the eyeD3 software package installed and in your path (which eyeD3).
Great! The articles so far have been full of great material. Glad to hear the serious will continue. Keep ‘em coming!