Adding or updating a tag

The place for "I can't figure out how to..." questions.
Post Reply
Mara Tatouille
Posts: 1
Joined: Thu Nov 20, 2008 2:31 pm

Adding or updating a tag

Post by Mara Tatouille » Thu Nov 20, 2008 2:41 pm

Hello all

I did search through the boards for a way to add or update a extended tag to an existing file, without modifying the other tags

Whereas I can get the tagwriter to create new tags with artist name, etc... I am not able to find out how to modify the current tag structure.

I can read it with the below code

Code: Select all

$getid3 = new getID3;
$getid3->encoding = 'UTF-8';

$filename = "/var/www/PersonalJesusNA.mp3";

set_time_limit (30);
$ArrayR= $getid3->info['id3v2']['POPM'];
$ArrayFull= $getid3->info;
So I have the full array of tags in $ArrayFull, and the array I want to modify in $ArrayR

My writing code is below

Code: Select all

$getID3 = new getID3;
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'write.php', __FILE__);
$TaggingFormat    = 'UTF-8';
$tagwriter = new getid3_writetags;
$tagwriter->filename   = $filename;
      $tagwriter->tagformats     = array('id3v1', 'id3v2.3');
$tagwriter->overwrite_tags = true;
$tagwriter->tag_encoding   = $TaggingFormat;
$tagwriter->remove_other_tags = false;
echo "<PRE>\n";
echo "</PRE>\n";
$tagwriter->tag_data    = $TagData;
When I try this, it should update only ['POPM'][0]['rating'] to 180 and write the tag. However, it's screwing up the tag structure completely. I end up with a near empty tag structure

Is there a guide somewhere on how to merge the existing data into the tagwriter's $tagdata? Or could someone post a snippet of code that just reads the existing tags from a file and would just copy them back (to the same file or another?

I know I'm missing something simple here, but can't find out what.

Any help appreciated.

Post Reply