MusicRoom

 view release on metacpan or  search on metacpan

lib/MusicRoom/CoverArt.pm  view on Meta::CPAN

               artist => "The Clash", song => "Tommy Gun", 
               album => "The Singles", dir_artist => "The Clash",
               dir_album => "The Singles", dir_name => "The Clash - The Singles",
               size => "1575705",quality => "7",year => "1978"};
=cut

use strict;
use warnings;
use Carp;

use MP3::Tag;
use MusicRoom::File;
use MusicRoom::Track;
use MusicRoom::Locate;

use constant COVERART_LOCATOR => "coverart";
use constant PICTURE_TYPE => "Cover (front)";
use constant PICTURE_COMMENT => "Cover Image";
use constant APIC => "APIC";

my $configured;

lib/MusicRoom/CoverArt.pm  view on Meta::CPAN

    if(!-w $mp3_file)
      {
        # This shouldn't happen but...
        chmod 0755,$mp3_file;
      }
    if(!-w $mp3_file)
      {
        carp("Cannot write to $mp3_file");
        return undef;
      }
    my $mp3 = MP3::Tag->new($mp3_file);

    if(!defined $mp3)
      {
        carp("Cannot read tags from $mp3_file");
        return undef;
      }

    # Attempt to read the tags
    $mp3->get_tags();
    if(!defined $mp3->{ID3v2})

lib/MusicRoom/CoverArt.pm  view on Meta::CPAN

        error("Cannot extract $image_type data from \"$file_name\"");
        return;
      }

    return("image/$image_type",$image_data);
  }

sub picture_type_idx
  {
    # Given a picture type string convert it into a number suitable
    # for MP3::Tag
    my($picture_type) = @_;

    # The picture types that are currently understood (from MP3::Tag::ID3v2):
    my @picture_types =
         ("Other", "32x32 pixels 'file icon' (PNG only)", "Other file icon",
           "Cover (front)", "Cover (back)", "Leaflet page",
           "Media (e.g. lable side of CD)", "Lead artist/lead performer/soloist"
,
           "Artist/performer", "Conductor", "Band/Orchestra", "Composer",
           "Lyricist/text writer", "Recording Location", "During recording",
           "During performance", "Movie/video screen capture",
           "A bright coloured fish", "Illustration", "Band/artist logotype",
           "Publisher/Studio logotype");

lib/MusicRoom/File.pm  view on Meta::CPAN

                  }
                return %attribs;
              },
          },
        mp3 =>
          {
            uses_encoder => "lame",

            # The MP3::Info package is implicitly called by
            # total_secs_int
            uses_package => ["MP3::Tag","MP3::Info",],
            # Bitrates defined in the mp3 standard
            bitrates => [32, 40, 48, 56, 64, 80, 96, 
                         112, 128, 144, 160, 192, 224, 256, 320],
            ext => "mp3",
            to_working => sub
              {
                my($format,$src_file,$dest_file) = @_;
    
                # decode an mp3 to wav
                # $src_file & $dest_file have been dosified already

lib/MusicRoom/File.pm  view on Meta::CPAN

                system("$paths{lame} -h --decode \"$src_file\" -o \"$dest_file\"");
              },
            is_valid => sub
              {
                my($format,$src_file) = @_;
                if(!-r $src_file)
                  {
                    carp("Cannot read $format file \"$src_file\"");
                    return "";
                  }
                my $mp3 = MP3::Tag->new($src_file);
                if(!defined $mp3)
                  {
                    carp("File \"$src_file\" appears to not be $format format");
                    return "";
                  }
                return 1;
              },
            from_working => sub
              {
                # encode a wav to mp3

lib/MusicRoom/File.pm  view on Meta::CPAN

                my $bitrate = bitrate_of($format);
                my $br_flag = "-b $bitrate";
                $br_flag = "" if($bitrate eq "");

                system("$paths{lame} -h $br_flag \"$src_file\" -o \"$dest_file\"");
              },
            get_tags => sub
              {
                # How to grab tags from an mp3 file
                my($format,$src_file) = @_;
                my $mp3 = MP3::Tag->new($src_file);
                if(!defined $mp3)
                  {
                    carp("File \"$src_file\" appears to not be $format format");
                    return "";
                  }
                my %attribs;
                $mp3->get_tags();
                foreach my $tag (@attribs)
                  {
                    if($tag eq "file")

lib/MusicRoom/File.pm  view on Meta::CPAN

                          }
                      }
                  }
                return %attribs;
              },
            set_tags => sub
              {
                # How to assign tags in an mp3 file
                my($vals_hash,$file_name) = @_;

                my $mp3 = MP3::Tag->new($file_name);
                if(!defined $mp3)
                  {
                    carp("Cannot get tags from $file_name");
                    return "";
                  }
                if(!defined $mp3->{ID3v2})
                  {
                    $mp3->new_tag("ID3v2");
                  }

lib/MusicRoom/Lyrics.pm  view on Meta::CPAN

package MusicRoom::Lyrics;

use strict;
use warnings;
use Carp;

use MP3::Tag;
use MusicRoom::File;
use MusicRoom::Track;
use MusicRoom::Locate;

use constant LYRICS_LOCATOR => "lyrics";

my $configured;

sub init
  {



( run in 1.097 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )