Actions

&johncdvorak

From Rabbi Blog

Revision as of 12:02, 9 June 2007 by Rabbi Bob (talk | contribs) (New page: While writing my perl Sansa mp3 player podcast sync program, I came across the issue that the mp3 audio for the CrankyGeeks podcast is without id3 tag information. This royally messes up ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

While writing my perl Sansa mp3 player podcast sync program, I came across the issue that the mp3 audio for the CrankyGeeks podcast is without id3 tag information. This royally messes up my list. As a short irony, I noticed that the last KFI Tech Guy with Leo Laporte was without a few tags, causing it to fall into the <unknown> category on the player.

Leo has enough stuff derived from his name, so I wrote the &johncdvorak subroutine

Here are the excerpts of the main file:

use MP3::Info;

&johncdvorak($checkmp3tag,$checkmp3name);


sub johncdvorak
    {
    #This routine is dedicated to John C Dvorak by way of CrankyGeeks
    my $file=$checkmp3tag;
    my $mp3 = new MP3::Info $file;
           
        my $newtag=();
        if ($checkmp3name =~ m/(.*).mp3/)
        {
        $newtag=$1;
        
        #Strip out numbers.  If we're lucky
        #we'll have a nice name for the tag w/o
        #show/ep numbers
        
        $newtag =~ s/[0-9]//g;  
        }            

        if ($mp3->title eq "")
            {
            $tag->{TITLE} = $newtag;
            set_mp3tag($checkmp3tag, $tag);
            }
        if ($mp3->artist eq "")
            {
            $tag->{ARTIST} = $newtag;
            set_mp3tag($checkmp3tag, $tag);
            }
        if ($mp3->album eq "")
            {
            $tag->{ALBUM} = $newtag;
            set_mp3tag($checkmp3tag, $tag);
            }
        if ($mp3->genre eq "")
            {
            #You must edit MP3\Info.pm and add Podcast to the genres
            #for this to work.  If I remember, I'll email Chris Nandor
            #and relay that. [email protected]
            $tag->{GENRE} = 'Podcast';
            set_mp3tag($checkmp3tag, $tag);
            }
        $mp3 = new MP3::Info $file;
        printf "Checked ID3v1 tags for $checkmp3name:\n title: %s - artist: %s - genre: %s\n",
                $mp3->title, $mp3->artist, $mp3->genre;
        #ref: FILE, TITLE, ARTIST, ALBUM, YEAR, COMMENT, GENRE
    }