JamesHeinrich / getID3

http://www.getid3.org/
Other
1.15k stars 245 forks source link

getid3_writetags removes all tags while the remove_other_tags is `false` #395

Closed foremtehan closed 2 years ago

foremtehan commented 2 years ago

I want to override or add some tags into an mp3 file, but the problem is getid3_writetags removes all tags then add my specific tags:

$getId = new \getID3();
$write = new \getid3_writetags();

$write->filename = "file.mp3";
$write->tag_encoding = 'UTF-8';
$write->remove_other_tags = false;
$write->tagformats = ['id3v2.3', 'id3v1'];

$write->tag_data = [
    'artist' => ['My Artist']
];

$write->WriteTags();

How can i tell just add or override my tags but also keep other tags and don't remove them?

version: 1.9.21

JamesHeinrich commented 2 years ago

remove_other_tags applies to other tag formats not specified in tagformat (e.g. if true in your above example it would remove any APE or Lyrics3 tags from the file, if present). What you're probably looking for is overwrite_tags = false

If true will erase existing tag data and write only passed data; if false will merge passed data with existing tag data.

foremtehan commented 2 years ago

@JamesHeinrich Ok but when using overwrite_tags = false i get this exception:

$this->overwrite_tags=false is known to be buggy in this version of getID3. Check http://github.com/JamesHeinrich/getID3 for a newer version.

Even though the lib was updated to 2.0^ it has the same error

JamesHeinrich commented 2 years ago

Yes, as noted on getid3.org:

Note: Tag writing (for all file and tag formats) is barely alpha-quality code, and needs considerable rewriting, and is generally unsupported. Use with caution, and expect that things may be incomplete or broken.

There are no plans to revisit the tag-writing code anytime soon, sorry.