Can't write ID3 tags using getID3 1.9.7

1.3k views Asked by At

I'm trying to take advantage of Wordpress' 3.6 support for getID3(), but I'm having trouble writing ID3 tags to my mp3s. Here is the code I'm using:

if ( ! class_exists( 'getID3' ) ) {
    require(ABSPATH.WPINC.'/ID3/getid3.php' );
}

# I had to custom install the write library because WP doesn't include it by default, evidently
getid3_lib::IncludeDependency(TEMPLATEPATH.'/lib/getid3/write.php', __FILE__);

$testfile = "/Users/jplew/Sites/dev.example.com/content/uploads/mp3.mp3";

$tagwriter = new getid3_writetags;
$tagwriter->filename   = $testfile;
$tagwriter->tagformats = array('id3v2.4');
$TagData['title'][]  = 'My Heart Will Go On';
$TagData['artist'][] = 'Celine Dion';
$TagData['genre'][]  = '90s Classics';

$tagwriter->tag_data = $TagData;

if ($tagwriter->WriteTags()) {
    echo 'success';
} else {
    echo 'failure';
}

I am consistently getting 'failure'. The path to the getid3_writetags function is fine. I know this because when I print_r($tagwriter);, it outputs all the arrays as specified. However the 'warnings' and 'errors' arrays are both empty.

Moreover, when I do the following it successfully returns all the correct tag information:

$data = $getid3->analyze( $testfile );
print_r($data)

I should also note that the demo.write.php included in the demos also fails when I run it. It gets as far as starting to write tag(s) then stops.

Any ideas? I'd post on the getid3.org forum but my IP is blacklisted. :(

1

There are 1 answers

0
Blaine Huff On BEST ANSWER

Wordpress did not include the entire GetID3 library when they implemented it. They only used the files to get the most popular video and audio tags.