apetag.rb

apetag.rb
Last Update: 2013-11-10 15:43:18 -0800

This library implements a APEv2 reader/writer. If called from the command line, it prints out the contents of the APEv2 tag for the given filename arguments.

ruby-apetag is a pure Ruby library for manipulating APEv2 tags. It aims for standards compliance with the APE spec (1). APEv2 is the standard tagging format for Musepack (.mpc) and Monkey's Audio files (.ape), and it can also be used with mp3s as an alternative to ID3v2.x (technically, it can be used on any file type and is not limited to storing just audio file metadata).

The module is in written in pure Ruby, so it should be useable on all platforms that Ruby supports. It is developed and tested on OpenBSD with ruby 1.8 and ruby 1.9.

General Use:

require 'apetag'
a = ApeTag.new('file.mp3')
a.exists? # if it already has an APEv2 tag
a.raw # the raw APEv2+ID3v1.1 tag string in the file
a.fields # a CICPHash of fields, keys are strings, values are list of strings
a.pretty_print # string suitable for pretty printing
a.update{|fields| fields['Artist']='Test Artist'; fields.delete('Year')}
 # Update the tag with the added/changed/deleted fields
 # Note that you should do: a.update{|fields| fields.replace('Test'=>'Test')}
 # and NOT: a.update{|fields| fields = {'Test'=>'Test'}}
 # You need to update/modify the fields given, not reassign it
a.remove! # remove the APEv2 and ID3v1.1 tags.

To run the tests for the library, run test_apetag.rb.

If you find any bugs, would like additional documentation, or want to submit a patch, please use GitHub (github.com/jeremyevans/ape_tag_libs/issues)

The RDoc for the project is available at ruby-apetag.jeremyevans.net.

The most current source code can be accessed via github (github.com/jeremyevans/ape_tag_libs). Note that the library isn't modified on a regular basis, so it is unlikely to be different from the latest release.

(1) wiki.hydrogenaudio.org/index.php?title=APEv2_specification

Required files

  1. cicphash