class ID3::Tag1
This class models version 1.x ID3-tags, and is mostly for backwards
compatibility. It's recommended to use version 2.x
ID3-tags, because they don't truncate the values, and give more
flexibility.
Provided Functionality:
- Reads and parses audio files for ID3-tags
- Writes audio files and attaches ID3-tags to them # not yet implemented
- Low-level interface to ID3-tags
Instance Variables:
- version # either nil, or a string wtih the version number
- raw
# string containing the raw ID3 version 1 tag
Instance Methods:
- new
- read
- write # not yet implemented..
- dump
Hash-like Access:
When accessing a Tag1 object wtih the Hash syntax, you can access the
actual data in the tag. Please note that there is only a very limited
number of valid keys, and that the class does not allow "inventing" new
keys (as those would not be defined in the ID3 definition)
Examples:
> require 'id3'
=> true
> t = ID3::Tag1.new
=> {}
> t.read('mp3/d.mp3')
=> true
> t.version
=> "1.1"
> t
=> {"ARTIST"=>"Beatles, The", "ALBUM"=>"Abbey Road", "TRACKNUM"=>"1", "TITLE"=>"Come Together", "YEAR"=>"2002", "GENREID"=>"12", "COMMENT"=>"Provided by Vlet"}
> > t['ALBUM']
=> "Abbey Road"
> t['ARTIST']
=> "Beatles, The"
> t['ARTIST'] = "The Beatles"
=> "The Beatles"
# PLEASE NOTE that the raw tag is read only, and reflects the data that was read from the file!
> t.raw
=> "TAGCome Together\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000Beatles, The\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000Abbey Road\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\0002002Provided by Vlet\000\000\000\000\000\000\000\000\000\000\000\000\000\001\f"
> t.raw.hexdump
index 0 1 2 3 4 5 6 7 8 9 A B C D E F
00000000 54414743 6f6d6520 546f6765 74686572 TAGCome Together
00000010 00000000 00000000 00000000 00000000 ................
00000020 00426561 746c6573 2c205468 65000000 .Beatles, The...
00000030 00000000 00000000 00000000 00000041 ...............A
00000040 62626579 20526f61 64000000 00000000 bbey Road.......
00000050 00000000 00000000 00000000 00323030 .............200
00000060 3250726f 76696465 64206279 20566c65 2Provided by Vle
00000070 74000000 00000000 00000000 0000010c t...............
=> nil
# PLEASE NOTE that the the dump method dumps a new raw tag into a string, and reflects
# the current data of the Tag1 object (with the changes you might have made)
> t.dump
=> "TAGCome Together\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000The Beatles\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000Abbey Road\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\0002002Provided by Vlet\000\000\000\000\000\000\000\000\000\000\000\000\000\001\f"
> t.dump.hexdump
index 0 1 2 3 4 5 6 7 8 9 A B C D E F
00000000 54414743 6f6d6520 546f6765 74686572 TAGCome Together
00000010 00000000 00000000 00000000 00000000 ................
00000020 00546865 20426561 746c6573 00000000 .The Beatles....
00000030 00000000 00000000 00000000 00000041 ...............A
00000040 62626579 20526f61 64000000 00000000 bbey Road.......
00000050 00000000 00000000 00000000 00323030 .............200
00000060 3250726f 76696465 64206279 20566c65 2Provided by Vle
00000070 74000000 00000000 00000000 0000010c t...............
=> nil
# PLEASE NOTE that you can not just "make up" new field names
> t['something']
=> nil
> t['something'] = 'is not allowed!!'
ArgumentError: Incorrect ID3-field "something" for ID3 version 1.1
valid fields are: ARTIST,ALBUM,TRACKNUM,TITLE,YEAR,GENREID,COMMENT
from ./id3.rb:636:in `[]='
from (irb):25
from :0