MP3-Tag

 view release on metacpan or  search on metacpan

examples/audio_rename  view on Meta::CPAN

  # and either p is the only Latin, or p is always surrounded by cyrillic stuff
  # at least on one side: /((?<=[^\s -~])|(?=.[^\s -~]))p/: funny stuff on one side
  tr/p/r/ if $c1 and $c2 > 2*$c1
	     and ($c == $c1 or (not /((?<=[^\s -~])|(?=.[^\s -~]))p/
			        and not $in =~ /(?!((?<=[^\s -~])|(?=.[^\s -~])))p/));
  $_
}

my $EXT = $opt{x} ? '' : '%E';
warn "Target spec: $opt{p}$EXT\n";
my @comp = split m|/|, $opt{p};
my @ext = split m/\|/, $opt{e};
my ($extl_add, $e) = 0;
for $e (@ext) {
    $extl_add = length $e if $extl_add < length $e;
}
my @f = @ARGV;
if ($opt{G}) {
  require File::Glob;			# "usual" glob() fails on spaces...
  @f = map File::Glob::bsd_glob($_), @f;
}

examples/extract-y.pl  view on Meta::CPAN

  # ### CHAMBER MUSIC //
  # Op. 1 // 1792--1794 // Pf. trios: Op.1, Nos. 1-3, in Eb, G major, and C minor
  # open my $codm, '<', 'Beethoven.codm' or die;
  my ($no_name, $fh) = (shift, shift);
  my (%seen, %no);
  #my $unknown = 0;
  while (<$fh>) {
    next if /###/;
    #s,^(?= // ), "?" . ++$unknown ,e;
    chomp;
    my ($op, $d, $n) = split m( // ), $_, 3;
    $n or $no_name or die "unexpected: <$_>";
    process_opus_year $op, $d, \%seen, \%no;
  }
  # close $codm or die;
  (\%seen, \%no)
}

sub find_no ($) {
  my $seen = shift;
  my %no;

examples/extract-y.pl  view on Meta::CPAN

  unless @ARGV and $ARGV[0] =~ /^(wiki|codm|merge|fix)$/i;

my $how = shift;
my $seen;
if ($how eq 'fix') {
  my $fn = shift;
  open my $f, '<', $fn or die "error opening $fn for read";
  my %ys;
  while (<$f>) {
    next if /^##/;
    my @fields = split m( // ), $_, 4;
    @fields == 4 or warn "<$_>";
    $ys{$fields[0]} = $fields[2];
  }
  close $f or die "error closing $fn for read";
  fix_year \*ARGV, \%ys;
  exit 0;
} elsif ($how eq 'merge') {
  my (@seen, %seen_a, %seen);
  my @ids = split m(/), shift;
  my @f = @ARGV;
  my $c = 0;
  for my $f (@f) {
    @ARGV = $f;
    my $sub_seen = extract_years $how, \*ARGV;
    @{$sub_seen->{$_}} == 1 or die "$_: <@{$sub_seen->{$_}}>"
      for keys %$sub_seen;
    $sub_seen->{$_} = $sub_seen->{$_}[0] for keys %$sub_seen;
    push @seen, $sub_seen;
    $seen_a{$_}[$c] = $sub_seen->{$_} for keys %$sub_seen; # Transposed

examples/mp3info2  view on Meta::CPAN

		'l' => 'album',
		'y' => 'year',
		'g' => 'genre',
		'c' => 'comment',
		'n' => 'track'  );

# Interprete Escape sequences:
my %r = ( 'n' => "\n", 't' => "\t", '\\' => "\\"  );
my ($e_backsl, $e_interp);
if ($opt{E} =~ s/^\+//) {
  ($e_backsl, $e_interp) = ((split m(/i:), $opt{E}, 2), '');
  $e_backsl .= 'p' unless $e_backsl =~ /p/;
  $e_interp =~ s/[Fp]//g;
  $e_interp .= 'Fp';
} else {
  ($e_backsl, $e_interp) = ((split m(/i:), $opt{E}, 2), '');
}
for my $e (split //, $e_backsl) {
  $opt{$e} =~ s/\\([nt\\])/$r{$1}/g if defined $opt{$e};
}
$e_interp = {map +($_, 1), split //, $e_interp};

if ($opt{'@'}) {
  for my $k (keys %opt) {
    if (ref $opt{$k}) {
      s/\@/%/g for @{ $opt{$k} };

examples/typeset_audio_dir  view on Meta::CPAN

  if ($how eq 'long') {
    %opt = (%opt, 1 => '', 2 => '%l', t => 1e100, a => 1e100);
  }
  if ($how eq 'short') {
    %opt = (%opt, 1 => '', 2 => '', t => -1e100, a => -1e100, c => 1);
  }
}

my $ini_c = $opt{c};
if ($opt{P}) {
  my @plan = split m/,/, $opt{P};	# Currenlty only one item in the plan
  @plan{@plan} = (1) x @plan;
  $both = 1 if $plan{short} and $plan{long};
  die "You can't have both short and long without -B" if $both and not $opt{B};
  %opt = %ini_opt;
  set_plan 'long'  if $plan{long};
  set_plan 'short' if $plan{short};
  @ARGV = @INI_ARGV;		# Redo getopts with different defaults
  getopts($opts, \%opt);
}

examples/typeset_audio_dir  view on Meta::CPAN

  }
  print to_TeX $this->{title};
  print "$comment$year\\posttitle\n";
}

# Callback for find():
sub print_mp3 {
  return unless -f $_ and /$glob_pat/;
  #print STDERR "... $_\n";
  my $tag = MP3::Tag->new($_);
  my @parts = split m<[/\\]>, $File::Find::dir;
  shift @parts if @parts and $parts[0] eq '.';

  my $this;
  $this->{top} = $opt{1} ? $tag->interpolate($opt{1}) : $performers[-1];
  $this->{author} = $tag->interpolate($opt{2});	# default '%a'
  $this->{title} = $tag->interpolate(@parts <= $opt{t} ? '%t' : '%l');
  $this->{track} = $tag->interpolate($opt{n} eq 1 ? '%{mA}%{n1}' : $opt{n})
    if $opt{n} and @parts <= $opt{t};
  $this->{len} = $tag->interpolate('%S') if $opt{T};
  my $l_part = $opt{a};

lib/MP3/Tag.pm  view on Meta::CPAN

    my($data, $how) = (shift, shift);
    my $firstnum = (($how || 0) eq 'num');
    my $prefer_num = (($how || 0) eq 'prefer_num');
    my (%seen, @genres);	# find all genres in incoming data
    $data = $data->[0] if ref $data;
    # clean and split line on both null and parentheses
    $data =~ s/\s+/ /g;
    $data =~ s/\s*\0[\0\s]*/\0/g;
    $data =~ s/^[\s\0]+//;
    $data =~ s/[\s\0]+$//;
    my @data = split m<\0|\s+/\s+>, $data;
    @data = split /\( ( \d+ | rx | cr ) \)/xi, $data[0] if @data == 1;

    # review array, produce a clean, ordered list of unique genres for output
    foreach my $genre (@data) {
        next if $genre eq "";  # (12)(13) ==> in front, and between

        # convert text to number to eliminate collisions, and produce consistent output
        if ($genre =~ /\D/) {{	# Not a pure number
            # return id number
            my $genre_num = MP3::Tag::ID3v1::genres($genre); 



( run in 2.605 seconds using v1.01-cache-2.11-cpan-71847e10f99 )