comment[0]: ARTIST=Dream Theater
comment[1]: ALBUM=Octavarium
comment[2]: TITLE=I Walk Beside You
comment[3]: DATE=2005
comment[4]: TRACKNUMBER=04
comment[5]: GENRE=Progressive
I'm using this example because I think it does a better job of illustrating my point than a simple description.
Now, there are two scenarios that I generally want to carry out when working with tags: update/modify existing tags, or replace wholesale replace the tags with new information. The latter is easy to accomplish, but the former seems to be impossible because of getID3()'s implementation of the overwrite_tags and remove_other_tags options. To illustrate, I wrote a very small program that sets the TITLE tag, then ran the program with those two options set to the four different possible combinations and captured the results after each run.
For completeness, here's the program:
- Code: Select all
require_once('getid3/getid3.php');
$file = '04-I Walk Beside You.flac';
$getID3 = new getID3;
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'write.php', __FILE__);
$TaggingFormat = 'UTF-8';
$getID3->setOption(array('encoding'=>$TaggingFormat));
$tagwriter = new getid3_writetags;
$tagwriter->filename = $file;
$tagwriter->tagformats = array('metaflac');
$tagwriter->tag_encoding = $TaggingFormat;
$tagwriter->overwrite_tags = false;
$tagwriter->remove_other_tags = false;
$TagData['TITLE'][] = 'Test Title';
$tagwriter->tag_data = $TagData;
$tagwriter->WriteTags();
$fileinfo = $getID3->analyze($file);
getid3_lib::CopyTagsToComments($fileinfo);
echo "overwrite_tags = false\n";
echo "remove_other_tags = false\n\n";
foreach ($fileinfo['comments'] as $tagname => $tagval)
for ($i = 0; $i < count($tagval); $i++)
echo strtoupper($tagname)." = {$tagval[$i]}\n";
Next up the output for the various combinations of true/false settings for overwrite_tags and remove_other_tags
- Code: Select all
overwrite_tags = false
remove_other_tags = false
TITLE = Test Title
TITLE = I Walk Beside You
ARTIST = Dream Theater
ALBUM = Octavarium
DATE = 2005
TRACKNUMBER = 04
GENRE = Progressive
- Code: Select all
overwrite_tags = true
remove_other_tags = false
TITLE = Test Title
- Code: Select all
overwrite_tags = false
remove_other_tags = true
TITLE = Test Title
TITLE = I Walk Beside You
ARTIST = Dream Theater
ALBUM = Octavarium
DATE = 2005
TRACKNUMBER = 04
GENRE = Progressive
- Code: Select all
overwrite_tags = true
remove_other_tags = true
TITLE = Test Title
As indicated in the last post, remove_other_tags is completely ignored when dealing with FLAC files. I would have to assume that this same behavior applies to Ogg Vorbis as well. Instead, only overwrite_tags seems to have any effect, and I believe it is not properly implemented as it greatly reduces the amount of flexability to users.
Going back to my scenario at the beginning of this post, it is apparently impossible to do something as simple as replacing the TITLE of the track without either creating a duplicate entry or blowing away all other tags. Sure, I could accomplish this with additional PHP code that backs up the currents tags to an array, update the array, then write them back, but all of that extra work essentially defeats the purpose using getID3() to begin with.
The behavior that I propose, and what I originally expected to see based on the option names, is as follows: (NOTE: this is my mockup, not actual output)
- Code: Select all
overwrite_tags = false
remove_other_tags = false
TITLE = Test Title
TITLE = I Walk Beside You
ARTIST = Dream Theater
ALBUM = Octavarium
DATE = 2005
TRACKNUMBER = 04
GENRE = Progressive
- Code: Select all
overwrite_tags = true
remove_other_tags = false
TITLE = Test Title
ARTIST = Dream Theater
ALBUM = Octavarium
DATE = 2005
TRACKNUMBER = 04
GENRE = Progressive
- Code: Select all
overwrite_tags = false
remove_other_tags = true
TITLE = Test Title
TITLE = I Walk Beside You
- Code: Select all
overwrite_tags = true
remove_other_tags = true
TITLE = Test Title
To me, this is a far more useful and intuitive bahavior. Does anyone else, particularly developers, have an opinion on this? I'd really love to read your feedback. Thanks.
