pax_global_header00006660000000000000000000000064137345464360014531gustar00rootroot0000000000000052 comment=1b597dc2565ed7d79ffc9306ee91fbfddceb71f7 mp3report-1.0.3/000077500000000000000000000000001373454643600134655ustar00rootroot00000000000000mp3report-1.0.3/.gitignore000066400000000000000000000005011373454643600154510ustar00rootroot00000000000000!Build/ .last_cover_stats /META.yml /META.json /MYMETA.* *.o *.pm.tdy *.bs # Devel::Cover cover_db/ # Devel::NYTProf nytprof.out # Dizt::Zilla /.build/ # Module::Build _build/ Build Build.bat # Module::Install inc/ # ExtUtils::MakeMaker /blib/ /_eumm/ /*.gz /Makefile /Makefile.old /MANIFEST.bak /pm_to_blib /*.zip mp3report-1.0.3/ChangeLog000066400000000000000000000017261373454643600152450ustar00rootroot00000000000000v1.0.2, 04/05/2000 ------------------ changes by David Parker: - updated code for MP3::Info instead of MPEG::MP3Info - now supports VBR (requested by Jean-Noel GADREAU ) - dir header is now written last, allows variable substitution from non-header variables (Gerard McGlew ) - clears out id3 variables from previous match (Eric Lieffers ) - better, more secure tempfiles - added man page - no more default hardcoded dirs, shows help instead v1.0.0, 01/27/2000 ------------------ - more cleanup - external template support - lots of new template fields - ID3v2.3.0 experimental support - first attempt at docs by David Parker v0.99.2, 01/22/2000 ------------------- changes by David Parker: - cleaned up little things - added OS-specific directory seperator - implemented command line options - made a readme v0.99.1, 01/21/2000 ------------------- - first release mp3report-1.0.3/LICENSE000066400000000000000000000432541373454643600145020ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. mp3report-1.0.3/MP3/000077500000000000000000000000001373454643600140645ustar00rootroot00000000000000mp3report-1.0.3/MP3/Info.pm000066400000000000000000000634751373454643600153340ustar00rootroot00000000000000package MP3::Info; use strict; use Carp; use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION @mp3_genres %mp3_genres @winamp_genres %winamp_genres $try_harder @t_bitrate @t_sampling_freq @frequency_tbl %v1_tag_fields @v1_tag_names %v2_tag_names %v2_to_v1_names); @ISA = 'Exporter'; @EXPORT = qw(set_mp3tag get_mp3tag get_mp3info remove_mp3tag use_winamp_genres); @EXPORT_OK = qw(@mp3_genres %mp3_genres); %EXPORT_TAGS = ( genres => [qw(@mp3_genres %mp3_genres)], all => [@EXPORT, @EXPORT_OK] ); $VERSION = '0.80'; { my $c = -1; # set all lower-case and regular-cased versions of genres as keys # with index as value of each key %mp3_genres = map {($_, ++$c, lc, $c)} @mp3_genres; # do it again for winamp genres $c = -1; %winamp_genres = map {($_, ++$c, lc, $c)} @winamp_genres; } =pod =head1 NAME MP3::Info - Manipulate / fetch info from MP3 audio files =head1 SYNOPSIS #!perl -w use MP3::Info; my $file = 'Pearls_Before_Swine.mp3'; set_mp3tag($file, 'Pearls Before Swine', q"77's", 'Sticks and Stones', '1990', q"(c) 1990 77's LTD.", 'rock & roll'); my $tag = get_mp3tag($file) or die "No TAG info"; $tag->{GENRE} = 'rock'; set_mp3tag($file, $tag); my $info = get_mp3info($file); printf "$file length is %d:%d", $info->{MM}, $info->{SS}; =head1 DESCRIPTION =over 4 =item use_winamp_genres() Puts WinAmp genres into C<@mp3_genres> and C<%mp3_genres>. You can import the data structures with one of: use MP3::Info qw(:genres); use MP3::Info qw(:DEFAULT :genres); use MP3::Info qw(:all); =cut sub use_winamp_genres { %mp3_genres = %winamp_genres; @mp3_genres = @winamp_genres; 1; } =pod =item remove_mp3tag (FILE) Removes last 128 bytes from file if those last 128 bytes begin with the text `TAG'. File will be 128 bytes shorter. Returns undef if no existing TAG found, 1 on successful removal of TAG. =cut sub remove_mp3tag { my $file = $_[0]; croak 'No file specified' unless $file; local *FILE; open FILE, "+< $file\0" or croak "Can't open '$file': $!"; binmode FILE; seek FILE, -128, 2; my $tell = tell FILE; return unless =~ /^TAG/; truncate FILE, $tell or carp "Can't truncate '$file': $!"; close FILE or carp "Problem closing '$file': $!"; 1; } =pod =item set_mp3tag (FILE, TITLE, ARTIST, ALBUM, YEAR, COMMENT, GENRE [, TRACKNUM]) =item set_mp3tag (FILE, $HASHREF) Adds/changes tag information in an MP3 audio file. Will clobber any existing information in file. Fields are TITLE, ARTIST, ALBUM, YEAR, COMMENT, GENRE. All fields have a 30-byte limit, except for YEAR, which has a four-byte limit, and GENRE, which is one byte in the file. The GENRE passed in the function is a case-insensitive text string representing a genre found in C<@mp3_genres>. Will accept either a list of values, or a hashref of the type returned by C. If TRACKNUM is present (for ID3v1.1), then the COMMENT field can only be 28 bytes. ID3v2 support will come eventually. =cut sub set_mp3tag { my($file, $title, $artist, $album, $year, $comment, $genre, $tracknum) = @_; my(%info, $oldfh); local %v1_tag_fields = %v1_tag_fields; # set each to '' if undef for ($title, $artist, $album, $year, $comment, $tracknum, $genre, (@info{@v1_tag_names})) {$_ = defined() ? $_ : ''} # populate data to hashref if hashref is not passed if (!ref $title) { (@info{@v1_tag_names}) = ($title, $artist, $album, $year, $comment, $tracknum, $genre); # put data from hashref into hashref if hashref is passed } elsif (ref $title eq 'HASH') { %info = %$title; # return otherwise } else { croak <<'EOT'; Usage: set_mp3tag (FILE, TITLE, ARTIST, ALBUM, YEAR, COMMENT, GENRE [, TRACKNUM]), set_mp3tag (FILE, $HASHREF) EOT } croak 'No file specified' unless $file; # comment field length 28 if ID3v1.1 $v1_tag_fields{COMMENT} = 28 if $info{TRACKNUM}; # only if -w is on if ($^W) { # warn if fields too long foreach my $field (keys %v1_tag_fields) { if (length($info{$field}) > $v1_tag_fields{$field}) { carp "Data too long for field $field: truncated to ". "$v1_tag_fields{$field}"; } } if ($info{GENRE}) { carp "Genre `$info{GENRE}' does not exist\n" unless exists $mp3_genres{$info{GENRE}}; } } if ($info{TRACKNUM}) { unless ($info{TRACKNUM} =~ /^\d+$/ && $info{TRACKNUM} > 0 && $info{TRACKNUM} < 256) { carp "Tracknum `$info{TRACKNUM}' must be an integer " . "from 1 and 255\n" if $^W; $info{TRACKNUM} = ''; } } local *FILE; open FILE, "+< $file\0" or croak "Can't open '$file': $!"; binmode FILE; $oldfh = select FILE; seek FILE, -128, 2; # go to end of file if no tag, beginning of file if tag seek FILE, ( =~ /^TAG/ ? -128 : 0), 2; # get genre value $info{GENRE} = exists $mp3_genres{$info{GENRE}} ? $mp3_genres{$info{GENRE}} : 255; # some default genre # print TAG to file if ($info{TRACKNUM}) { print pack "a3a30a30a30a4a28xCC", 'TAG', @info{@v1_tag_names}; } else { print pack "a3a30a30a30a4a30C", 'TAG', @info{@v1_tag_names[0..4, 6]}; } select $oldfh; close FILE or carp "Problem closing '$file': $!"; 1; } =pod =item get_mp3tag (FILE [, VERSION, RAW_V2]) Returns hash reference containing tag information in MP3 file. Same info as described in C. If VERSION is C<1>, the information is taken from the ID3v1 tag (if present). If VERSION is C<2>, the information is taken from the ID3v2 tag (if present). If VERSION is not supplied, the ID3v1 tag is read if present, and then, if present, the ID3v2 tag information will override any existing ID3v1 tag info. If the ID3v2 version is older than ID3v2.3.0, it will not be read (and a warning will be issued if B<-w> is on). If RAW_V2 is false or not supplied and VERSION is C<2>, only the tags corresponding to ID3v1 tags are returned, with the same keys in the returned hashref. If RAW_V2 is true and VERSION is C<2>, C will return a hash of tag four-character IDs and their data. Tag IDs and their meanings are in the global hash (not exported) C<%v2_tag_names>. my $tag = get_mp3tag('mysong.mp3', 2, 1); # ID3v2, raw ID3v2 tags for (keys %$tag) { printf "%s => %s\n", $MP3::Info::v2_tag_names{$_}, $tag->{$_}; } =cut sub get_mp3tag { my($file, $ver, $raw_v2, $tag, $v1, $v2, %info, @array) = (@_[0 .. 2]); $ver ||= 0; croak 'No file specified' unless $file; local *FILE; open FILE, "< $file\0" or croak "Can't open '$file': $!"; binmode FILE; if ($ver < 2) { seek FILE, -128, 2; while(defined(my $line = )) { $tag .= $line } if ($tag =~ /^TAG/) { $v1 = 1; if (substr($tag, -3, 2) =~ /\000[^\000]/) { (undef, @info{@v1_tag_names}) = (unpack('a3a30a30a30a4a28', $tag), ord(substr($tag, -2, 1)), $mp3_genres[ord(substr $tag, -1)]); } else { (undef, @info{@v1_tag_names[0..4, 6]}) = (unpack('a3a30a30a30a4a30', $tag), $mp3_genres[ord(substr $tag, -1)]); } } } $v2 = _get_v2tag(\*FILE); return unless $v1 || $v2; if (($ver == 0 || $ver == 2) && $v2) { if ($raw_v2) { %info = %$v2; } else { for (keys %v2_to_v1_names) { if (exists $v2->{$_}) { if ($_ eq 'TCON' && $v2->{$_} =~ /^\((\d+)\)/) { $info{$v2_to_v1_names{$_}} = $mp3_genres[$1]; } else { $info{$v2_to_v1_names{$_}} = $v2->{$_}; } } } } } foreach my $key (keys %info) { if (defined $info{$key}) { $info{$key} =~ s/\s+$//; $info{$key} =~ s/\000.*//g; } } close FILE or carp "Problem closing '$file': $!"; return {%info}; } sub _get_v2tag { my($fh, $off, $myseek, $v2, $h) = ($_[0]); $myseek = sub { seek $fh, $off, 0; read $fh, my($bytes), 10; return unless $bytes =~ /^(\w{4})/; my($id, $size) = ($1, 10); my @bytes = reverse unpack 'C4', substr($bytes, 4, 4); for my $i (0 .. 3) { $size += $bytes[$i] * 256 ** $i; } return($id, $size); }; $v2 = _get_v2head($fh) or return; if ($v2->{major_version} < 3) { warn "This is $v2->{version}; " . "ID3v2 versions older than ID3v2.3.0 not supported\n" if $^W; return; } $off = $v2->{ext_header_size} + 10; while ($off < $v2->{tag_size}) { my($id, $size) = &$myseek or last; seek $fh, $off + 10, 0; read $fh, my($bytes), $size - 10; $bytes =~ s/\000//g; # necessary? if (exists $h->{$id}) { if (ref $h->{$id} eq 'ARRAY') { push @{$h->{$id}}, $bytes; } else { $h->{$id} = [$h->{$id}, $bytes]; } } else { $h->{$id} = $bytes; } $off += $size; } return $h; } =pod =item get_mp3info (FILE) Returns hash reference containing file information for MP3 file. This data cannot be changed. Returned data includes MP3 version (VERSION), total time in minutes (MM) and seconds (SS), boolean for STEREO, MPEG layer (LAYER), BITRATE, MODE, boolean for COPYRIGHT, and FREQUENCY. Variable bitrates not yet supported. See L<"TODO">. =cut sub get_mp3info { my($file, $off, $myseek, $byte, $eof, $h, $i, $tot) = ($_[0], 0); $tot = 4096; local *FILE; $myseek = sub { seek FILE, $off, 0; read FILE, $byte, 4; }; open FILE, "< $file\0" or croak "Can't open '$file': $!"; binmode FILE; &$myseek; if ($off == 0) { if (my $id3v2 = _get_v2head(\*FILE)) { $tot += $off += $id3v2->{tag_size}; &$myseek; } } $h = _get_head($byte); until (_is_mp3($h)) { $off++; &$myseek; $h = _get_head($byte); return if $off > $tot && !$try_harder; } my $vbr = _get_vbr(*FILE, $h, \$off); seek FILE, 0, 2; $eof = tell FILE; seek FILE, -128, 2; $off += 128 if =~ /^TAG/ ? 1 : 0; close FILE; if ($vbr) { $h->{bitrate} = (($vbr->{bytes} != 0 ? $vbr->{bytes} : ($eof - $off)) / $vbr->{frames}) * $h->{fs} / 144000; } $h->{'length'} = $h->{bitrate} == 0 ? 0 : (($eof - $off) * 8) / $h->{bitrate} / 10; $h->{secs} = $h->{'length'} / 100; $h->{freq_idx} = 3 * $h->{ID} + $h->{sampling_freq}; $i->{LAYER} = $h->{layer} <= 0 ? '' : $h->{layer} == 3 ? 1 : $h->{layer} == 1 ? 3 : $h->{layer}; $i->{VERSION} = $h->{IDR} == 2 ? 2 : $h->{IDR} == 3 ? 1 : $h->{IDR} == 0 ? 2.5 : 0; $i->{VBR} = $vbr ? 1 : 0; $i->{MM} = int $h->{secs} / 60; $i->{SS} = int $h->{secs} % 60; # ? ceil() ? leftover seconds? $i->{STEREO} = $h->{mode} == 3 ? 0 : 1; $i->{MODE} = $h->{mode}; $i->{COPYRIGHT} = $h->{copyright}; $i->{BITRATE} = $h->{bitrate} >= 0 ? int $h->{bitrate} : ''; $i->{FREQUENCY} = $h->{freq_idx} >= 0 ? $frequency_tbl[$h->{freq_idx}] : ''; return $i; } sub _get_head { my($byte, $bytes, $h) = $_[0]; $bytes = unpack('l', pack('L', unpack('N', $byte))); @$h{qw(IDR ID layer protection_bit bitrate_index sampling_freq padding_bit private_bit mode mode_extension copyright original emphasis version_index bytes)} = ( ($bytes>>19)&3, ($bytes>>19)&1, ($bytes>>17)&3, ($bytes>>16)&1, ($bytes>>12)&15, ($bytes>>10)&3, ($bytes>>9)&1, ($bytes>>8)&1, ($bytes>>6)&3, ($bytes>>4)&3, ($bytes>>3)&1, ($bytes>>2)&1, $bytes&3, ($bytes>>19)&3, $bytes ); $h->{bitrate} = $t_bitrate[$h->{ID}][3 - $h->{layer}][$h->{bitrate_index}]; $h->{fs} = $t_sampling_freq[$h->{ID}][$h->{sampling_freq}]; return $h; } sub _is_mp3 { my $h = $_[0] or return; return ! ( $h->{bitrate_index} == 0 || $h->{version_index} == 1 || ($h->{bytes} & 0xFFE00000) != 0xFFE00000 || !$h->{fs} || !$h->{bitrate} || $h->{bitrate_index} == 15 || !$h->{layer} || $h->{sampling_freq} == 3 || $h->{emphasis} == 2 || !$h->{bitrate_index} || ($h->{bytes} & 0xFFFF0000) == 0xFFFE0000 || ($h->{ID} == 1 && $h->{layer} == 3 && $h->{protection_bit} == 1) || ($h->{mode_extension} != 0 && $h->{mode} != 1) ); } sub _get_vbr { my($fh, $h, $roff) = @_; my($off, $bytes, @bytes, $myseek, $myunpack, %vbr); $off = $$roff; @_ = (); # closure confused if we don't do this $myseek = sub { my $n = $_[0] || 4; seek $fh, $off, 0; read $fh, $bytes, $n; $off += $n; }; $myunpack = sub { unpack('l', pack('L', unpack('N', $_[0]))); }; $off += 4; if ($h->{ID}) { # MPEG1 $off += $h->{mode} == 3 ? 17 : 32; } else { # MPEG2 $off += $h->{mode} == 3 ? 9 : 17; } &$myseek; return unless $bytes eq 'Xing'; &$myseek; $vbr{flags} = $myunpack->($bytes); if ($vbr{flags} & 1) { &$myseek; $vbr{frames} = $myunpack->($bytes); } if ($vbr{flags} & 2) { &$myseek; $vbr{bytes} = $myunpack->($bytes); } if ($vbr{flags} & 4) { $myseek->(100); $vbr{toc} = $myunpack->($bytes); } if ($vbr{flags} & 8) { &$myseek; $vbr{scale} = $myunpack->($bytes); } else { $vbr{scale} = -1; } $$roff = $off; return \%vbr; } sub _get_v2head { my $fh = $_[0] or return; my($h, $bytes, @bytes); # check first three bytes for 'ID3' seek $fh, 0, 0; read $fh, $bytes, 3; return unless $bytes eq 'ID3'; # get version read $fh, $bytes, 2; $h->{version} = sprintf "ID3v2.%d.%d", @$h{qw[major_version minor_version]} = unpack 'c2', $bytes; # get flags read $fh, $bytes, 1; @$h{qw[unsync ext_header experimental]} = (unpack 'b8', $bytes)[7, 6, 5]; # get ID3v2 tag length from bytes 7-10 $h->{tag_size} = 10; # include ID3v2 header size read $fh, $bytes, 4; @bytes = reverse unpack 'C4', $bytes; foreach my $i (0..3) { # whoaaaaaa nellllllyyyyyy! $h->{tag_size} += $bytes[$i] * 128 ** $i; } # get extended header size $h->{ext_header_size} = 0; if ($h->{ext_header}) { $h->{ext_header_size} += 10; read $fh, $bytes, 4; @bytes = reverse unpack 'C4', $bytes; for my $i (0..3) { $h->{ext_header_size} += $bytes[$i] * 256 ** $i; } } return $h; } BEGIN { @mp3_genres = ( 'Blues', 'Classic Rock', 'Country', 'Dance', 'Disco', 'Funk', 'Grunge', 'Hip-Hop', 'Jazz', 'Metal', 'New Age', 'Oldies', 'Other', 'Pop', 'R&B', 'Rap', 'Reggae', 'Rock', 'Techno', 'Industrial', 'Alternative', 'Ska', 'Death Metal', 'Pranks', 'Soundtrack', 'Euro-Techno', 'Ambient', 'Trip-Hop', 'Vocal', 'Jazz+Funk', 'Fusion', 'Trance', 'Classical', 'Instrumental', 'Acid', 'House', 'Game', 'Sound Clip', 'Gospel', 'Noise', 'AlternRock', 'Bass', 'Soul', 'Punk', 'Space', 'Meditative', 'Instrumental Pop', 'Instrumental Rock', 'Ethnic', 'Gothic', 'Darkwave', 'Techno-Industrial', 'Electronic', 'Pop-Folk', 'Eurodance', 'Dream', 'Southern Rock', 'Comedy', 'Cult', 'Gangsta', 'Top 40', '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', ); @winamp_genres = ( @mp3_genres, 'Folk', 'Folk-Rock', 'National Folk', 'Swing', 'Fast 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', 'Ballad', 'Power Ballad', 'Rhythmic Soul', 'Freestyle', 'Duet', 'Punk Rock', 'Drum Solo', 'Acapella', 'Euro-House', 'Dance Hall', ); @t_bitrate = ([ [0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256], [0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160], [0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160] ],[ [0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448], [0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384], [0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320] ]); @t_sampling_freq = ( [22050, 24000, 16000], [44100, 48000, 32000] ); @frequency_tbl = map {eval"${_}e-3"} @{$t_sampling_freq[0]}, @{$t_sampling_freq[1]}; %v1_tag_fields = (TITLE => 30, ARTIST => 30, ALBUM => 30, COMMENT => 30, YEAR => 4); @v1_tag_names = qw(TITLE ARTIST ALBUM YEAR COMMENT TRACKNUM GENRE); %v2_to_v1_names = ( 'TIT2' => 'TITLE', 'TPE1' => 'ARTIST', 'TALB' => 'ALBUM', 'TYER' => 'YEAR', 'COMM' => 'COMMENT', 'TRCK' => 'TRACKNUM', 'TCON' => 'GENRE', ); %v2_tag_names = ( 'AENC' => 'Audio encryption', 'APIC' => 'Attached picture', 'COMM' => 'Comments', 'COMR' => 'Commercial frame', 'ENCR' => 'Encryption method registration', 'EQUA' => 'Equalization', 'ETCO' => 'Event timing codes', 'GEOB' => 'General encapsulated object', 'GRID' => 'Group identification registration', 'IPLS' => 'Involved people list', 'LINK' => 'Linked information', 'MCDI' => 'Music CD identifier', 'MLLT' => 'MPEG location lookup table', 'OWNE' => 'Ownership frame', 'PCNT' => 'Play counter', 'POPM' => 'Popularimeter', 'POSS' => 'Position synchronisation frame', 'PRIV' => 'Private frame', 'RBUF' => 'Recommended buffer size', 'RVAD' => 'Relative volume adjustment', 'RVRB' => 'Reverb', 'SYLT' => 'Synchronized lyric/text', 'SYTC' => 'Synchronized tempo codes', 'TALB' => 'Album/Movie/Show title', 'TBPM' => 'BPM (beats per minute)', 'TCOM' => 'Composer', 'TCON' => 'Content type', 'TCOP' => 'Copyright message', 'TDAT' => 'Date', 'TDLY' => 'Playlist delay', 'TENC' => 'Encoded by', 'TEXT' => 'Lyricist/Text writer', 'TFLT' => 'File type', 'TIME' => 'Time', 'TIT1' => 'Content group description', 'TIT2' => 'Title/songname/content description', 'TIT3' => 'Subtitle/Description refinement', 'TKEY' => 'Initial key', 'TLAN' => 'Language(s)', 'TLEN' => 'Length', 'TMED' => 'Media type', 'TOAL' => 'Original album/movie/show title', 'TOFN' => 'Original filename', 'TOLY' => 'Original lyricist(s)/text writer(s)', 'TOPE' => 'Original artist(s)/performer(s)', 'TORY' => 'Original release year', 'TOWN' => 'File owner/licensee', 'TPE1' => 'Lead performer(s)/Soloist(s)', 'TPE2' => 'Band/orchestra/accompaniment', 'TPE3' => 'Conductor/performer refinement', 'TPE4' => 'Interpreted, remixed, or otherwise modified by', 'TPOS' => 'Part of a set', 'TPUB' => 'Publisher', 'TRCK' => 'Track number/Position in set', 'TRDA' => 'Recording dates', 'TRSN' => 'Internet radio station name', 'TRSO' => 'Internet radio station owner', 'TSIZ' => 'Size', 'TSRC' => 'ISRC (international standard recording code)', 'TSSE' => 'Software/Hardware and settings used for encoding', 'TXXX' => 'User defined text information frame', 'TYER' => 'Year', 'UFID' => 'Unique file identifier', 'USER' => 'Terms of use', 'USLT' => 'Unsychronized lyric/text transcription', 'WCOM' => 'Commercial information', 'WCOP' => 'Copyright/Legal information', 'WOAF' => 'Official audio file webpage', 'WOAR' => 'Official artist/performer webpage', 'WOAS' => 'Official audio source webpage', 'WORS' => 'Official internet radio station homepage', 'WPAY' => 'Payment', 'WPUB' => 'Publishers official webpage', 'WXXX' => 'User defined URL link frame', ); } __END__ =pod =back =head1 TROUBLESHOOTING If you find a bug, please send me a patch. If you cannot figure out why it does not work for you, please put the MP3 file in a place where I can get it (preferably via FTP) and send me mail regarding where I can get the file, with a detailed description of the problem. If I download the file, after debugging the problem I will not keep the MP3 file if it is not legal for me to have it. Just let me know if it is legal for me ot keep it or not. =head1 TODO =over 4 =item ID3v2 Support First go at adding support for reading ID3v2 tags. Still need to do more, such as using Compress::Zlib to decompress compressed tags. But until I see this in use more, I won't bother. I might not be able to support Unicode at all, until Perl supports 16-bit Unicode. If something does not work properly with reading, follow the instructions above for troubleshooting. Still need to add support for writing ID3v2 tags, and work on API a bit. =back =head1 HISTORY =over 4 =item v0.80, Monday, March 6, 2000 Better stripping of bad data (after nulls) in ID3 tags (Dave O'Neill) Fixed VERSION in get_mp3info to properly return 2 when appropriate. (Bogdan Surdu) Added VBR support. Average bitrate is returned as BITRATE, and minutes and seconds (MM and SS) should be accurate. (Andy Waite for pointer to MP3Ext) Made time calculation better overall. Made MP3 header validation routines more comprehensive. (Matthew Sachs for pointer to xmms source) Changed name to MP3::Info (with wrapper still named MP3::Info). =item v0.71, Thursday, July 8, 1999 Several fixes to ID3v2 support unpack unsigned instead of signed, don't bail out after 4096-byte offsets on long ID3v2 headers. Thanks much to Matthew Sachs. =item v0.70, Saturday, July 3, 1999 Added preliminary ID3v2 reading support in C. Thanks much to Tom Brown. =item v0.64, Thursday, July 1, 1999 Found bug in checking TRACKNUM parameter, used \d instead of \d+. Only gives spurious warnings, doesn't affect anything else. Cleaned up a bit, prepare for impending ID3v2 support. NOTE: truncate() broken in some builds of ActivePerl (517, maybe others). No changes to module to fix problem. (Brian Goodwin) =item v0.63, Friday, April 30, 1999 Added ID3v1.1 support. (Trond Michelsen, Pass F. B. Travis) Added 255 (\xFF) as default genre. (Andrew Phillips) I think I fixed bug relating to spaces in ID3v2 headers. (Tom Brown) =item v0.62, Sunday, March 7, 1999 Doc updates. Fix small unnoticable bug where ID3v2 offset is tag size plus 10, not just tag size. Not publickly released. =item v0.61, Monday, March 1, 1999 Fixed problem of not removing nulls on return from C (was using spaces for padding before ... now trailing whitespace and all nulls are removed before returning tag info). Made tests more extensive (more for my own sanity when making all these changes than to make sure it works on other platforms and machines :). =item v0.60, Sunday, February 28, 1999 Cleaned up a lot of stuff, added more comments, made C much faster and much more reliable, and added recognition of ID3v2 headers. (Tom Brown) =item v0.52, Sunday, February 21, 1999 Fixed problem in C that changed value of C<$_> in caller (Todd Hanneken). =item v0.51, Saturday, February 20, 1999 Fixed problem with C<%winamp_genres> having the wrong numbers (Matthew Sachs). =item v0.50, Friday, February 19, 1999 Added C. Addeed VERSION to the hash returned by C, and fixed a bug where STEREO was not being set correctly. Export all genre data structures on request. Added C to use WinAmp genres. (Roland Steinbach) Added a C<$MPEG::MP3Info::try_harder> (C<$MP3::Info::try_harder>) variable that will try harder to find the MP3 header in a file. False by default. Can take a long time to fail, but should find most headers at any offsets if set to true. Thanks to Matthew Sachs for his input and fixes, and for mp3tools. =item v0.20, Saturday, October 17, 1998 Changed name from C to C, because it does more than just TAG stuff now. Made header stuff even more reliable. Lots of help and testing from Meng Weng Wong again. :-) =item v0.13, Thursday, October 8, 1998 Had some problems with header verification, got some code from Predrag Supurovic with his mpgtools. Great stuff. Also did some looping to find a header if it is not in the "right" place. I did what I think it is a smart way to do it, since some files have the header as far down as 2 kbytes into the file. First, I look at position 0, then at position 36 (a position where I have found many headers), then I start at 0 again and jump in 128-byte chunks. Once I do that a bunch of times, I go back at the beginning and try at 0 and go ahead in 1-byte chunks for a bunch more times. If you have an MP3 that has the header begin at an odd place like byte 761, then I suggest you strip out the junk before the header begins. :-) =item v0.12, Friday, October 2, 1998 Added C. Thanks again to F source from Johann Lindvall, because I basically stole it straight (after converting it from C to Perl, of course). I did everything I could to find the header info, but if anyone has valid MP3 files that are not recognized, or has suggestions for improvement of the algorithms, let me know. =item v0.04, Tuesday, September 29, 1998 Changed a few things, replaced a regex with an C. (Meng Weng Wong) =item v0.03, Tuesday, September 8, 1998 First public release. =back =head1 THANKS Johann Lindvall, Meng Weng Wong Emengwong@pobox.comE, Predrag Supurovic Empgtools@dv.co.yuE, Matthew Sachs Ematthewg@zevils.comE, Peter Kovacs Ekovacsp@egr.uri.eduE, Roland Steinbach Eroland@support-system.comE, Todd Hanneken Ethanneken@hds.harvard.eduE, Tom Brown Ethecap@usa.netE, Andrew Phillips Easp@wasteland.orgE, Trond Michelsen Emike@crusaders.noE, Pass F. B. Travis Epftravis@bellsouth.netE, Vittorio Bertola Ev.bertola@vitaminic.comE, Brian Goodwin Ebrian@fuddmain.comE, Bogdan Surdu Etim@go.roE, Andy Waite Eandy@mailroute.comE, Chris Sidi Esidi@angband.orgE, Luke Drumm Elukedrumm@mypad.comE, Dave O'Neill Edave@nexus.carleton.caE, Edward Allen Eallenej@c51844-a.spokn1.wa.home.comE. =head1 AUTHOR AND COPYRIGHT Chris Nandor Epudge@pobox.comE, http://pudge.net/ Copyright (c) 2000 Chris Nandor. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License, distributed with Perl. =head1 SEE ALSO =over 4 =item mp3tools http://www.zevils.com/linux/mp3tools/ =item mpgtools http://www.dv.co.yu/mp3list/mpgtools.htm http://www.dv.co.yu/mp3list/mpeghdr.htm =item mp3tool http://www.dtek.chalmers.se/~d2linjo/mp3/mp3tool.html =item ID3v2 http://www.id3.org/ =item Xing Variable Bitrate http://www.xingtech.com/support/partner_developer/mp3/vbr_sdk/ =item MP3Ext http://rupert.informatik.uni-stuttgart.de/~mutschml/MP3ext/ =item Xmms http://www.xmms.org/ =back =head1 VERSION v0.80, Monday, March 6, 2000 =cut mp3report-1.0.3/README.md000066400000000000000000000046321373454643600147510ustar00rootroot00000000000000# Licensing Neon Goat MP3 Report Generator v1.0.2 - April 5, 2000 Copyright (C) 2000, David Parker, Neon Goat Productions. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See COPYING or http://www.gnu.org for more information. # Neon Goat MP3 Report Generator A customizable program to scan a list of (sub)directories, creating a report from an HTML template. Also calculates various statistics and each song's playing time. Supports ID3 and ID3v2 tags. Should work on any perl-ized OS; see homepage for demo (http://mp3report.sourceforge.net). # Configuring All options can be configured through the command line, see mp3report.pl --help for more info. You may also want to modify the hard coded defaults at the top of the program file. See documentation.html for information on customizing your own template file. # Usage Neon Goat MP3 Report Generator v1.0.2 Copyright (C) 2000, David Parker, Neon Goat Productions. www.neongoat.com - david@neongoat.com ``` Usage: mp3report.pl [options] [directory...] --help shows this help screen --printmode uses a smaller font for printing --title=TITLE sets the title used in the report --outfile=OUTFILE file to write report to, '-' for STDOUT --template=FILE file to use as report template --stdgenres use standard genres instead of winamp genres --id3v2 enable id3v2 support (experimental) directory... dirs to scan (subdirs included) ``` # Installing mp3report You should be able to run mp3report.pl directly after decompressing it: ``` tar xfzv mp3report-1.0.2.tar.gz cd mp3report-1.0.2 ./mp3report.pl --help ``` If your perl interpreter isn't in /usr/bin/perl, you'll need to change the first line of mp3report.pl If you'd like to install the MP3::Info perl module so that other programs can use it, it is available at http://search.cpan.org/search?dist=MP3-Info. # Acknowledgements Of course, much thanks to Chris Nandor and contributors to MP3::Info... it saved me a lot of time :) And to Larry Wall for such a great language. Hello to MMT, UCLA LUG, cX, and of course the DJs of Mister Balak's Neighborhood! David Parker david@neongoat.com http://www.neongoat.com http://mp3report.sourceforge.net mp3report-1.0.3/TODO000066400000000000000000000007261373454643600141620ustar00rootroot00000000000000TODO ---- make templates allow perl code, eperl-style report to multi-page HTML, sorted by letter, group, genre, etc. Write index to main page w/ stats cgi-ize for searching online and/or submitting checkbox array'd lists predef user funcs for finetuning urls, output display, etc. add url in docs/help for subscribing to new release announcements make install script, place into /usr/local/bin, /usr/local/lib/mp3report (for templates), etc? rpm/deb-ize into package? mp3report-1.0.3/default-template.html000066400000000000000000000120061373454643600176070ustar00rootroot00000000000000 $t_title $t_title


Generated: $t_datetime by Neon Goat MP3 Report Generator

Scanned directories:
  $t_dirs

Total number of dirs:   $t_numdirs
Total number of files:   $t_numfiles
Average file size:   $t_avgsize
Average playing time:   $t_avgplaytime
Total size of files:   $t_size
Total playing time:   $t_playtime

 $item_dir
$item_num.  $item_filename $item_len

Report completed in $t_exectime.


This report was generated with Neon Goat MP3 Report Generator.
Copyright © 2000, David Parker, Neon Goat Productions. All rights reserved.
This software is released under the GNU Genereal Public Licence, see http://www.gnu.org for more details.

mp3report-1.0.3/documentation.html000066400000000000000000000476351373454643600172430ustar00rootroot00000000000000 Neon Goat MP3 Report Generator - mp3report.pl

NAME

Neon Goat MP3 Report Generator - mp3report.pl


DESCRIPTION

 A customizable program to scan a list of (sub)directories, creating a report
 from an HTML template. Also calculates various statistics and each song's
 playing time. Supports ID3 and ID3v2 tags. Should work on any perl-ized OS;
 see homepage for demo - http://mp3report.sourceforge.net


CONFIGURING

 All options can be configured through the command line, see mp3report.pl --help
 for more info. You may also want to modify the hard coded defaults at the
 top of the program file.

 See documentation.html for information on customizing your own template file.


USAGE

 Usage: mp3report.pl [options] [directory...]
  --help                 shows this help screen
  --printmode            uses a smaller font for printing
  --title=TITLE          sets the title used in the report
  --outfile=OUTFILE      file to write report to, '-' for STDOUT
  --template=FILE        file to use as report template
  --stdgenres            use standard genres instead of winamp genres
  --id3v2                enable id3v2 support (experimental)
  directory...           dirs to scan (subdirs included)


INSTALLATION

 You should be able to run mp3report.pl directly after decompressing it:
 
 tar xfzv mp3report-1.0.2.tar.gz
 cd mp3report-1.0.2
 ./mp3report.pl --help
 
 If your perl interpreter isn't in /usr/bin/perl, you'll need to change the first line
 of mp3report.pl
 
 If you'd like to install the MP3::Info perl module so that other programs can
 use it, it is available at http://search.cpan.org/search?dist=MP3-Info.


CUSTOMIZATION AND TEMPLATES

By creating your own HTML file or modifying one of the provided templates, you can customize the output of MP3 Report Generator. These are the various identifiers that MP3 Report Generator can look for in a report:


General Information

$t_fontsize

This is either 1 or 2, depending on the --printmode flag. If printing mode is on, the idea is that the font size should be a little bit smaller so that it looks better on paper. To make sure this field does something, use <FONT SIZE="$t_fontsize"> in your HTML code.

$t_title

Used for the HTML <TITLE> tag as well as the first line of the report, and is set by specifying --title=SOMETHING on the command line.

$t_datetime

The local date and time when the report was generated.

$t_dirs

The list of parent directories that was scanned in the report. Each directory is separated by <BR&gt;&amp;nbsp;&amp;nbsp; so that they are on seperate lines and indented.

$t_numdirs

The total number of directories and subdirectories scanned in the report.

$t_numfiles

The total number of MP3 files included in the report.

$t_size

The total size of all MP3 files included in the report combined. This is formatted into ``x.xx GB (y.yy MB)''.

$t_playtime

The total playing time of all songs combined. This is formatted into an English sentence (4 days, 3 hours, 2 minutes, 1 second).

$t_exectime

The total time it took to genereate the report. This is formatted into an English sentence (4 days, 3 hours, 2 minutes, 1 second).

$t_avgsize

The average size of the MP3s in this report. This is formatted into ``x.xx MB''.

$t_avgplaytime

The average playing time of a single song in the report. This is formatted into an English sentence (3 hours, 2 minutes, 1 second).


Report Settings

$t_filename

The filename that the report is being written to.

$t_template_filename

The filename of the template that is being used.

$t_printmode

Either ``Yes'' or ``No'' depending on whether the --printmode flag was specified.

$t_customdirs

Either ``Yes'' or ``No'' depending on whether user specified custom directories to scan on the command line.

$t_genretype

Either ``Standard'' or ``WinAMP'' depending on whether or not the user specified --stdgenres.

$t_id3v2

Either ``Yes'' or ``No'' depending on whether the --id3v2 flag was specified.


Item Information

$item_dir

The current directory that is being scanned.

$item_num

The current sequential number of the item found.

$item_filename

The filename of the item found. NOTE: This in versions older than 1.0.2, this variable was called $item_name.

$item_size

The size of the item found. This is formatted into ``x.xx MB''.

$item_bgcolor

This will either be #FFFFFF or #EEEEEE (white or light gray) depending on whether or not the current item number is even or odd. This is used to make the cell color in tables alternate to make the report easier to read. In order for this to work, your HTML code must look something like &lt;TD BGCOLOR="$item_bgcolor"&gt;...&lt;/TD&gt;.

$item_len

The playing time of the song found, formatted into ``XX:YY'' (minutes:seconds).


MP3 Information

$item_totalseconds

The total number of seconds in the current song.

$item_mp3version

The MPEG version number of the current MP3, usually 1.

$item_stereo

Either ``Stereo'' or ``Mono'' depending on the number of channels in the MP3.

$item_mpeglayer

The MPEG layer number, usually 3.

$item_bitrate

The bitrate of the current MP3 in kbps.

$item_vbr

If the current MP3 is encoded at a variable bitrate, this will equal ``VBR''. If not, it will be a blank string.

$item_copyrighted

Either ``Copyrighted'' or ``Not copyrighted'' depending on the MP3's copyright flag.

$item_frequency

The frequency of the current MP3 in kHz.


ID3 Tag Information

$item_id3title

The song's ID3 title, maximum 30 characters.

$item_id3artist

The song's ID3 artist, maximum 30 characters.

$item_id3album

The song's ID3 album, maximum 30 characters.

$item_id3year

The song's ID3 year, maximum 4 characters.

$item_id3comment

The song's ID3 comment, maximum 30 characters (28 if the ID3 tag also contains a track number).

$item_id3genre

The song's ID3 genre. You may disable WinAMP genres by specifying the --stdgenres flag.

$item_id3tracknum

The song's ID3v1.1 track number (if present), maximum 2 characters.


ID3v2 Tag Information

ID3v2.3.0 (or later) tags are also supported. To enable ID3v2 support, use the --id3v2 flag on the command line. The following is taken from MPEG::MP3Info::v2_tag_names

$item_id3v2_wpay

WPAY: Payment

$item_id3v2_text

TEXT: Lyricist/Text writer

$item_id3v2_toly

TOLY: Original lyricist(s)/text writer(s)

$item_id3v2_tmed

TMED: Media type

$item_id3v2_rvad

RVAD: Relative volume adjustment

$item_id3v2_time

TIME: Time

$item_id3v2_rbuf

RBUF: Recommended buffer size

$item_id3v2_toal

TOAL: Original album/movie/show title

$item_id3v2_trck

TRCK: Track number/Position in set

$item_id3v2_ipls

IPLS: Involved people list

$item_id3v2_mllt

MLLT: MPEG location lookup table

$item_id3v2_tkey

TKEY: Initial key

$item_id3v2_apic

APIC: Attached picture

$item_id3v2_sytc

SYTC: Synchronized tempo codes

$item_id3v2_tyer

TYER: Year

$item_id3v2_tpos

TPOS: Part of a set

$item_id3v2_trsn

TRSN: Internet radio station name

$item_id3v2_ufid

UFID: Unique file identifier

$item_id3v2_trso

TRSO: Internet radio station owner

$item_id3v2_tsiz

TSIZ: Size

$item_id3v2_tenc

TENC: Encoded by

$item_id3v2_trda

TRDA: Recording dates

$item_id3v2_comm

COMM: Comments

$item_id3v2_sylt

SYLT: Synchronized lyric/text

$item_id3v2_woaf

WOAF: Official audio file webpage

$item_id3v2_link

LINK: Linked information

$item_id3v2_comr

COMR: Commercial frame

$item_id3v2_tbpm

TBPM: BPM (beats per minute)

$item_id3v2_pcnt

PCNT: Play counter

$item_id3v2_tofn

TOFN: Original filename

$item_id3v2_woar

WOAR: Official artist/performer webpage

$item_id3v2_woas

WOAS: Official audio source webpage

$item_id3v2_tpe1

TPE1: Lead performer(s)/Soloist(s)

$item_id3v2_tflt

TFLT: File type

$item_id3v2_tpe2

TPE2: Band/orchestra/accompaniment

$item_id3v2_tsrc

TSRC: ISRC (international standard recording code)

$item_id3v2_tpe3

TPE3: Conductor/performer refinement

$item_id3v2_rvrb

RVRB: Reverb

$item_id3v2_tpe4

TPE4: Interpreted, remixed, or otherwise modified by

$item_id3v2_mcdi

MCDI: Music CD identifier

$item_id3v2_tdly

TDLY: Playlist delay

$item_id3v2_tdat

TDAT: Date

$item_id3v2_tory

TORY: Original release year

$item_id3v2_tlan

TLAN: Language(s)

$item_id3v2_tcom

TCOM: Composer

$item_id3v2_tlen

TLEN: Length

$item_id3v2_tcon

TCON: Content type

$item_id3v2_tcop

TCOP: Copyright message

$item_id3v2_owne

OWNE: Ownership frame

$item_id3v2_tpub

TPUB: Publisher

$item_id3v2_txxx

TXXX: User defined text information frame

$item_id3v2_geob

GEOB: General encapsulated object

$item_id3v2_tsse

TSSE: Software/Hardware and settings used for encoding

$item_id3v2_priv

PRIV: Private frame

$item_id3v2_tit1

TIT1: Content group description

$item_id3v2_talb

TALB: Album/Movie/Show title

$item_id3v2_tit2

TIT2: Title/songname/content description

$item_id3v2_tit3

TIT3: Subtitle/Description refinement

$item_id3v2_poss

POSS: Position synchronisation frame

$item_id3v2_grid

GRID: Group identification registration

$item_id3v2_uslt

USLT: Unsychronized lyric/text transcription

$item_id3v2_encr

ENCR: Encryption method registration

$item_id3v2_town

TOWN: File owner/licensee

$item_id3v2_wors

WORS: Official internet radio station homepage

$item_id3v2_etco

ETCO: Event timing codes

$item_id3v2_equa

EQUA: Equalization

$item_id3v2_wcom

WCOM: Commercial information

$item_id3v2_aenc

AENC: Audio encryption

$item_id3v2_tope

TOPE: Original artist(s)/performer(s)

$item_id3v2_wcop

WCOP: Copyright/Legal information

$item_id3v2_popm

POPM: Popularimeter

$item_id3v2_wpub

WPUB: Publishers official webpage

$item_id3v2_wxxx

WXXX: User defined URL link frame

$item_id3v2_user

USER: Terms of use


ACKNOWLEDGEMENTS

 Much thanks to Chris Nandor and contributors to MP3::Info... 
 it saved me a lot of time :) And to Larry Wall for such a great language.
 
 Hello to MMT, UCLA LUG, cX, and of course the DJs of Mister Balak's Neighborhood!


SEE ALSO

MP3::Info

http://search.cpan.org/search?dist=MP3-Info

ID3v2

http://www.id3.org/

SourceForge

http://www.sourceforge.net Damn, these guys rock.

icecast

http://www.icecast.org


AUTHOR AND COPYRIGHT

 Neon Goat MP3 Report Generator
 v1.0.2 - April 5, 2000
 Copyright (C) 2000, David Parker, Neon Goat Productions.
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.
 
 See COPYING or http://www.gnu.org for more information.
 
 David Parker
 david@neongoat.com
 http://www.neongoat.com
 http://mp3report.sourceforge.net
mp3report-1.0.3/documentation.txt000066400000000000000000000300701373454643600170770ustar00rootroot00000000000000NAME Neon Goat MP3 Report Generator - mp3report.pl DESCRIPTION A customizable program to scan a list of (sub)directories, creating a report from an HTML template. Also calculates various statistics and each song's playing time. Supports ID3 and ID3v2 tags. Should work on any perl-ized OS; see homepage for demo - http://mp3report.sourceforge.net CONFIGURING All options can be configured through the command line, see mp3report.pl --help for more info. You may also want to modify the hard coded defaults at the top of the program file. See documentation.html for information on customizing your own template file. USAGE Usage: mp3report.pl [options] [directory...] --help shows this help screen --printmode uses a smaller font for printing --title=TITLE sets the title used in the report --outfile=OUTFILE file to write report to, '-' for STDOUT --template=FILE file to use as report template --stdgenres use standard genres instead of winamp genres --id3v2 enable id3v2 support (experimental) directory... dirs to scan (subdirs included) INSTALLATION You should be able to run mp3report.pl directly after decompressing it: tar xfzv mp3report-1.0.2.tar.gz cd mp3report-1.0.2 ./mp3report.pl --help If your perl interpreter isn't in /usr/bin/perl, you'll need to change the first line of mp3report.pl If you'd like to install the MP3::Info perl module so that other programs can use it, it is available at http://search.cpan.org/search?dist=MP3-Info. CUSTOMIZATION AND TEMPLATES By creating your own HTML file or modifying one of the provided templates, you can customize the output of MP3 Report Generator. These are the various identifiers that MP3 Report Generator can look for in a report: General Information $t_fontsize This is either 1 or 2, depending on the `--printmode' flag. If printing mode is on, the idea is that the font size should be a little bit smaller so that it looks better on paper. To make sure this field does something, use ` in your HTML code. $t_title Used for the HTML ` tag as well as the first line of the report, and is set by specifying `--title=SOMETHING' on the command line. $t_datetime The local date and time when the report was generated. $t_dirs The list of parent directories that was scanned in the report. Each directory is separated by `'`...'. $item_len The playing time of the song found, formatted into "XX:YY" (minutes:seconds). MP3 Information $item_totalseconds The total number of seconds in the current song. $item_mp3version The MPEG version number of the current MP3, usually 1. $item_stereo Either "Stereo" or "Mono" depending on the number of channels in the MP3. $item_mpeglayer The MPEG layer number, usually 3. $item_bitrate The bitrate of the current MP3 in kbps. $item_vbr If the current MP3 is encoded at a variable bitrate, this will equal "VBR". If not, it will be a blank string. $item_copyrighted Either "Copyrighted" or "Not copyrighted" depending on the MP3's copyright flag. $item_frequency The frequency of the current MP3 in kHz. ID3 Tag Information $item_id3title The song's ID3 title, maximum 30 characters. $item_id3artist The song's ID3 artist, maximum 30 characters. $item_id3album The song's ID3 album, maximum 30 characters. $item_id3year The song's ID3 year, maximum 4 characters. $item_id3comment The song's ID3 comment, maximum 30 characters (28 if the ID3 tag also contains a track number). $item_id3genre The song's ID3 genre. You may disable WinAMP genres by specifying the `--stdgenres' flag. $item_id3tracknum The song's ID3v1.1 track number (if present), maximum 2 characters. ID3v2 Tag Information ID3v2.3.0 (or later) tags are also supported. To enable ID3v2 support, use the `--id3v2' flag on the command line. The following is taken from `MPEG::MP3Info::v2_tag_names' $item_id3v2_wpay WPAY: Payment $item_id3v2_text TEXT: Lyricist/Text writer $item_id3v2_toly TOLY: Original lyricist(s)/text writer(s) $item_id3v2_tmed TMED: Media type $item_id3v2_rvad RVAD: Relative volume adjustment $item_id3v2_time TIME: Time $item_id3v2_rbuf RBUF: Recommended buffer size $item_id3v2_toal TOAL: Original album/movie/show title $item_id3v2_trck TRCK: Track number/Position in set $item_id3v2_ipls IPLS: Involved people list $item_id3v2_mllt MLLT: MPEG location lookup table $item_id3v2_tkey TKEY: Initial key $item_id3v2_apic APIC: Attached picture $item_id3v2_sytc SYTC: Synchronized tempo codes $item_id3v2_tyer TYER: Year $item_id3v2_tpos TPOS: Part of a set $item_id3v2_trsn TRSN: Internet radio station name $item_id3v2_ufid UFID: Unique file identifier $item_id3v2_trso TRSO: Internet radio station owner $item_id3v2_tsiz TSIZ: Size $item_id3v2_tenc TENC: Encoded by $item_id3v2_trda TRDA: Recording dates $item_id3v2_comm COMM: Comments $item_id3v2_sylt SYLT: Synchronized lyric/text $item_id3v2_woaf WOAF: Official audio file webpage $item_id3v2_link LINK: Linked information $item_id3v2_comr COMR: Commercial frame $item_id3v2_tbpm TBPM: BPM (beats per minute) $item_id3v2_pcnt PCNT: Play counter $item_id3v2_tofn TOFN: Original filename $item_id3v2_woar WOAR: Official artist/performer webpage $item_id3v2_woas WOAS: Official audio source webpage $item_id3v2_tpe1 TPE1: Lead performer(s)/Soloist(s) $item_id3v2_tflt TFLT: File type $item_id3v2_tpe2 TPE2: Band/orchestra/accompaniment $item_id3v2_tsrc TSRC: ISRC (international standard recording code) $item_id3v2_tpe3 TPE3: Conductor/performer refinement $item_id3v2_rvrb RVRB: Reverb $item_id3v2_tpe4 TPE4: Interpreted, remixed, or otherwise modified by $item_id3v2_mcdi MCDI: Music CD identifier $item_id3v2_tdly TDLY: Playlist delay $item_id3v2_tdat TDAT: Date $item_id3v2_tory TORY: Original release year $item_id3v2_tlan TLAN: Language(s) $item_id3v2_tcom TCOM: Composer $item_id3v2_tlen TLEN: Length $item_id3v2_tcon TCON: Content type $item_id3v2_tcop TCOP: Copyright message $item_id3v2_owne OWNE: Ownership frame $item_id3v2_tpub TPUB: Publisher $item_id3v2_txxx TXXX: User defined text information frame $item_id3v2_geob GEOB: General encapsulated object $item_id3v2_tsse TSSE: Software/Hardware and settings used for encoding $item_id3v2_priv PRIV: Private frame $item_id3v2_tit1 TIT1: Content group description $item_id3v2_talb TALB: Album/Movie/Show title $item_id3v2_tit2 TIT2: Title/songname/content description $item_id3v2_tit3 TIT3: Subtitle/Description refinement $item_id3v2_poss POSS: Position synchronisation frame $item_id3v2_grid GRID: Group identification registration $item_id3v2_uslt USLT: Unsychronized lyric/text transcription $item_id3v2_encr ENCR: Encryption method registration $item_id3v2_town TOWN: File owner/licensee $item_id3v2_wors WORS: Official internet radio station homepage $item_id3v2_etco ETCO: Event timing codes $item_id3v2_equa EQUA: Equalization $item_id3v2_wcom WCOM: Commercial information $item_id3v2_aenc AENC: Audio encryption $item_id3v2_tope TOPE: Original artist(s)/performer(s) $item_id3v2_wcop WCOP: Copyright/Legal information $item_id3v2_popm POPM: Popularimeter $item_id3v2_wpub WPUB: Publishers official webpage $item_id3v2_wxxx WXXX: User defined URL link frame $item_id3v2_user USER: Terms of use ACKNOWLEDGEMENTS Much thanks to Chris Nandor and contributors to MP3::Info... it saved me a lot of time :) And to Larry Wall for such a great language. Hello to MMT, UCLA LUG, cX, and of course the DJs of Mister Balak's Neighborhood! SEE ALSO MP3::Info http://search.cpan.org/search?dist=MP3-Info ID3v2 http://www.id3.org/ SourceForge http://www.sourceforge.net Damn, these guys rock. icecast http://www.icecast.org AUTHOR AND COPYRIGHT Neon Goat MP3 Report Generator v1.0.2 - April 5, 2000 Copyright (C) 2000, David Parker, Neon Goat Productions. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See COPYING or http://www.gnu.org for more information. David Parker david@neongoat.com http://www.neongoat.com http://mp3report.sourceforge.net mp3report-1.0.3/extended-template.html000066400000000000000000000122271373454643600177700ustar00rootroot00000000000000 $t_title $t_title


Generated: $t_datetime by Neon Goat MP3 Report Generator

Scanned directories:
  $t_dirs

Total number of dirs:   $t_numdirs
Total number of files:   $t_numfiles
Average file size:   $t_avgsize
Average playing time:   $t_avgplaytime
Total size of files:   $t_size
Total playing time:   $t_playtime

 $item_dir
$item_num.  $item_filename
$item_size - MPEG $item_mp3version Layer $item_mpeglayer, $item_bitrate kbps, $item_frequency kHz, $item_stereo
$item_len

Report completed in $t_exectime.


This report was generated with Neon Goat MP3 Report Generator.
Copyright © 2000, David Parker, Neon Goat Productions. All rights reserved.
This software is released under the GNU Genereal Public Licence, see http://www.gnu.org for more details.

mp3report-1.0.3/mp3report.1000066400000000000000000000477131373454643600155160ustar00rootroot00000000000000.rn '' }` ''' $RCSfile$$Revision$$Date$ ''' ''' $Log$ ''' .de Sh .br .if t .Sp .ne 5 .PP \fB\\$1\fR .PP .. .de Sp .if t .sp .5v .if n .sp .. .de Ip .br .ie \\n(.$>=3 .ne \\$3 .el .ne 3 .IP "\\$1" \\$2 .. .de Vb .ft CW .nf .ne \\$1 .. .de Ve .ft R .fi .. ''' ''' ''' Set up \*(-- to give an unbreakable dash; ''' string Tr holds user defined translation string. ''' Bell System Logo is used as a dummy character. ''' .tr \(*W-|\(bv\*(Tr .ie n \{\ .ds -- \(*W- .ds PI pi .if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch .if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch .ds L" "" .ds R" "" ''' \*(M", \*(S", \*(N" and \*(T" are the equivalent of ''' \*(L" and \*(R", except that they are used on ".xx" lines, ''' such as .IP and .SH, which do another additional levels of ''' double-quote interpretation .ds M" """ .ds S" """ .ds N" """"" .ds T" """"" .ds L' ' .ds R' ' .ds M' ' .ds S' ' .ds N' ' .ds T' ' 'br\} .el\{\ .ds -- \(em\| .tr \*(Tr .ds L" `` .ds R" '' .ds M" `` .ds S" '' .ds N" `` .ds T" '' .ds L' ` .ds R' ' .ds M' ` .ds S' ' .ds N' ` .ds T' ' .ds PI \(*p 'br\} .\" If the F register is turned on, we'll generate .\" index entries out stderr for the following things: .\" TH Title .\" SH Header .\" Sh Subsection .\" Ip Item .\" X<> Xref (embedded .\" Of course, you have to process the output yourself .\" in some meaninful fashion. .if \nF \{ .de IX .tm Index:\\$1\t\\n%\t"\\$2" .. .nr % 0 .rr F .\} .TH MP3REPORT 1 "perl 5.005, patch 03" "5/Apr/2000" "User Contributed Perl Documentation" .UC .if n .hy 0 .if n .na .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .de CQ \" put $1 in typewriter font .ft CW 'if n "\c 'if t \\&\\$1\c 'if n \\&\\$1\c 'if n \&" \\&\\$2 \\$3 \\$4 \\$5 \\$6 \\$7 '.ft R .. .\" @(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2 . \" AM - accent mark definitions .bd B 3 . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds ? ? . ds ! ! . ds / . ds q .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds ? \s-2c\h'-\w'c'u*7/10'\u\h'\*(#H'\zi\d\s+2\h'\w'c'u*8/10' . ds ! \s-2\(or\s+2\h'-\w'\(or'u'\v'-.8m'.\v'.8m' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' . ds q o\h'-\w'o'u*8/10'\s-4\v'.4m'\z\(*i\v'-.4m'\s+4\h'\w'o'u*8/10' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds v \\k:\h'-(\\n(.wu*9/10-\*(#H)'\v'-\*(#V'\*(#[\s-4v\s0\v'\*(#V'\h'|\\n:u'\*(#] .ds _ \\k:\h'-(\\n(.wu*9/10-\*(#H+(\*(#F*2/3))'\v'-.4m'\z\(hy\v'.4m'\h'|\\n:u' .ds . \\k:\h'-(\\n(.wu*8/10)'\v'\*(#V*4/10'\z.\v'-\*(#V*4/10'\h'|\\n:u' .ds 3 \*(#[\v'.2m'\s-2\&3\s0\v'-.2m'\*(#] .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E .ds oe o\h'-(\w'o'u*4/10)'e .ds Oe O\h'-(\w'O'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds v \h'-1'\o'\(aa\(ga' . ds _ \h'-1'^ . ds . \h'-1'. . ds 3 3 . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE . ds oe oe . ds Oe OE .\} .rm #[ #] #H #V #F C .SH "NAME" Neon Goat MP3 Report Generator \- mp3report.pl .SH "DESCRIPTION" .PP .Vb 4 \& A customizable program to scan a list of (sub)directories, creating a report \& from an HTML template. Also calculates various statistics and each song's \& playing time. Supports ID3 and ID3v2 tags. Should work on any perl-ized OS; \& see homepage for demo - http://mp3report.sourceforge.net .Ve .SH "CONFIGURING" .PP .Vb 3 \& All options can be configured through the command line, see mp3report.pl --help \& for more info. You may also want to modify the hard coded defaults at the \& top of the program file. .Ve .Vb 1 \& See documentation.html for information on customizing your own template file. .Ve .SH "USAGE" .PP .Vb 9 \& Usage: mp3report.pl [options] [directory...] \& --help shows this help screen \& --printmode uses a smaller font for printing \& --title=TITLE sets the title used in the report \& --outfile=OUTFILE file to write report to, '-' for STDOUT \& --template=FILE file to use as report template \& --stdgenres use standard genres instead of winamp genres \& --id3v2 enable id3v2 support (experimental) \& directory... dirs to scan (subdirs included) .Ve .SH "INSTALLATION" .PP .Vb 11 \& You should be able to run mp3report.pl directly after decompressing it: \& \& tar xfzv mp3report-1.0.2.tar.gz \& cd mp3report-1.0.2 \& ./mp3report.pl --help \& \& If your perl interpreter isn't in /usr/bin/perl, you'll need to change the first line \& of mp3report.pl \& \& If you'd like to install the MP3::Info perl module so that other programs can \& use it, it is available at http://search.cpan.org/search?dist=MP3-Info. .Ve .SH "CUSTOMIZATION AND TEMPLATES" By creating your own HTML file or modifying one of the provided templates, you can customize the output of MP3 Report Generator. These are the various identifiers that MP3 Report Generator can look for in a report: .Sh "General Information" .Ip "$t_fontsize" 4 This is either 1 or 2, depending on the \f(CW--printmode\fR flag. If printing mode is on, the idea is that the font size should be a little bit smaller so that it looks better on paper. To make sure this field does something, use \f(CW in your \s-1HTML\s0 code. .Ip "$t_title" 4 Used for the \s-1HTML\s0 \f(CW tag as well as the first line of the report, and is set by specifying \f(CW--title=SOMETHING\fR on the command line. .Ip "$t_datetime" 4 The local date and time when the report was generated. .Ip "$t_dirs" 4 The list of parent directories that was scanned in the report. Each directory is separated by \f(CW\fR\f(CW...\fR. .Ip "$item_len" 4 The playing time of the song found, formatted into \*(L"\s-1XX:YY\s0\*(R" (minutes:seconds). .Sh "\s-1MP3\s0 Information" .Ip "$item_totalseconds" 4 The total number of seconds in the current song. .Ip "$item_mp3version" 4 The \s-1MPEG\s0 version number of the current \s-1MP3\s0, usually 1. .Ip "$item_stereo" 4 Either \*(L"Stereo\*(R" or \*(L"Mono\*(R" depending on the number of channels in the \s-1MP3\s0. .Ip "$item_mpeglayer" 4 The \s-1MPEG\s0 layer number, usually 3. .Ip "$item_bitrate" 4 The bitrate of the current \s-1MP3\s0 in kbps. .Ip "$item_vbr" 4 If the current \s-1MP3\s0 is encoded at a variable bitrate, this will equal \*(L"\s-1VBR\s0\*(R". If not, it will be a blank string. .Ip "$item_copyrighted" 4 Either \*(L"Copyrighted\*(R" or \*(L"Not copyrighted\*(R" depending on the \s-1MP3\s0's copyright flag. .Ip "$item_frequency" 4 The frequency of the current \s-1MP3\s0 in kHz. .Sh "\s-1ID3\s0 Tag Information" .Ip "$item_id3title" 4 The song's \s-1ID3\s0 title, maximum 30 characters. .Ip "$item_id3artist" 4 The song's \s-1ID3\s0 artist, maximum 30 characters. .Ip "$item_id3album" 4 The song's \s-1ID3\s0 album, maximum 30 characters. .Ip "$item_id3year" 4 The song's \s-1ID3\s0 year, maximum 4 characters. .Ip "$item_id3comment" 4 The song's \s-1ID3\s0 comment, maximum 30 characters (28 if the \s-1ID3\s0 tag also contains a track number). .Ip "$item_id3genre" 4 The song's \s-1ID3\s0 genre. You may disable WinAMP genres by specifying the \f(CW--stdgenres\fR flag. .Ip "$item_id3tracknum" 4 The song's ID3v1.1 track number (if present), maximum 2 characters. .Sh "ID3v2 Tag Information" ID3v2.3.0 (or later) tags are also supported. To enable ID3v2 support, use the \f(CW--id3v2\fR flag on the command line. The following is taken from \f(CWMPEG::MP3Info::v2_tag_names\fR .Ip "$item_id3v2_wpay" 4 \s-1WPAY\s0: Payment .Ip "$item_id3v2_text" 4 \s-1TEXT\s0: Lyricist/Text writer .Ip "$item_id3v2_toly" 4 \s-1TOLY\s0: Original \fIlyricist\fR\|(s)/text \fIwriter\fR\|(s) .Ip "$item_id3v2_tmed" 4 \s-1TMED\s0: Media type .Ip "$item_id3v2_rvad" 4 \s-1RVAD\s0: Relative volume adjustment .Ip "$item_id3v2_time" 4 \s-1TIME\s0: Time .Ip "$item_id3v2_rbuf" 4 \s-1RBUF\s0: Recommended buffer size .Ip "$item_id3v2_toal" 4 \s-1TOAL\s0: Original album/movie/show title .Ip "$item_id3v2_trck" 4 \s-1TRCK\s0: Track number/Position in set .Ip "$item_id3v2_ipls" 4 \s-1IPLS\s0: Involved people list .Ip "$item_id3v2_mllt" 4 \s-1MLLT\s0: \s-1MPEG\s0 location lookup table .Ip "$item_id3v2_tkey" 4 \s-1TKEY\s0: Initial key .Ip "$item_id3v2_apic" 4 \s-1APIC\s0: Attached picture .Ip "$item_id3v2_sytc" 4 \s-1SYTC\s0: Synchronized tempo codes .Ip "$item_id3v2_tyer" 4 \s-1TYER\s0: Year .Ip "$item_id3v2_tpos" 4 \s-1TPOS\s0: Part of a set .Ip "$item_id3v2_trsn" 4 \s-1TRSN\s0: Internet radio station name .Ip "$item_id3v2_ufid" 4 \s-1UFID\s0: Unique file identifier .Ip "$item_id3v2_trso" 4 \s-1TRSO\s0: Internet radio station owner .Ip "$item_id3v2_tsiz" 4 \s-1TSIZ\s0: Size .Ip "$item_id3v2_tenc" 4 \s-1TENC\s0: Encoded by .Ip "$item_id3v2_trda" 4 \s-1TRDA\s0: Recording dates .Ip "$item_id3v2_comm" 4 \s-1COMM\s0: Comments .Ip "$item_id3v2_sylt" 4 \s-1SYLT\s0: Synchronized lyric/text .Ip "$item_id3v2_woaf" 4 \s-1WOAF\s0: Official audio file webpage .Ip "$item_id3v2_link" 4 \s-1LINK\s0: Linked information .Ip "$item_id3v2_comr" 4 \s-1COMR\s0: Commercial frame .Ip "$item_id3v2_tbpm" 4 \s-1TBPM\s0: \s-1BPM\s0 (beats per minute) .Ip "$item_id3v2_pcnt" 4 \s-1PCNT\s0: Play counter .Ip "$item_id3v2_tofn" 4 \s-1TOFN\s0: Original filename .Ip "$item_id3v2_woar" 4 \s-1WOAR\s0: Official artist/performer webpage .Ip "$item_id3v2_woas" 4 \s-1WOAS\s0: Official audio source webpage .Ip "$item_id3v2_tpe1" 4 \s-1TPE1\s0: Lead \fIperformer\fR\|(s)/\fISoloist\fR\|(s) .Ip "$item_id3v2_tflt" 4 \s-1TFLT\s0: File type .Ip "$item_id3v2_tpe2" 4 \s-1TPE2\s0: Band/orchestra/accompaniment .Ip "$item_id3v2_tsrc" 4 \s-1TSRC\s0: \s-1ISRC\s0 (international standard recording code) .Ip "$item_id3v2_tpe3" 4 \s-1TPE3\s0: Conductor/performer refinement .Ip "$item_id3v2_rvrb" 4 \s-1RVRB\s0: Reverb .Ip "$item_id3v2_tpe4" 4 \s-1TPE4\s0: Interpreted, remixed, or otherwise modified by .Ip "$item_id3v2_mcdi" 4 \s-1MCDI\s0: Music \s-1CD\s0 identifier .Ip "$item_id3v2_tdly" 4 \s-1TDLY\s0: Playlist delay .Ip "$item_id3v2_tdat" 4 \s-1TDAT\s0: Date .Ip "$item_id3v2_tory" 4 \s-1TORY\s0: Original release year .Ip "$item_id3v2_tlan" 4 \s-1TLAN\s0: \fILanguage\fR\|(s) .Ip "$item_id3v2_tcom" 4 \s-1TCOM\s0: Composer .Ip "$item_id3v2_tlen" 4 \s-1TLEN\s0: Length .Ip "$item_id3v2_tcon" 4 \s-1TCON\s0: Content type .Ip "$item_id3v2_tcop" 4 \s-1TCOP\s0: Copyright message .Ip "$item_id3v2_owne" 4 \s-1OWNE\s0: Ownership frame .Ip "$item_id3v2_tpub" 4 \s-1TPUB\s0: Publisher .Ip "$item_id3v2_txxx" 4 \s-1TXXX\s0: User defined text information frame .Ip "$item_id3v2_geob" 4 \s-1GEOB\s0: General encapsulated object .Ip "$item_id3v2_tsse" 4 \s-1TSSE\s0: Software/Hardware and settings used for encoding .Ip "$item_id3v2_priv" 4 \s-1PRIV\s0: Private frame .Ip "$item_id3v2_tit1" 4 \s-1TIT1\s0: Content group description .Ip "$item_id3v2_talb" 4 \s-1TALB\s0: Album/Movie/Show title .Ip "$item_id3v2_tit2" 4 \s-1TIT2\s0: Title/songname/content description .Ip "$item_id3v2_tit3" 4 \s-1TIT3\s0: Subtitle/Description refinement .Ip "$item_id3v2_poss" 4 \s-1POSS\s0: Position synchronisation frame .Ip "$item_id3v2_grid" 4 \s-1GRID\s0: Group identification registration .Ip "$item_id3v2_uslt" 4 \s-1USLT\s0: Unsychronized lyric/text transcription .Ip "$item_id3v2_encr" 4 \s-1ENCR\s0: Encryption method registration .Ip "$item_id3v2_town" 4 \s-1TOWN\s0: File owner/licensee .Ip "$item_id3v2_wors" 4 \s-1WORS\s0: Official internet radio station homepage .Ip "$item_id3v2_etco" 4 \s-1ETCO\s0: Event timing codes .Ip "$item_id3v2_equa" 4 \s-1EQUA\s0: Equalization .Ip "$item_id3v2_wcom" 4 \s-1WCOM\s0: Commercial information .Ip "$item_id3v2_aenc" 4 \s-1AENC\s0: Audio encryption .Ip "$item_id3v2_tope" 4 \s-1TOPE\s0: Original \fIartist\fR\|(s)/\fIperformer\fR\|(s) .Ip "$item_id3v2_wcop" 4 \s-1WCOP\s0: Copyright/Legal information .Ip "$item_id3v2_popm" 4 \s-1POPM\s0: Popularimeter .Ip "$item_id3v2_wpub" 4 \s-1WPUB\s0: Publishers official webpage .Ip "$item_id3v2_wxxx" 4 \s-1WXXX\s0: User defined \s-1URL\s0 link frame .Ip "$item_id3v2_user" 4 \s-1USER\s0: Terms of use .SH "ACKNOWLEDGEMENTS" .PP .Vb 4 \& Much thanks to Chris Nandor and contributors to MP3::Info... \& it saved me a lot of time :) And to Larry Wall for such a great language. \& \& Hello to MMT, UCLA LUG, cX, and of course the DJs of Mister Balak's Neighborhood! .Ve .SH "SEE ALSO" .Ip "\s-1MP3::\s0Info" 4 http://search.cpan.org/search?dist=\s-1MP3-\s0Info .Ip "ID3v2" 4 http://www.id3.org/ .Ip "SourceForge" 4 http://www.sourceforge.net Damn, these guys rock. .Ip "icecast" 4 http://www.icecast.org .SH "AUTHOR AND COPYRIGHT" .PP .Vb 15 \& Neon Goat MP3 Report Generator \& v1.0.2 - April 5, 2000 \& Copyright (C) 2000, David Parker, Neon Goat Productions. \& \& This program is free software; you can redistribute it and/or modify \& it under the terms of the GNU General Public License as published by \& the Free Software Foundation; either version 2 of the License, or \& (at your option) any later version. \& \& See COPYING or http://www.gnu.org for more information. \& \& David Parker \& david@neongoat.com \& http://www.neongoat.com \& http://mp3report.sourceforge.net .Ve .rn }` '' .IX Title "MP3REPORT 1" .IX Name "Neon Goat MP3 Report Generator - mp3report.pl" .IX Header "NAME" .IX Header "DESCRIPTION" .IX Header "CONFIGURING" .IX Header "USAGE" .IX Header "INSTALLATION" .IX Header "CUSTOMIZATION AND TEMPLATES" .IX Subsection "General Information" .IX Item "$t_fontsize" .IX Item "$t_title" .IX Item "$t_datetime" .IX Item "$t_dirs" .IX Item "$t_numdirs" .IX Item "$t_numfiles" .IX Item "$t_size" .IX Item "$t_playtime" .IX Item "$t_exectime" .IX Item "$t_avgsize" .IX Item "$t_avgplaytime" .IX Subsection "Report Settings" .IX Item "$t_filename" .IX Item "$t_template_filename" .IX Item "$t_printmode" .IX Item "$t_customdirs" .IX Item "$t_genretype" .IX Item "$t_id3v2" .IX Subsection "Item Information" .IX Item "$item_dir" .IX Item "$item_num" .IX Item "$item_filename" .IX Item "$item_size" .IX Item "$item_bgcolor" .IX Item "$item_len" .IX Subsection "\s-1MP3\s0 Information" .IX Item "$item_totalseconds" .IX Item "$item_mp3version" .IX Item "$item_stereo" .IX Item "$item_mpeglayer" .IX Item "$item_bitrate" .IX Item "$item_vbr" .IX Item "$item_copyrighted" .IX Item "$item_frequency" .IX Subsection "\s-1ID3\s0 Tag Information" .IX Item "$item_id3title" .IX Item "$item_id3artist" .IX Item "$item_id3album" .IX Item "$item_id3year" .IX Item "$item_id3comment" .IX Item "$item_id3genre" .IX Item "$item_id3tracknum" .IX Subsection "ID3v2 Tag Information" .IX Item "$item_id3v2_wpay" .IX Item "$item_id3v2_text" .IX Item "$item_id3v2_toly" .IX Item "$item_id3v2_tmed" .IX Item "$item_id3v2_rvad" .IX Item "$item_id3v2_time" .IX Item "$item_id3v2_rbuf" .IX Item "$item_id3v2_toal" .IX Item "$item_id3v2_trck" .IX Item "$item_id3v2_ipls" .IX Item "$item_id3v2_mllt" .IX Item "$item_id3v2_tkey" .IX Item "$item_id3v2_apic" .IX Item "$item_id3v2_sytc" .IX Item "$item_id3v2_tyer" .IX Item "$item_id3v2_tpos" .IX Item "$item_id3v2_trsn" .IX Item "$item_id3v2_ufid" .IX Item "$item_id3v2_trso" .IX Item "$item_id3v2_tsiz" .IX Item "$item_id3v2_tenc" .IX Item "$item_id3v2_trda" .IX Item "$item_id3v2_comm" .IX Item "$item_id3v2_sylt" .IX Item "$item_id3v2_woaf" .IX Item "$item_id3v2_link" .IX Item "$item_id3v2_comr" .IX Item "$item_id3v2_tbpm" .IX Item "$item_id3v2_pcnt" .IX Item "$item_id3v2_tofn" .IX Item "$item_id3v2_woar" .IX Item "$item_id3v2_woas" .IX Item "$item_id3v2_tpe1" .IX Item "$item_id3v2_tflt" .IX Item "$item_id3v2_tpe2" .IX Item "$item_id3v2_tsrc" .IX Item "$item_id3v2_tpe3" .IX Item "$item_id3v2_rvrb" .IX Item "$item_id3v2_tpe4" .IX Item "$item_id3v2_mcdi" .IX Item "$item_id3v2_tdly" .IX Item "$item_id3v2_tdat" .IX Item "$item_id3v2_tory" .IX Item "$item_id3v2_tlan" .IX Item "$item_id3v2_tcom" .IX Item "$item_id3v2_tlen" .IX Item "$item_id3v2_tcon" .IX Item "$item_id3v2_tcop" .IX Item "$item_id3v2_owne" .IX Item "$item_id3v2_tpub" .IX Item "$item_id3v2_txxx" .IX Item "$item_id3v2_geob" .IX Item "$item_id3v2_tsse" .IX Item "$item_id3v2_priv" .IX Item "$item_id3v2_tit1" .IX Item "$item_id3v2_talb" .IX Item "$item_id3v2_tit2" .IX Item "$item_id3v2_tit3" .IX Item "$item_id3v2_poss" .IX Item "$item_id3v2_grid" .IX Item "$item_id3v2_uslt" .IX Item "$item_id3v2_encr" .IX Item "$item_id3v2_town" .IX Item "$item_id3v2_wors" .IX Item "$item_id3v2_etco" .IX Item "$item_id3v2_equa" .IX Item "$item_id3v2_wcom" .IX Item "$item_id3v2_aenc" .IX Item "$item_id3v2_tope" .IX Item "$item_id3v2_wcop" .IX Item "$item_id3v2_popm" .IX Item "$item_id3v2_wpub" .IX Item "$item_id3v2_wxxx" .IX Item "$item_id3v2_user" .IX Header "ACKNOWLEDGEMENTS" .IX Header "SEE ALSO" .IX Item "\s-1MP3::\s0Info" .IX Item "ID3v2" .IX Item "SourceForge" .IX Item "icecast" .IX Header "AUTHOR AND COPYRIGHT" mp3report-1.0.3/mp3report.pl000077500000000000000000000656511373454643600157750ustar00rootroot00000000000000#!/usr/bin/perl -w # # Neon Goat MP3 Report Generator - mp3report.pl # Copyright (C) 2000, David Parker, Neon Goat Productions. # www.neongoat.com - david@neongoat.com # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # See the file COPYING or http://www.gnu.org for more details. no strict 'refs'; use Getopt::Long; use IO::File; use MP3::Info; my ($tnumdir, $tnumfile, $tsize, $tmin, $tsec) = (0, 0, 0, 0, 0); my ($template_header, $template_itemheader, $template_itemitem, $template_itemfooter, $template_footer); my (@dirs, $printmode, $title, $outfile); # local's necessary for all variables that are to be 'dynamically' interpolated into the HTML template local $VERSION = "1.0.2"; local ($t_fontsize, $t_title, $t_datetime, $t_dirs, $t_numdirs, $t_numfiles, $t_size, $t_playtime, $t_exectime, $t_avgsize, $t_avgplaytime); local ($t_filename, $t_template_filename, $t_printmode, $t_customdirs, $t_genretype, $t_id3v2); local ($item_dir, $item_num, $item_filename, $item_size, $item_bgcolor, $item_len); local ($item_totalseconds, $item_mp3version, $item_stereo, $item_mpeglayer, $item_bitrate, $item_vbr, $item_copyrighted, $item_frequency, $item_mode); local ($item_id3title, $item_id3artist, $item_id3album, $item_id3year, $item_id3comment, $item_id3genre, $item_id3tracknum); # id3v2 local variables defined below if --id3v2 is specified on the cmd line ########################################################## # my hardcoded defaults, you probably want to change these ########################################################## $printmode = 0; ## $title = "the mad diPPer's MP3 Catalog"; $title = "[untitled mp3report]"; $outfile = "mp3report.html"; ## $dirs[@dirs] = 'C:\Audio\Napster'; ## $dirs[@dirs] = 'D:\symphonic iNSANiTY'; ########################################################## # end of config settings ########################################################## print STDERR "\nNeon Goat MP3 Report Generator v$VERSION"; print STDERR "\nCopyright (C) 2000, David Parker, Neon Goat Productions."; print STDERR "\nwww.neongoat.com - david\@neongoat.com\n"; my ($longopt_help, $longopt_print, $longopt_title, $longopt_outfile, $longopt_template, $longopt_stdgenres, $longopt_id3v2); GetOptions("help" => \$longopt_help, "printmode" => \$longopt_print, "title=s" => \$longopt_title, "outfile=s" => \$longopt_outfile, "template=s" => \$longopt_template, "stdgenres" => \$longopt_stdgenres, "id3v2" => \$longopt_id3v2); if ($longopt_help || (!@ARGV && !@dirs)) { print STDERR "\nUsage: $0 [options] [directory...]"; print STDERR "\n --help\t\t\tshows this help screen"; print STDERR "\n --printmode\t\tuses a smaller font for printing"; print STDERR "\n --title=TITLE\t\tsets the title used in the report"; print STDERR "\n --outfile=OUTFILE\tfile to write report to, '-' for STDOUT"; print STDERR "\n --template=FILE\tfile to use as report template"; print STDERR "\n --stdgenres\t\tuse standard genres instead of winamp genres"; print STDERR "\n --id3v2\t\tenable id3v2 support (experimental)"; print STDERR "\n directory...\t\tdirs to scan (subdirs included)\n\n"; exit; } if ($longopt_print) { $printmode = 1; } if ($longopt_title) { $title = $longopt_title; } if ($longopt_outfile) { $outfile = $longopt_outfile; } if (!$longopt_stdgenres) { use_winamp_genres(); } if ($longopt_id3v2) { print STDERR "\nWarning: Enabling ID3v2 support. This is still experimental and may act funny.\n"; # a little hackery to define id3v2 template variables: foreach $tag (keys %$MP3::Info::v2_tag_names) { eval 'local $item_id3v2_' . lc($tag) . ' = " ";' || die "can't eval for id3v2 tags"; } } my $tmpfile1 = IO::File->new_tmpfile() or die "Unable to create temp file 1 of 2: $!"; my $tmpfile2 = IO::File->new_tmpfile() or die "Unable to create temp file 2 of 2: $!"; $t_filename = $outfile; $t_template_filename = $longopt_template; $t_printmode = $printmode ? 'Yes' : 'No'; $t_customdirs = 'No'; $t_genretype = $longopt_stdgenres ? 'Standard' : 'WinAMP'; $t_id3v2 = $longopt_id3v2 ? 'Yes' : 'No'; my $dirsep = ((($^O =~ /MSWin32/i) || ($^O =~ /dos/i)) ? '\\' : (($^O =~ /mac/i) ? ':' : '/')); if (@ARGV) { # clear out hardcoded dirs undef @dirs; $t_customdirs = 'Yes'; foreach my $opt_dir (sort @ARGV) { $dirs[@dirs] = $opt_dir; } } foreach my $foo (@dirs) { $foo =~ s/($dirsep)*$//i; # nuke trailing slashes } my $starttime = (times)[0]; $t_fontsize = ($printmode ? 1 : 2); $t_title = $title; open(EET, "> $outfile"); if ($longopt_template) { templatize($longopt_template); } else { default_templatize(); } local $item_name; $item_name = "(\$item_name deprecated, use \$item_filename)"; foreach $dir (sort @dirs) { dodir($dir); } print STDERR "\n\nWriting report to $outfile..."; $t_datetime = localtime; $t_dirs = join("
  ", sort @dirs); $t_numdirs = $tnumdir; $t_numfiles = $tnumfile; $t_size = sprintf("%.2f GB (%.2f MB)", $tsize/1024/1024/1024, $tsize/1024/1024); $t_playtime = englishtime(60 * $tmin + $tsec); $t_avgsize = sprintf("%.2f MB", $t_numfiles ? $tsize/1024/1024/$t_numfiles : 0); $t_avgplaytime = englishtime(sprintf("%.2f", $t_numfiles ? (60 * $tmin + $tsec)/$t_numfiles : 0)); $report_header = $template_header; $report_footer = $template_footer; $report_header =~ s/\$(\w+)/${$1}/g; print EET $report_header; seek($tmpfile1, 0, 0); # about to slurp in the contents of tempfile while(<$tmpfile1>) { print EET $_; } close($tmpfile1); close($tmpfile2); $t_exectime = englishtime(sprintf("%.2f", (times)[0])); $report_footer =~ s/\$(\w+)/${$1}/g; print EET $report_footer; close(EET); print STDERR "\nDone, report generated in $t_exectime!\n"; exit; sub dodir { my $dir = shift; if ( -r $dir ) { print STDERR "\nScanning $dir..."; } else { print STDERR "\nSkipping $dir..."; return } opendir(DIR, $dir) || die("couldn't open dir $dir: $!"); my @files = sort grep { /\.mp3$/i } readdir(DIR); if (@files) { my $report_header = $template_itemheader; $item_dir = $dir; $report_header =~ s/\$(\w+)/${$1}/g; } truncate($tmpfile2, 0); seek($tmpfile2, 0, 0); foreach $mp3 (@files) { my ($size, $min, $sec, $name); $size = (stat($dir.$dirsep.$mp3))[7]; if (my $mp3info = get_mp3info($dir.$dirsep.$mp3)) { $tsize += $size; $tmin += $mp3info->{MM}; $tsec += $mp3info->{SS}; $tnumfile++; $item_num = sprintf("%04u", $tnumfile); $item_filename = $mp3; $item_size = sprintf("%.2f MB", $size/1024/1024); $item_len = sprintf("%02u:%02u", $mp3info->{MM}, $mp3info->{SS}); $item_bgcolor = ($tnumfile%2) ? "#FFFFFF" : "#EEEEEE"; $item_totalseconds = $mp3info->{MM}*60 + $mp3info->{SS}; $item_mp3version = $mp3info->{VERSION}; $item_stereo = $mp3info->{STEREO} ? Stereo : Mono; $item_mpeglayer = $mp3info->{LAYER}; $item_bitrate = $mp3info->{BITRATE}; $item_vbr = $mp3info->{VBR} ? VBR : ''; $item_mode = $mp3info->{MODE}; $item_copyrighted = $mp3info->{COPYRIGHT} ? Copyrighted : 'Not copyrighted'; $item_frequency = $mp3info->{FREQUENCY}; # clear out id3 variables from previous match $item_id3title = ""; $item_id3artist = ""; $item_id3album = ""; $item_id3year = ""; $item_id3comment = ""; $item_id3genre = ""; $item_id3tracknum = ""; if (my $mp3tag = get_mp3tag($dir.$dirsep.$mp3)) { $item_id3title = $mp3tag->{TITLE}; $item_id3artist = $mp3tag->{ARTIST}; $item_id3album = $mp3tag->{ALBUM}; $item_id3year = $mp3tag->{YEAR}; $item_id3comment = $mp3tag->{COMMENT}; $item_id3genre = $mp3tag->{GENRE}; $item_id3tracknum = $mp3tag->{TRACKNUM}; } # clear out id3v2 variables from previous match foreach $tag (keys %MP3::Info::v2_tag_names) { eval '$item_id3v2_' . lc($tag) . ' = "";'; } if ($longopt_id3v2 && (my $mp3tag_id3v2 = get_mp3tag($dir.$dirsep.$mp3, 2, 1))) { # fill in id3v2 tags foreach $tag (keys %MP3::Info::v2_tag_names) { eval '$item_id3v2_' . lc($tag) . ' = defined($mp3tag_id3v2->{$tag}) ? $mp3tag_id3v2->{$tag} : "";'; } } $report_item = $template_itemdata; $report_item =~ s/\$(\w+)/${$1}/g; print $tmpfile2 $report_item; } else { print STDERR "\nWarning: $dir$dirsep$mp3 is not a valid MP3, skipping..."; } } if (@files) { my $report_header = $template_itemheader; $item_dir = $dir; $report_header =~ s/\$(\w+)/${$1}/g; print $tmpfile1 $report_header; } seek($tmpfile2, 0, 0); while(<$tmpfile2>) { print $tmpfile1 $_; } truncate($tmpfile2, 0); seek($tmpfile2, 0, 0); closedir(DIR); if (@files) { print $tmpfile1 $template_itemfooter; } opendir(SUBDIR, $dir) || die("couldn't open subdir $dir: $!"); foreach $subdir (sort grep { -d } map { $dir.$dirsep.$_ } grep { !/^\./ } readdir(SUBDIR)) { dodir($subdir); } $tnumdir++; } sub englishtime { my $tsec = shift; my ($english, @fragments); my $flub = int($tsec/60/60/24); if ($flub > 0) { $fragments[@fragments] = "$flub day" . (($flub != 1) ? 's' : ''); $tsec -= $flub*60*60*24; } $flub = int($tsec/60/60); if ($flub > 0) { $fragments[@fragments] = "$flub hour" . (($flub != 1) ? 's' : ''); $tsec -= $flub*60*60; } $flub = int($tsec/60); if ($flub > 0) { $fragments[@fragments] = "$flub minute" . (($flub != 1) ? 's' : ''); $tsec -= $flub*60; } if ($tsec) { $fragments[@fragments] = "$tsec second" . (($tsec != 1) ? 's' : ''); } $english = (@fragments == 0) ? '' : (@fragments == 1) ? $fragments[0] : (@fragments == 2) ? join(" and ", @fragments) : join(", ", @fragments[0 .. ($#fragments-1)], "and $fragments[-1]"); return $english; } sub templatize { my $template = shift; my $slurped; my $parsepos = 0; my @parsetokens = qw(START_TEMPLATE_HEADER END_TEMPLATE_HEADER START_TEMPLATE_ITEMHEADER END_TEMPLATE_ITEMHEADER START_TEMPLATE_ITEMDATA END_TEMPLATE_ITEMDATA START_TEMPLATE_ITEMFOOTER END_TEMPLATE_ITEMFOOTER START_TEMPLATE_FOOTER END_TEMPLATE_FOOTER); my $parseline = ''; open(TEMPLATE, "< $template") || die "can't open template file $template: $!"; #slurp whole file my $oldslurp = $/; undef $/; $slurped =