"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/Image/ExifTool/ID3.pm" between
Image-ExifTool-12.05.tar.gz and Image-ExifTool-12.06.tar.gz

About: ExifTool is a platform-independent Perl library plus a command-line application for reading, writing and editing meta information in a wide variety of files.

ID3.pm  (Image-ExifTool-12.05):ID3.pm  (Image-ExifTool-12.06)
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# File: ID3.pm # File: ID3.pm
# #
# Description: Read ID3 meta information # Description: Read ID3 and Lyrics3 meta information
# #
# Revisions: 09/12/2005 - P. Harvey Created # Revisions: 09/12/2005 - P. Harvey Created
# 09/08/2020 - PH Added Lyrics3 support
# #
# References: 1) http://www.id3.org/ # References: 1) http://www.id3.org/
# 2) http://www.mp3-tech.org/ # 2) http://www.mp3-tech.org/
# 3) http://www.fortunecity.com/underworld/sonic/3/id3tag.html # 3) http://www.fortunecity.com/underworld/sonic/3/id3tag.html
# 4) https://id3.org/Lyrics3
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
package Image::ExifTool::ID3; package Image::ExifTool::ID3;
use strict; use strict;
use vars qw($VERSION); use vars qw($VERSION);
use Image::ExifTool qw(:DataAccess :Utils); use Image::ExifTool qw(:DataAccess :Utils);
$VERSION = '1.54'; $VERSION = '1.55';
sub ProcessID3v2($$$); sub ProcessID3v2($$$);
sub ProcessPrivate($$$); sub ProcessPrivate($$$);
sub ProcessSynText($$$); sub ProcessSynText($$$);
sub ConvertID3v1Text($$); sub ConvertID3v1Text($$);
sub ConvertTimeStamp($); sub ConvertTimeStamp($);
# audio formats that we process after an ID3v2 header (in order) # audio formats that we process after an ID3v2 header (in order)
my @audioFormats = qw(APE MPC FLAC OGG MP3); my @audioFormats = qw(APE MPC FLAC OGG MP3);
skipping to change at line 71 skipping to change at line 73
my %dateTimeConv = ( my %dateTimeConv = (
ValueConv => 'require Image::ExifTool::XMP; Image::ExifTool::XMP::ConvertXMP Date($val)', ValueConv => 'require Image::ExifTool::XMP; Image::ExifTool::XMP::ConvertXMP Date($val)',
PrintConv => '$self->ConvertDateTime($val)', PrintConv => '$self->ConvertDateTime($val)',
); );
# This table is just for documentation purposes # This table is just for documentation purposes
%Image::ExifTool::ID3::Main = ( %Image::ExifTool::ID3::Main = (
VARS => { NO_ID => 1 }, VARS => { NO_ID => 1 },
NOTES => q{ NOTES => q{
ExifTool extracts ID3 information from MP3, MPEG, AIFF, OGG, FLAC, APE, ExifTool extracts ID3 and Lyrics3 information from MP3, MPEG, AIFF, OGG,
MPC FLAC, APE, MPC and RealAudio files. ID3v2 tags which support multiple
and RealAudio files. ID3v2 tags which support multiple languages (eg. languages (eg. Comment and Lyrics) are extracted by specifying the tag n
Comment and Lyrics) are extracted by specifying the tag name, followed b ame,
y a followed by a dash ('-'), then a 3-character ISO 639-2 language code (eg
dash ('-'), then a 3-character ISO 639-2 language code (eg. "Comment-spa .
"). "Comment-spa"). See L<http://www.id3.org/> for the official ID3
See L<http://www.id3.org/> for the official ID3 specification and specification and L<http://www.loc.gov/standards/iso639-2/php/code_list.
L<http://www.loc.gov/standards/iso639-2/php/code_list.php> for a list of php>
ISO for a list of ISO 639-2 language codes.
639-2 language codes.
}, },
ID3v1 => { ID3v1 => {
Name => 'ID3v1', Name => 'ID3v1',
SubDirectory => { TagTable => 'Image::ExifTool::ID3::v1' }, SubDirectory => { TagTable => 'Image::ExifTool::ID3::v1' },
}, },
ID3v1Enh => { ID3v1Enh => {
Name => 'ID3v1_Enh', Name => 'ID3v1_Enh',
SubDirectory => { TagTable => 'Image::ExifTool::ID3::v1_Enh' }, SubDirectory => { TagTable => 'Image::ExifTool::ID3::v1_Enh' },
}, },
ID3v22 => { ID3v22 => {
skipping to change at line 101 skipping to change at line 103
ID3v23 => { ID3v23 => {
Name => 'ID3v2_3', Name => 'ID3v2_3',
SubDirectory => { TagTable => 'Image::ExifTool::ID3::v2_3' }, SubDirectory => { TagTable => 'Image::ExifTool::ID3::v2_3' },
}, },
ID3v24 => { ID3v24 => {
Name => 'ID3v2_4', Name => 'ID3v2_4',
SubDirectory => { TagTable => 'Image::ExifTool::ID3::v2_4' }, SubDirectory => { TagTable => 'Image::ExifTool::ID3::v2_4' },
}, },
); );
# Lyrics3 tags (ref 4)
%Image::ExifTool::ID3::Lyrics3 = (
GROUPS => { 1 => 'Lyrics3', 2 => 'Audio' },
NOTES => q{
ExifTool extracts Lyrics3 version 1.00 and 2.00 tags from any file that
supports ID3. See L<https://id3.org/Lyrics3> for the specification.
},
IND => 'Indications',
LYR => 'Lyrics',
INF => 'AdditionalInfo',
AUT => { Name => 'Author', Groups => { 2 => 'Author' } },
EAL => 'ExtendedAlbumName',
EAR => 'ExtendedArtistName',
ETT => 'ExtendedTrackTitle',
IMG => 'AssociatedImageFile',
CRC => 'CRC', #PH
);
# Mapping for ID3v1 Genre numbers # Mapping for ID3v1 Genre numbers
my %genre = ( my %genre = (
0 => 'Blues', 0 => 'Blues',
1 => 'Classic Rock', 1 => 'Classic Rock',
2 => 'Country', 2 => 'Country',
3 => 'Dance', 3 => 'Dance',
4 => 'Disco', 4 => 'Disco',
5 => 'Funk', 5 => 'Funk',
6 => 'Grunge', 6 => 'Grunge',
7 => 'Hip-Hop', 7 => 'Hip-Hop',
skipping to change at line 1350 skipping to change at line 1370
%extra %extra
); );
} }
} }
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Extract ID3 information from an audio file # Extract ID3 information from an audio file
# Inputs: 0) ExifTool object reference, 1) dirInfo reference # Inputs: 0) ExifTool object reference, 1) dirInfo reference
# Returns: 1 on success, 0 if this file didn't contain ID3 information # Returns: 1 on success, 0 if this file didn't contain ID3 information
# - also processes audio data if any ID3 information was found # - also processes audio data if any ID3 information was found
# - sets ExifTool DoneID3 to 1 when called, or to 2 if an ID3v1 trailer exists # - sets ExifTool DoneID3 to 1 when called, or to trailer size if an ID3v1 trail er exists
sub ProcessID3($$) sub ProcessID3($$)
{ {
my ($et, $dirInfo) = @_; my ($et, $dirInfo) = @_;
return 0 if $$et{DoneID3}; # avoid infinite recursion return 0 if $$et{DoneID3}; # avoid infinite recursion
$$et{DoneID3} = 1; $$et{DoneID3} = 1;
# allow this to be called with either RAF or DataPt # allow this to be called with either RAF or DataPt
my $raf = $$dirInfo{RAF} || new File::RandomAccess($$dirInfo{DataPt}); my $raf = $$dirInfo{RAF} || new File::RandomAccess($$dirInfo{DataPt});
my ($buff, %id3Header, %id3Trailer, $hBuff, $tBuff, $eBuff, $tagTablePtr); my ($buff, %id3Header, %id3Trailer, $hBuff, $tBuff, $eBuff, $tagTablePtr);
skipping to change at line 1429 skipping to change at line 1449
$tagTablePtr = GetTagTable('Image::ExifTool::ID3::v2_3'); $tagTablePtr = GetTagTable('Image::ExifTool::ID3::v2_3');
} else { } else {
$tagTablePtr = GetTagTable('Image::ExifTool::ID3::v2_2'); $tagTablePtr = GetTagTable('Image::ExifTool::ID3::v2_2');
} }
$hdrEnd = $raf->Tell(); $hdrEnd = $raf->Tell();
last; last;
} }
# #
# read ID3v1 trailer if it exists # read ID3v1 trailer if it exists
# #
my $trailSize = 0;
if ($raf->Seek(-128, 2) and $raf->Read($tBuff, 128) == 128 and $tBuff =~ /^T AG/) { if ($raf->Seek(-128, 2) and $raf->Read($tBuff, 128) == 128 and $tBuff =~ /^T AG/) {
$$et{DoneID3} = 2; # set to 2 as flag that trailer exists $trailSize = 128;
%id3Trailer = ( %id3Trailer = (
DataPt => \$tBuff, DataPt => \$tBuff,
DataPos => $raf->Tell() - 128, DataPos => $raf->Tell() - 128,
DirStart => 0, DirStart => 0,
DirLen => length($tBuff), DirLen => length($tBuff),
); );
$id3Len += length($tBuff); $id3Len += length($tBuff);
$rtnVal = 1; $rtnVal = 1;
# load 'Enhanced TAG' information if available # load 'Enhanced TAG' information if available
if ($raf->Seek(-355, 2) and $raf->Read($eBuff, 227) == 227 and $eBuff =~ my $eSize = 227; # size of ID3 Enhanced TAG info
/^TAG+/) { if ($raf->Seek(-$trailSize - $eSize, 2) and $raf->Read($eBuff, $eSize) =
= $eSize and $eBuff =~ /^TAG+/) {
$id3Trailer{EnhancedTAG} = \$eBuff; $id3Trailer{EnhancedTAG} = \$eBuff;
$trailSize += $eSize;
}
$$et{DoneID3} = $trailSize; # save trailer size
}
#
# read Lyrics3 trailer if it exists
#
if ($raf->Seek(-$trailSize-15, 2) and $raf->Read($buff, 15) == 15 and $buff
=~ /^(.{6})LYRICS(END|200)$/) {
my $ver = $2; # Lyrics3 version ('END' for version 1)
my $len = ($ver eq 'END') ? 5100 : $1 + 15; # max Lyrics3 length
my $tbl = GetTagTable('Image::ExifTool::ID3::Lyrics3');
$len = $raf->Tell() if $len > $raf->Tell();
if ($raf->Seek(-$len, 1) and $raf->Read($buff, $len) == $len and $buff =
~ /LYRICSBEGIN/g) {
my $pos = pos($buff);
$$et{DoneID3} = $trailSize + $len - $pos + 11; # update trailer len
gth
my $oldIndent = $$et{INDENT};
$$et{INDENT} .= '| ';
if ($et->Options('Verbose')) {
$et->VPrint(0, "Lyrics3:\n");
$et->VerboseDir('Lyrics3', undef, $len);
if ($pos > 11) {
$buff = substr($buff, $pos - 11);
$pos = 11;
}
$et->VerboseDump(\$buff);
}
if ($ver eq 'END') {
# Lyrics3 v1.00
my $val = substr($buff, $pos, $len - $pos - 9);
$et->HandleTag($tbl, 'LYR', $et->Decode($val, 'Latin'));
} else {
# Lyrics3 v2.00
for (;;) {
# (note: the size field is 5 digits,, not 6 as per the docum
entation)
last unless $buff =~ /\G(.{3})(\d{5})/g;
my ($tag, $size) = ($1, $2);
$pos += 8;
last if $pos + $size > length($buff);
unless ($$tbl{$tag}) {
AddTagToTable($tbl, $tag, { Name => Image::ExifTool::Mak
eTagName("Lyrics3_$tag") });
}
$et->HandleTag($tbl, $tag, $et->Decode(substr($buff, $pos, $
size), 'Latin'));
$pos += $size;
pos($buff) = $pos;
}
$pos == length($buff) - 15 or $et->Warn('Malformed Lyrics3 v2.00
block');
}
$$et{INDENT} = $oldIndent;
} else {
$et->Warn('Error reading Lyrics3 trailer');
} }
} }
# #
# process the the information # process the the information
# #
if ($rtnVal) { if ($rtnVal) {
# first process audio data if it exists # first process audio data if it exists
if ($$dirInfo{RAF}) { if ($$dirInfo{RAF}) {
my $oldType = $$et{FILE_TYPE}; # save file type my $oldType = $$et{FILE_TYPE}; # save file type
# check current file type first # check current file type first
skipping to change at line 1586 skipping to change at line 1658
=head1 REFERENCES =head1 REFERENCES
=over 4 =over 4
=item L<http://www.id3.org/> =item L<http://www.id3.org/>
=item L<http://www.mp3-tech.org/> =item L<http://www.mp3-tech.org/>
=item L<http://www.fortunecity.com/underworld/sonic/3/id3tag.html> =item L<http://www.fortunecity.com/underworld/sonic/3/id3tag.html>
=item L<https://id3.org/Lyrics3>
=back =back
=head1 SEE ALSO =head1 SEE ALSO
L<Image::ExifTool::TagNames/ID3 Tags>, L<Image::ExifTool::TagNames/ID3 Tags>,
L<Image::ExifTool(3pm)|Image::ExifTool> L<Image::ExifTool(3pm)|Image::ExifTool>
=cut =cut
 End of changes. 12 change blocks. 
17 lines changed or deleted 97 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)