Audio-Scan

 view release on metacpan or  search on metacpan

t/mp3.t  view on Meta::CPAN

        is( $tags->{TPE1}, $a, 'ID3v2.4 UTF-8 title ok' );
        is( $tags->{$b}, $c, 'ID3v2.4 UTF-8 TXXX key/value ok' );
    }
}

# ID3v2.4 from iTunes with non-standard tags with spaces
{
    my $s = Audio::Scan->scan( _f('v2.4-itunes81.mp3') );

    my $info = $s->{info};
    my $tags = $s->{tags};

    is( $info->{id3_version}, 'ID3v2.4.0', 'ID3v2.4 from iTunes ok' );
    is( $tags->{TSOT}, 'Track Title Sort', 'ID3v2.4 invalid iTunes TST frame ok' );
    is( $tags->{TCON}, 'Metal', 'ID3v2.4 TCON with (9) ok' );
    is( $tags->{RVA2}->[0], '', 'ID3v2.4 RVA2 ok' );
    is( $tags->{RVA2}->[1], 1, 'ID3v2.4 RVA2 channel ok' );
    is( $tags->{RVA2}->[2], '-2.109375 dB', 'ID3v2.4 RVA2 adjustment ok' );
    is( $tags->{RVA2}->[3], '0.000000 dB', 'ID3v2.4 RVA2 peak ok' );
}

# ID3v2.4 with JPEG APIC
{
    my $s = Audio::Scan->scan( _f('v2.4-apic-jpg.mp3') );

    my $tags = $s->{tags};

    is( ref $tags->{APIC}, 'ARRAY', 'ID3v2.4 APIC JPEG frame is array' );
    is( $tags->{APIC}->[0], 'image/jpeg', 'ID3v2.4 APIC JPEG mime type ok' );
    is( $tags->{APIC}->[1], 3, 'ID3v2.4 APIC JPEG picture type ok' );
    is( $tags->{APIC}->[2], 'This is the front cover description', 'ID3v2.4 APIC JPEG description ok' );
    is( length( $tags->{APIC}->[3] ), 2103, 'ID3v2.4 APIC JPEG picture length ok' );
    is( unpack( 'H*', substr( $tags->{APIC}->[3], 0, 4 ) ), 'ffd8ffe0', 'ID3v2.4 APIC JPEG picture data ok ');
}

# Test AUDIO_SCAN_NO_ARTWORK
{
    local $ENV{AUDIO_SCAN_NO_ARTWORK} = 1;

    my $s = Audio::Scan->scan( _f('v2.4-apic-jpg.mp3') );

    my $tags = $s->{tags};

    is( $tags->{APIC}->[3], 2103, 'ID3v2.4 APIC JPEG picture with AUDIO_SCAN_NO_ARTWORK=1 ok ');
    is( $tags->{APIC}->[4], 351, 'ID3v2.4 APIC JPEG picture with AUDIO_SCAN_NO_ARTWORK=1 offset value ok' );
}

# Test setting AUDIO_SCAN_NO_ARTWORK to 0
{
    local $ENV{AUDIO_SCAN_NO_ARTWORK} = 0;

    my $s = Audio::Scan->scan( _f('v2.4-apic-jpg.mp3') );

    my $tags = $s->{tags};

    is( length( $tags->{APIC}->[3] ), 2103, 'ID3v2.4 APIC JPEG picture with AUDIO_SCAN_NO_ARTWORK=0 ok' );
}

# ID3v2.4 with PNG APIC
{
    my $s = Audio::Scan->scan( _f('v2.4-apic-png.mp3') );

    my $tags = $s->{tags};

    is( ref $tags->{APIC}, 'ARRAY', 'ID3v2.4 APIC PNG frame is array' );
    is( $tags->{APIC}->[0], 'image/png', 'ID3v2.4 APIC PNG mime type ok' );
    is( $tags->{APIC}->[1], 3, 'ID3v2.4 APIC PNG picture type ok' );
    is( $tags->{APIC}->[2], 'This is the front cover description', 'ID3v2.4 APIC PNG description ok' );
    is( length( $tags->{APIC}->[3] ), 58618, 'ID3v2.4 APIC PNG picture length ok' );
    is( unpack( 'H*', substr( $tags->{APIC}->[3], 0, 4 ) ), '89504e47', 'ID3v2.4 APIC PNG picture data ok ');
}

# ID3v2.4 with multiple APIC
{
    my $s = Audio::Scan->scan( _f('v2.4-apic-multiple.mp3') );

    my $tags = $s->{tags};

    my $png = $tags->{APIC}->[0];
    my $jpg = $tags->{APIC}->[1];

    is( ref $png, 'ARRAY', 'ID3v2.4 APIC PNG frame is array' );
    is( $png->[0], 'image/png', 'ID3v2.4 APIC PNG mime type ok' );
    is( $png->[1], 3, 'ID3v2.4 APIC PNG picture type ok' );
    is( $png->[2], 'This is the front cover description', 'ID3v2.4 APIC PNG description ok' );
    is( length( $png->[3] ), 58618, 'ID3v2.4 APIC PNG picture length ok' );
    is( unpack( 'H*', substr( $png->[3], 0, 4 ) ), '89504e47', 'ID3v2.4 APIC PNG picture data ok ');

    is( ref $jpg, 'ARRAY', 'ID3v2.4 APIC JPEG frame is array' );
    is( $jpg->[0], 'image/jpeg', 'ID3v2.4 APIC JPEG mime type ok' );
    is( $jpg->[1], 4, 'ID3v2.4 APIC JPEG picture type ok' );
    is( $jpg->[2], 'This is the back cover description', 'ID3v2.4 APIC JPEG description ok' );
    is( length( $jpg->[3] ), 2103, 'ID3v2.4 APIC JPEG picture length ok' );
    is( unpack( 'H*', substr( $jpg->[3], 0, 4 ) ), 'ffd8ffe0', 'ID3v2.4 APIC JPEG picture data ok ');
}

# ID3v2.4 with GEOB
{
    my $s = Audio::Scan->scan( _f('v2.4-geob.mp3') );

    my $tags = $s->{tags};

    is( ref $tags->{GEOB}, 'ARRAY', 'ID3v2.4 GEOB is array' );
    is( $tags->{GEOB}->[0], 'text/plain', 'ID3v2.4 GEOB mime type ok' );
    is( $tags->{GEOB}->[1], 'eyeD3.txt', 'ID3v2.4 GEOB filename ok' );
    is( $tags->{GEOB}->[2], 'eyeD3 --help output', 'ID3v2.4 GEOB content description ok' );
    is( length( $tags->{GEOB}->[3] ), 6207, 'ID3v2.4 GEOB length ok' );
    is( substr( $tags->{GEOB}->[3], 0, 6 ), "\nUsage", 'ID3v2.4 GEOB content ok' );
}

# ID3v2.4 with multiple GEOB
{
    my $s = Audio::Scan->scan( _f('v2.4-geob-multiple.mp3') );

    my $tags = $s->{tags};

    my $a = $tags->{GEOB}->[0];
    my $b = $tags->{GEOB}->[1];

    is( ref $a, 'ARRAY', 'ID3v2.4 GEOB multiple A is array' );
    is( $a->[0], 'text/plain', 'ID3v2.4 GEOB multiple A mime type ok' );
    is( $a->[1], 'eyeD3.txt', 'ID3v2.4 GEOB multiple A filename ok' );
    is( $a->[2], 'eyeD3 --help output', 'ID3v2.4 GEOB multiple A content description ok' );
    is( length( $a->[3] ), 6207, 'ID3v2.4 GEOB multiple A length ok' );
    is( substr( $a->[3], 0, 6 ), "\nUsage", 'ID3v2.4 GEOB multiple A content ok' );

    is( ref $b, 'ARRAY', 'ID3v2.4 GEOB multiple B is array' );
    is( $b->[0], 'text/plain', 'ID3v2.4 GEOB multiple B mime type ok' );
    is( $b->[1], 'genres.txt', 'ID3v2.4 GEOB multiple B filename ok' );
    is( $b->[2], 'eyeD3 --list-genres output', 'ID3v2.4 GEOB multiple B content description ok' );
    is( length( $b->[3] ), 4087, 'ID3v2.4 GEOB multiple B length ok' );
    is( substr( $b->[3], 0, 10 ), '  0: Blues', 'ID3v2.4 GEOB multiple B content ok' );
}

# ID3v2.4 with TIPL frame that has multiple strings
{
    my $s = Audio::Scan->scan( _f('v2.4-tipl.mp3') );

    my $tags = $s->{tags};

    is( ref $tags->{TIPL}, 'ARRAY', 'ID3v2.4 TIPL array ok' );
    is( $tags->{TIPL}->[0], 'producer', 'ID3v2.4 TIPL string 1 ok' );
    is( $tags->{TIPL}->[1], 'Steve Albini', 'ID3v2.4 TIPL string 2 ok' );
    is( $tags->{TIPL}->[2], 'engineer', 'ID3v2.4 TIPL string 3 ok' );
    is( $tags->{TIPL}->[3], 'Steve Albini', 'ID3v2.4 TIPL string 4 ok' );
}



( run in 2.865 seconds using v1.01-cache-2.11-cpan-788537b7465 )