apetag.rb

Path: apetag.rb
Last Update: Sun Jul 06 14:50:30 -0700 2008

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. The minimum Ruby version required should be 1.8, but it has only been tested on 1.8.4+. Modifying the code to work with previous version shouldn‘t be difficult, though there aren‘t any plans to do so.

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 Rubyforge (rubyforge.org/projects/apetag/).

The RDoc for the project is available at apetag.rubyforge.org.

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

Copyright (c) 2007 Jeremy Evans

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Required files

cicphash  

[Validate]