Apache::MP3 fetch_info()

This is the code that fetches information about each MP3 file.

sub fetch_info {
  my $file = shift;
  return unless my $info = get_mp3info($file);
  my $tag  = get_mp3tag($file);
  my ($title,$artist,$album,$year,$comment,$genre,$duration,$bps);
  if ($tag) {
    ($title,$artist,$album,$year,$comment,$genre) = @{$tag}{qw(TITLE ARTIST ALBUM YEAR COMMENT GENRE)};
  }
  $duration = "$info->{MM}m $info->{SS}s";
  $bps      = "$info->{BITRATE} bps";
  return { title    => $title,
	   artist   => $artist,
	   duration => $duration,
	   bps      => $bps,
	   genre    => $genre,
	   album    => $album,
	   comment  => $comment,
	 };
}


<< Previous
Contents >> Next >>

Lincoln D. Stein, lstein@cshl.org
Cold Spring Harbor Laboratory
Last modified: Sun Jun 4 13:06:51 PDT 2000