IPhone Perl MP3tag

From ivc wiki
Jump to: navigation, search

Install Perl

From the Installer.app, install the Perl package.

Copy make

Copy the make build tool into /usr/bin and make it executable:

chmod +x /usr/bin/make

Compile MP3 Tag

Download the MP3 Tag module (right side on the page) onto the iPhone.

Extract the package and compile the module:

tar zxvf MP3-Tag-0.92.tar.gz

Create the make file:

/opt/iphone/binperl Makefile.PL

Compile and install the module:

make
make test
make install

Read ID3 tag

Create a new file and put these lines [1]:

#!/opt/iphone/bin/perl

# use module
use MP3::Tag;

# set filename of MP3 track
$filename = $ARGV[$0];

# create new MP3-Tag object
$mp3 = MP3::Tag->new($filename);

# get tag information
$mp3->get_tags();

# check to see if an ID3v1 tag exists
# if it does, print track information
if (exists $mp3->{ID3v1})
{
	print "Filename: $filename\n";
	print "Artist: " . $mp3->{ID3v1}->artist . "\n";
	print "Title: " . $mp3->{ID3v1}->title . "\n";
	print "Album: " . $mp3->{ID3v1}->album . "\n";
	print "Year: " . $mp3->{ID3v1}->year . "\n";
	print "Genre: " . $mp3->{ID3v1}->genre . "\n"; }

# clean up
$mp3->close();

And make it executable:

chmod +x read_tag.pl

Test the output:

./read_tag.pl test2.mp3

References