############################################################################### # # Mp3IdOf: Shows the MP3 Id tags of a mp3 file # # Parameter: MP3-Filename # # # @Filetype: Perl scipt # @Author: Werner Puenter # @Date: 06.10.2001 # @Version: 1.1 # # @History: # Version 1.0: Initial Version # Version 1.1: Add Genre # Version 1.2: Add "use strict" # -> use of my # -> correct mistake of missing input_file # ############################################################################### use strict; my $input_file = $ARGV[0]; # must read from file(?) if ($input_file) { my @Genre = qw( Blues Classic_Rock Country Dance Disco Funk Grunge Hip-Hop Jazz Metal NewAge Oldies Other Pop R&B Rap Reggae Rock Techno Industrial Alternative Ska DeathMetal Pranks Soundtrack Euro-Techno Ambient Trip-Hop Vocal Jazz+Funk Fusion Trance Classical Instrumental Acid House Game SoundClip Gospel Noise Alt.Rock Bass Soul Punk Space Meditative Instrumental_Pop Instrumental_Rock Ethnic Gothic Darkwave Techno-Industrial Electronic Pop-Folk Eurodance Dream Southern_Rock Comedy Cult Gangsta Top40 Christian_Rap Pop/Funk Jungle Native_American Cabaret New_Wave Psychadelic Rave Showtunes Trailer Lo-Fi Tribal Acid_Punk Acid_Jazz Polka Retro Musical Rock&Roll Hard_Rock Folk Folk/Rock National_Folk Swing Fusion Bebob Latin Revival Celtic Bluegrass Avantgarde Gothic_Rock Progressive_Rock Psychedelic_Rock Symphonic_Rock Slow_Rock Big_Band Chorus Easy_Listening Acoustic Humour Speech Chanson Opera Chamber_Music Sonata Symphony Booty_Bass Primus Porn_Groove Satire Slow_Jam Club Tango Samba Folklore Unknown ); # Folklore=115, Unknown=116-255 open(INPUT_FILE,"<$input_file") or die "*** ERROR *** Not able to open $input_file.\n$!\n$^E"; binmode(INPUT_FILE); # Set file type to binary my @lines = reverse ; # Read file from in reverse order # (Last row first) # The last 128 bytes of a MP3 file contains the ID-Tags my $MP3_Tag = 0; # 3 Bytes = "TAG" my $MP3_Titel = 0; # 30 Bytes = Titel des Stueckes my $MP3_Interpret = 0; # 30 Bytes = Interpret my $MP3_CD_Name = 0; # 30 Bytes = CD-Titel my $MP3_Jahr = 0; # 4 Bytes = Erscheinungsjahr my $MP3_Comment = 0; # 30 Bytes = Kommentar my $MP3_GenreByte = 255; # 1 Byte = Genre my $i = 0; foreach my $line(@lines) { $i=$i+1; if ($line =~ /.*(TAG.*)/) { my $Total = $1; $MP3_Tag = substr($Total,0,3); # 0/1/2 -> 3 Char $MP3_Titel = substr($Total,3,30); # 3/../32 -> 30 Char $MP3_Interpret = substr($Total,33,30); # 33/../62 -> 30 Char $MP3_CD_Name = substr($Total,63,30); # 63/../92 -> 30 Char $MP3_Jahr = substr($Total,93,4); # 93/../96 -> 4 Char $MP3_Comment = substr($Total,97,30); # 97/../126 -> 30 Char $MP3_GenreByte = ord(substr($Total,127,1)); # 127/ -> 1 Char if ( $MP3_GenreByte > 115 ) { $MP3_GenreByte = 116; # UnKnown } print "MP3_Tag = $MP3_Tag\n"; print "MP3_Titel = $MP3_Titel\n"; print "MP3_Interpret = $MP3_Interpret\n"; print "MP3_CD_Name = $MP3_CD_Name\n"; print "MP3_Jahr = $MP3_Jahr\n"; print "MP3_Comment = $MP3_Comment\n"; print "MP3_Genre = $Genre[$MP3_GenreByte]\n"; last; } else { print "No MP3 IdTag available."; last; } if ($i > 1) { print " *** WARNING *** - Unexspected EndOfLine found\n"; last; # Sicherheitshalber -> NotAus } } close (INPUT_FILE); } else { print "*** ERROR *** - Please use Mp3IdOf with Parameter \n"; }